diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f53850..2ac19e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v3.0.152(JUNE 10, 2021) +- Added `getMessage` in `BaseMessage`. + ## v3.0.151(MAY 28, 2021) - Added `MessageTypeFilter` in `BaseChannel`. - Improved stability. diff --git a/README.md b/README.md index 8789321..ee5d917 100644 --- a/README.md +++ b/README.md @@ -325,9 +325,8 @@ The `sb.setErrorFirstCallback(false)` returns callbacks to their original parame ## Changelogs -## v3.0.151(MAY 28, 2021) +## v3.0.152(JUNE 10, 2021) If you want to check the record of other versions, go to [Change Log](https://github.com/sendbird/Sendbird-SDK-JavaScript/blob/master/CHANGELOG.md). -- Added `MessageTypeFilter` in `BaseChannel`. -- Improved stability. \ No newline at end of file +- Added `getMessage` in `BaseMessage`. \ No newline at end of file diff --git a/SendBird.d.ts b/SendBird.d.ts index cf8a767..f8d8734 100644 --- a/SendBird.d.ts +++ b/SendBird.d.ts @@ -1,5 +1,5 @@ /** - * Type Definitions for Sendbird SDK v3.0.151 + * Type Definitions for Sendbird SDK v3.0.152 * homepage: https://sendbird.com/ * git: https://github.com/sendbird/Sendbird-SDK-JavaScript */ @@ -87,6 +87,10 @@ declare namespace SendBird { }; OpenChannel: OpenChannelStatic; GroupChannel: GroupChannelStatic; + + BaseMessage: { + getMessage(params: MessageRetrievalParams, callback?: messageCallback): Promise; + }; UserMessage: UserMessageStatic; FileMessage: FileMessageStatic; AdminMessage: AdminMessageStatic; diff --git a/SendBird.min.js b/SendBird.min.js index 95ca828..0e5094e 100644 --- a/SendBird.min.js +++ b/SendBird.min.js @@ -1,6 +1,6 @@ /** * Copyright (c) 2016 Sendbird DBA (Smile Family, Inc.) - * Sendbird JavaScript SDK v3.0.151 + * Sendbird JavaScript SDK v3.0.152 */ -!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 r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e),a=r(n),s=r(t);function o(e){return(o="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 l(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function u(e,n){for(var t=0;te.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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=e[Symbol.iterator]()},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 R=function(){function e(){l(this,e)}return c(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.151"}},{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}(),O={},T=new WeakMap,M=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l(this,e),T.set(this,"object"===o(n)&&n?n:{})}return c(e,[{key:"container",get:function(){return T.get(this)}},{key:"get",value:function(e){return T.get(this)[e]}},{key:"set",value:function(e,n){T.get(this)[e]=n}},{key:"remove",value:function(e){var n=T.get(this);n.hasOwnProperty(e)&&delete n[e]}}],[{key:"create",value:function(n,t){return O[n]=new e(t),O[n]}},{key:"get",value:function(e){return e||(e=$n.getInstance()._iid),O[e]}}]),e}(),L=function(e){f(t,e);var n=U(t);function t(e,r){var i;return l(this,t),(i=n.call(this,r)).name="SendBirdException",i.code=r||0,i.message=e,i}return c(t,[{key:"isSessionKeyExpiredError",get:function(){return 400309===this.code}},{key:"isSessionTokenExpiredError",get:function(){return 400302===this.code}}],[{key:"INVALID_INITIALIZATION",get:function(){return 800100}},{key:"CONNECTION_REQUIRED",get:function(){return 800101}},{key:"CONNECTION_CANCELED",get:function(){return 800102}},{key:"INVALID_PARAMETER",get:function(){return 800110}},{key:"NETWORK_ERROR",get:function(){return 800120}},{key:"NETWORK_ROUTING_ERROR",get:function(){return 800121}},{key:"MALFORMED_DATA",get:function(){return 800130}},{key:"MALFORMED_ERROR_DATA",get:function(){return 800140}},{key:"WRONG_CHANNEL_TYPE",get:function(){return 800150}},{key:"MARK_AS_READ_RATE_LIMIT_EXCEEDED",get:function(){return 800160}},{key:"QUERY_IN_PROGRESS",get:function(){return 800170}},{key:"ACK_TIMEOUT",get:function(){return 800180}},{key:"LOGIN_TIMEOUT",get:function(){return 800190}},{key:"WEBSOCKET_CONNECTION_CLOSED",get:function(){return 800200}},{key:"WEBSOCKET_CONNECTION_FAILED",get:function(){return 800210}},{key:"REQUEST_FAILED",get:function(){return 800220}},{key:"FILE_UPLOAD_CANCEL_FAILED",get:function(){return 800230}},{key:"REQUEST_CANCELED",get:function(){return 800240}},{key:"REQUEST_DUPLICATED",get:function(){return 800250}},{key:"FILE_SIZE_LIMIT_EXCEEDED",get:function(){return 800260}},{key:"SESSION_TOKEN_REQUEST_FAILED",get:function(){return 800500}},{key:"SESSION_TOKEN_REFRESHED",get:function(){return 800501}},{key:"SESSION_TOKEN_REFRESH_FAILED",get:function(){return 800502}}]),t}(v(Error)),P=function(){function e(){l(this,e),this.sessionToken=null,this.sessionKey=null,this.eKey=null}return c(e,[{key:"hasSession",value:function(){return!!this.sessionKey}}]),e}(),w={},D=function(){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var r in l(this,e),this._iid=n,t){var i=t[r];"function"==typeof i&&(this[r]=this.getClonedClass(i))}w[n]=this}return c(e,[{key:"getClonedClass",value:function(e){var n=this._iid;return function(t){f(i,t);var r=U(i);function i(){return l(this,i),r.apply(this,arguments)}return c(i,[{key:"_iid",get:function(){return n}}],[{key:"_iid",get:function(){return n}},{key:"_name",get:function(){return e.name}}]),i}(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=U(t);function t(){return l(this,t),n.apply(this,arguments)}return c(t,[{key:"log",value:function(e){for(var n,t,r,i,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-1&&(B=n)}},{key:"supportedLogLevels",get:function(){return j}},{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,r=new Array(t>1?t-1:0),i=1;i0){var e=this._queue.shift();this.lock(e)}}}]),e}(),W=function(){function e(n){l(this,e),this.sb=n,this.mutex=new K,this.pingTimer=null,this.pingTimeoutTimer=null}return c(e,[{key:"ping",value:function(){var e=this,n=D.get(this.sb._iid).Command.bPing(),t=M.get(this.sb._iid).container,r=t.wsAdapter,i=t.pongTimeout;r.client.send(n),Y.debug("`PING`"),this.pingTimeoutTimer=setTimeout((function(){Y.debug("`PING` timeout."),e.stop(),r.client.handler&&r.client.handler.onError()}),i)}},{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 V(){return"undefined"==typeof window&&"undefined"!=typeof process&&("node"===process.title||void 0!==process.versions&&process.versions.node||"[object process]"===String(process))}var J=[L.CONNECTION_REQUIRED,L.NETWORK_ERROR,L.ACK_TIMEOUT,L.WEBSOCKET_CONNECTION_CLOSED,L.WEBSOCKET_CONNECTION_FAILED,L.FILE_UPLOAD_CANCEL_FAILED,L.REQUEST_CANCELED,500901,500910,900200],X=function(){function e(){l(this,e)}return c(e,null,[{key:"deepEqual",value:function(e,n){if(e!==n){var t=p({},e),r=p({},n);return(!t.messageId||!r.messageId||t.messageId===r.messageId)&&((!t.reqId||!r.reqId||t.reqId===r.reqId)&&(t.hasOwnProperty("messageId")&&delete t.messageId,t.hasOwnProperty("reqId")&&delete t.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(t)===JSON.stringify(r)))}return!0}},{key:"isResendableError",value:function(e){return e>0&&J.indexOf(e)>=0}},{key:"isFile",value:function(e){var n="object"===o(e)&&null!==e&&"string"==typeof e.name&&"string"==typeof e.uri&&"string"==typeof e.type;if(!n)if(V()){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){if(l(this,e),this.fields={},n)for(var t in n)this.fields[t]={value:n[t]},X.isFile(n[t])&&(this.fields[t].filename=n[t].name);this.options={},this.internal=!1,this.upload={reqId:null,deleteRequest:null,progressHandler:null}}return c(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(){var e=!1;for(var n in this.fields)if(X.isFile(this.fields[n].value)){e=!0;break}if(e){var t=new a.default;for(var r in this.fields){var i=this.fields[r];if(X.isFile(i.value)){var s=i.value;s.filename||s.name?t.append(r,i.value,s.filename||s.name):s.data?t.append(r,i.value,s.data.name):t.append(r,i.value,"unnamed")}else t.append(r,i.value)}return t}var o={};for(var l in this.fields)o[l]=this.fields[l].value;return o}}]),e}(),$=888e3,ee=function(){function e(n){l(this,e),this.sb=n,this.cls=D.get(this.sb._iid)}return c(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,r=e.params;return t?r&&r.internal?"".concat(n,"/v").concat(R.SDK_MAJOR_VERSION,"/sdk").concat(t):"".concat(n,"/v").concat(R.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,r=void 0!==t&&t,i=n.accessToken,s=void 0===i?null:i,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(R.OS_VERSION,",").concat(R.SDK_VERSION,",").concat(c),o["SB-User-Agent"]=encodeURIComponent(p(h)),!r&&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=[];for(var r in n){var i=n[r];if(null!=i){var a="";a="object"===o(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(r,"=").concat(a))}}return t.length>0?"".concat(e,"?").concat(t.join("&")):e}catch(n){return Y.debug("createWithEncodedGetParams is failed. - ",n),e}}},{key:"_request",value:function(e,n,t,r){var s=this;this.checkRouting((function(o,l){if(o)r(new L("Request failed.",L.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:Y.supportedLogLevels.DEBUG,messages:["url:",n]},{level:Y.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||V()||"function"!=typeof fetch)switch(e){case"GET":f=i.default.get(p,{headers:d,validateStatus:s._validateStatus});break;case"POST":var g=null;if(c instanceof a.default){var y=i.default.CancelToken.source();g=y.token;var _=s.cls.FileMessageQueue,m=t.upload.reqId;m&&(h.push({level:Y.supportedLogLevels.DEBUG,messages:["request id:",m]}),_.uploadRequest[m]=y)}f=i.default.post(p,"function"==typeof c.getBuffer?c.getBuffer():c,{headers:d,validateStatus:s._validateStatus,cancelToken:g,onUploadProgress:function(e){t.upload.progressHandler&&t.upload.progressHandler(e,t.upload.reqId)}});break;case"PUT":f=i.default.put(p,c,{headers:d,validateStatus:s._validateStatus});break;case"DELETE":f=i.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 C=new AbortController,E=C.signal;v.signal=E;var U=s.cls.FileMessageQueue,b=t.upload.reqId;b&&(h.push({level:Y.supportedLogLevels.DEBUG,messages:["request id:",b]}),U.uploadRequest[b]=C)}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})}))}))}Y.group("".concat(e," request"),h),h=[],f.then((function(n){try{var i=n.data;"POST"===e&&"function"==typeof t.upload.deleteRequest&&t.upload.deleteRequest(),h.push({level:Y.supportedLogLevels.DEBUG,messages:["data:",i]}),r(null,i)}catch(e){throw{code:$,rawError:e}}})).catch((function(i){if(i.code===$)throw i.rawError;"POST"===e&&"function"==typeof t.upload.deleteRequest&&t.upload.deleteRequest();var a=s._handleError(i);h.push({level:Y.supportedLogLevels.DEBUG,messages:["error:",a]}),n&&t&&a.isSessionKeyExpiredError?M.get(s.sb._iid).container.sessionManager.refresh((function(e){return r(e,null)})):r(a,null)})).finally((function(){return Y.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 L("Request has been canceled.",L.REQUEST_CANCELED);if(t){var r=t.data,i=r?r.message:"Request failed.",a=r?r.code:L.REQUEST_FAILED;return new L(i,a)}return new L("Request failed.",L.REQUEST_FAILED)}return new L("There was a network error.",L.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 r=this,i=n.accessToken;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.USERS_USERID_SESSION_KEY.replace("%s",encodeURIComponent(a.userId)),o=new Z;o.options.noSessionKey=!0,o.options.accessToken=i,r.post(s,o,t)}}))}},{key:"updateCurrentUserInfo",value:function(n,t){var r=this,i=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;i&&c.add("nickname",i),a&&c.add("profile_url",a),s&&c.add("profile_file",s,s.name),o&&c.add("preferred_languages",o),r.put(u,c,t)}}))}},{key:"getMyGroupChannelChangeLogs",value:function(n,t){var r=this,i=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),i&&d.add("change_ts",i),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),r.get(c,d,t)}}))}},{key:"getChannelInvitationPreference",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"getGroupChannelCount",value:function(n,t){var r=this,i=n.memberStateFilter;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=r.cls.GroupChannel,o=e.Path.USERS_USERID_GROUP_CHANNEL_COUNT.replace("%s",encodeURIComponent(a.userId)),l="";switch(i){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});r.get(o,u,t)}}))}},{key:"getUnreadItemCount",value:function(n,t){var r=this,i=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:i});r.get(s,o,t)}}))}},{key:"getTotalUnreadMessageCount",value:function(n,t){var r=this,i=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!==i&&i.length>0&&l.add("custom_types",i),r.get(o,l,t)}}))}},{key:"getTotalUnreadChannelCount",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_UNREAD_CHANNEL_COUNT.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"searchMessages",value:function(n,t){var r=this,i=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,g=n.targetFields;this.sb.ConnectionManager.ready((function(n,y){if(n)t(n,null);else{var _=e.Path.SEARCH_MESSAGE,m=new Z({limit:a,reverse:s,query:i,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),g&&Array.isArray(g)&&m.add("target_fields",g),r.get(_,m,t)}}))}},{key:"markAsReadAll",value:function(n,t){var r=this,i=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;i&&o.add("channel_urls",i),r.put(s,o,t)}}))}},{key:"markAsDelivered",value:function(n,t){var r=this,i=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(i)),l=new Z;a&&l.add("user_id",a),r.put(o,l,t)}}))}},{key:"setChannelInvitationPreference",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"blockUser",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"unblockUser",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"getPushTriggerOption",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setPushTriggerOption",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"getPushTokens",value:function(n,t){var r=this,i=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),i&&u.add("created_ts",i),r.get(l,u,t)}}))}},{key:"getPushTemplate",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setPushTemplate",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"getDoNotDisturb",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setDoNotDisturb",value:function(n,t){var r=this,i=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:i,start_hour:a,start_min:s,end_hour:o,end_min:l,timezone:u});r.put(d,h,t)}}))}},{key:"getSnoozePeriod",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setSnoozePeriod",value:function(n,t){var r=this,i=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:i,snooze_start_ts:a,snooze_end_ts:s});r.put(l,u,t)}}))}},{key:"registerGCMPushToken",value:function(n,t){var r=this,i=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:i,always_push:!0});r.post(s,o,t)}}))}},{key:"unregisterGCMPushToken",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"unregisterAllGCMPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"registerAPNSPushToken",value:function(n,t){var r=this,i=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:i,always_push:!0});r.post(s,o,t)}}))}},{key:"unregisterAPNSPushToken",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"unregisterAllAPNSPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"unregisterAllPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"loadFriendList",value:function(n,t){var r=this,i=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:i});r.get(o,l,t)}}))}},{key:"getFriendChangeLogsByToken",value:function(n,t){var r=this,i=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;i&&o.add("token",i),r.get(s,o,t)}}))}},{key:"addFriends",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"deleteFriends",value:function(n,t){var r=this,i=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:i});r.delete(s,o,t)}}))}},{key:"uploadFriendDiscoveries",value:function(n,t){var r=this,i=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=[];i.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});r.put(s,l,t)}}))}},{key:"deleteFriendDiscoveries",value:function(n,t){var r=this,i=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:i});r.delete(s,o,t)}}))}},{key:"loadUserList",value:function(n,t){var r=this,i=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:i,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),r.get(d,h,t)}}))}},{key:"loadBlockedUserList",value:function(n,t){var r=this,i=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:i,limit:a});s&&s.length>0&&u.add("user_ids",s),r.get(l,u,t)}}))}},{key:"createUserMetaData",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"updateUserMetaData",value:function(n,t){var r=this,i=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:i,upsert:a});r.put(o,l,t)}}))}},{key:"deleteUserMetaData",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"deleteAllUserMetaData",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"getMessageChangeLogs",value:function(n,t){var r=this,i=n.channelUrl,a=n.ts,s=n.timestamp,o=n.token,l=n.isOpenChannel,u=n.includeMetaArray,c=n.includeReactions,d=n.includeReplies,h=n.includeParentMessageText,p=n.includeThreadInfo;this.sb.ConnectionManager.ready((function(n,f){if(n)t(n,null);else{var g=l?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)),y=new Z;o&&y.add("token",o),a&&y.add("change_ts",a),s&&y.add("change_ts",s),"boolean"==typeof u&&y.add("with_sorted_meta_array",u),"boolean"==typeof c&&y.add("include_reactions",c),"boolean"==typeof d&&y.add("include_replies",d),"boolean"==typeof h&&y.add("include_parent_text_message",h),"boolean"==typeof p&&y.add("include_thread_info",p),r.get(g,y,t)}}))}},{key:"getMyMutedInfo",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.get(l,null,t)}}))}},{key:"loadBannedUserList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(u,c,t)}}))}},{key:"loadMutedUserList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(u,c,t)}}))}},{key:"getMessageList",value:function(n,t){var r=this,i=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,g=n.customTypes,y=n.senderUserIds,_=n.includeMetaArray,m=n.includeReactions,v=n.includeThreadInfo,C=n.includeReplies,E=n.includeParentMessageText,U=n.showSubchannelMessagesOnly,b=n.rootMessageId,A=n.parentMessageId;this.sb.ConnectionManager.ready((function(n,l){if(n)t(n,null);else{var c=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url),S=new Z({is_sdk:String(!0),prev_limit:String(u),next_limit:String(d),include:String(o),reverse:String(h)});"timestamp"===s?S.add("message_ts",a):"messageId"===s&&S.add("message_id",String(a)),p&&S.add("message_type",String(p)),Array.isArray(g)&&(0===g.length&&("string"==typeof f?g.push(f):g.push("*")),S.add("custom_types",g)),Array.isArray(y)&&y.length>0&&S.add("sender_ids",y),"boolean"==typeof _&&S.add("with_sorted_meta_array",_),"boolean"==typeof m&&S.add("include_reactions",m),"boolean"==typeof v&&S.add("include_thread_info",v),"boolean"==typeof C&&S.add("include_replies",C),"boolean"==typeof E&&S.add("include_parent_message_text",E),"boolean"==typeof U&&i.isOpenChannel()&&S.add("show_subchannel_messages_only",U),b&&S.add("root_message_id",b),A&&S.add("parent_message_id",A),r.get(c,S,t)}}))}},{key:"translateUserMessage",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",s),c=new Z({target_langs:o});r.post(u,c,t)}}))}},{key:"getMessage",value:function(n,t){var r=this,i=n.channel,a=n.messageId;this.sb.ConnectionManager.ready((function(n,s){if(n)t(n,null);else{var o=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(a));r.get(o,null,t)}}))}},{key:"deleteMessage",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,t)}}))}},{key:"muteUser",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(i)),d=new Z({user_id:a});o&&(o>0||-1!==o)&&d.add("seconds",o),s&&d.add("description",s),r.post(c,d,t)}}))}},{key:"unmuteUser",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,t)}}))}},{key:"banUser",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(i)),d=new Z({user_id:a});s&&d.add("description",s),d.add("seconds",String(o)),r.post(c,d,t)}}))}},{key:"unbanUser",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,t)}}))}},{key:"getMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new Z({keys:s});r.get(l,u,t)}}))}},{key:"createMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new Z({metacounter:s});r.post(l,u,t)}}))}},{key:"updateMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),d=new Z({metacounter:s,upsert:o,mode:l});r.put(c,d,t)}}))}},{key:"deleteMetaCounter",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",s);r.delete(l,null,t)}}))}},{key:"deleteAllMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i));r.delete(o,null,t)}}))}},{key:"getMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new Z({keys:s,include_ts:!0});r.get(l,u,t)}}))}},{key:"createMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new Z({metadata:s,include_ts:!0});r.post(l,u,t)}}))}},{key:"updateMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),c=new Z({metadata:s,upsert:o,include_ts:!0});r.put(u,c,t)}}))}},{key:"deleteMetaData",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",s),u=new Z({include_ts:!0});r.delete(l,u,t)}}))}},{key:"deleteAllMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),l=new Z({include_ts:!0});r.delete(o,l,t)}}))}},{key:"loadOperatorList",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)),c=new Z({token:s,limit:o});r.get(u,c,t)}}))}},{key:"getOpenChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({});l.internal=a===R.INTERNAL_CALL,r.get(o,l,t)}}))}},{key:"loadOpenChannelList",value:function(n,t){var r=this,i=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:i,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),r.get(h,p,t)}}))}},{key:"loadParticipantList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(l,u,t)}}))}},{key:"createOpenChannel",value:function(n,t){var r=this,i=n.name,a=n.coverUrlOrImage,s=n.data,o=n.operatorUserIds,l=n.customType;this.sb.ConnectionManager.ready((function(n,u){if(n)t(n,null);else{var c=e.Path.OPENCHANNELS,d=new Z;"string"==typeof a&&d.add("cover_url",a),X.isFile(a)&&d.add("cover_file",a),null!==i&&"string"==typeof i&&d.add("name",i),s&&d.add("data",s),o&&(Array.isArray(o)?d.add("operators",o):d.add("operators",[o])),l&&d.add("custom_type",l),r.post(c,d,t)}}))}},{key:"updateOpenChannel",value:function(n,t){var r=this,i=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(i)),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),r.put(d,h,t)}}))}},{key:"deleteOpenChannel",value:function(n,t){var r=this,i=n.channelUrl;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(s,null,t)}}))}},{key:"getGroupChannel",value:function(n,t){var r=this,i=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(i)),u=new Z({show_member:a,show_read_receipt:!0,show_delivery_receipt:!0});u.internal=s===R.INTERNAL_CALL,r.get(l,u,t)}}))}},{key:"loadGroupChannelList",value:function(n,t){var r=this,i=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,g=n.superChannelFilter,y=n.publicChannelFilter,_=n.unreadChannelFilter,m=n.metadataOrderKeyFilter,v=n.hiddenChannelFilter,C=n.searchFilter,E=n.includeFrozen,U=n.includeMetaData;this.sb.ConnectionManager.ready((function(n,b){if(n)t(n,null);else{var A=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(b.userId)),S=new Z({token:i,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&&S.add("custom_types",h),u&&S.add("members_nickname_contains",u),c&&S.add("name_contains",c),C.hasOwnProperty("search_query")&&C.hasOwnProperty("search_fields")&&(S.add("search_query",C.search_query),S.add("search_fields",C.search_fields)),l.userIds&&l.userIds.length>0&&(l.includeMode?(S.add("members_include_in",l.userIds),S.add("query_type",l.queryType.toUpperCase())):S.add("members_exactly_in",l.userIds)),d&&d.length>0&&S.add("channel_urls",d),S.add("super_mode",g),S.add("public_mode",y),S.add("unread_filter",_),m&&S.add("metadata_order_key",m),p&&S.add("custom_type_startswith",p),v&&S.add("hidden_mode",v),"boolean"==typeof E&&S.add("show_frozen",E),"boolean"==typeof U&&S.add("show_metadata",U),r.get(A,S,t)}}))}},{key:"loadPublicGroupChannelList",value:function(n,t){var r=this,i=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,g=n.includeFrozen,y=n.includeMetaData;this.sb.ConnectionManager.ready((function(n,_){if(n)t(n,null);else{var m=r.cls.GroupChannel,v=e.Path.GROUPCHANNELS,C=new Z({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(s),public_mode:m.PublicChannelFilter.PUBLIC,public_membership_mode:p});c&&c.length>0&&C.add("custom_types",c),l&&C.add("name_contains",l),u&&u.length>0&&C.add("channel_urls",u),C.add("super_mode",h),f&&C.add("metadata_order_key",f),d&&C.add("custom_type_startswith",d),"boolean"==typeof g&&C.add("show_frozen",g),"boolean"==typeof y&&C.add("show_metadata",y),r.get(v,C,t)}}))}},{key:"createGroupChannel",value:function(n,t){var r=this,i=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,g=n.coverImage,y=n.accessCode,_=n.isEphemeral,m=n._invitedUserIds,v=void 0===m?[]:m,C=n.operatorUserIds,E=n.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(n,m){if(n)t(n,null);else{var U=e.Path.GROUPCHANNELS,b=new Z({user_ids:[m.userId].concat(S(v)).filter((function(e,n,t){return n===t.indexOf(e)}))});null!==f&&"string"==typeof f&&b.add("cover_url",f),X.isFile(g)&&b.add("cover_file",g,g.name),null!==l&&b.add("channel_url",l),null!==i&&b.add("is_distinct",i),null!==a&&b.add("is_super",a),null!==s&&b.add("is_broadcast",s),null!==o&&b.add("is_public",o),null!==u&&b.add("is_discoverable",u),null!==c&&b.add("strict",c),null!==_&&b.add("is_ephemeral",_),y&&b.add("access_code",y),null!==d&&"string"==typeof d&&b.add("name",d),h&&b.add("data",h),p&&b.add("custom_type",p),Array.isArray(C)&&C.length>0&&b.add("operator_ids",C),null!==E&&E>-1&&b.add("message_survival_seconds",E),r.post(U,b,t)}}))}},{key:"updateGroupChannel",value:function(n,t){var r=this,i=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,g=n.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(n,y){if(n)t(n,null);else{var _=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(s)),m=new Z;null!==i&&m.add("is_distinct",i),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!==g&&g>-1&&m.add("message_survival_seconds",g),r.put(_,m,t)}}))}},{key:"addOperators",value:function(n,t){var r=this,i=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(i)),u=new Z({operator_ids:o});r.post(l,u,t)}}))}},{key:"removeOperators",value:function(n,t){var r=this,i=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(i)),u=new Z({operator_ids:o});r.delete(l,u,t)}}))}},{key:"inviteToGroupChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({user_ids:a});r.post(o,l,t)}}))}},{key:"acceptInvitation",value:function(n,t){var r=this,i=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(i)),l=new Z({user_id:s.userId});a&&l.add("access_code",a),r.put(o,l,t)}}))}},{key:"declineInvitation",value:function(n,t){var r=this,i=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(i)),o=new Z({user_id:a.userId});r.put(s,o,t)}}))}},{key:"joinGroupChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({user_id:s.userId});a&&l.add("access_code",a),r.put(o,l,t)}}))}},{key:"leaveGroupChannel",value:function(n,t){var r=this,i=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(i)),o=new Z({user_id:a.userId});r.put(s,o,t)}}))}},{key:"hideGroupChannel",value:function(n,t){var r=this,i=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(i)),u=new Z({user_id:o.userId,hide_previous_messages:a,allow_auto_unhide:s});r.put(l,u,t)}}))}},{key:"unhideGroupChannel",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"freeze",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)),u=new Z({freeze:s});r.put(l,u,t)}}))}},{key:"deleteGroupChannel",value:function(n,t){var r=this,i=n.channelUrl;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(s,null,t)}}))}},{key:"loadMemberList",value:function(n,t){var r=this,i=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(i)),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),r.get(h,p,t)}}))}},{key:"report",value:function(n,t){var r=this,i=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(i)),d=new Z({report_category:s});null!=o&&d.add("reporting_user_id",o),null!=l&&d.add("report_description",l),r.post(c,d,t)}}))}},{key:"reportUser",value:function(n,t){var r=this,i=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(i)),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),r.post(d,h,t)}}))}},{key:"reportMessage",value:function(n,t){var r=this,i=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(i)).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),r.post(h,p,t)}}))}},{key:"sendUserMessage",value:function(n,t){var r=this,i=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,g=n.parentMessageId,y=n.appleCriticalAlertOptions;this.sb.ConnectionManager.ready((function(n,_){if(n)t(n,null);else{var m=r.cls.FileMessageParams,v=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),C=new Z({message_type:"MESG",user_id:_.userId,message:s,mention_type:d,mentioned_user_ids:[]});null!=o&&C.add("data",o),null!=l&&C.add("custom_type",l),u&&C.add("translation_target_langs",u),c&&c.length>0&&C.add("sorted_metaarray",c.map((function(e){return e.encode()}))),d===r.cls.BaseMessageParams.MentionType.CHANNEL?C.add("mentioned_user_ids",[]):Array.isArray(h)&&h.length>0&&C.add("mentioned_user_ids",h),p&&p!==m.PushNotificationDeliveryOption.DEFAULT&&C.add("push_option",p),f&&C.add("root_message_id",f),g&&C.add("parent_message_id",g),y&&C.add("apple_critical_alert_options",y.serialize()),r.post(v,C,t)}}))}},{key:"sendFileMessage",value:function(n,t){var r=this,i=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,g=n.mentionType,y=n.mentionedUserIds,_=n.pushNotificationDeliveryOption,m=n.rootMessageId,v=n.parentMessageId,C=n.appleCriticalAlertOptions;this.sb.ConnectionManager.ready((function(n,E){if(n)t(n,null);else{var U=r.cls.FileMessageParams,b=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),A=new Z({message_type:"FILE",user_id:E.userId,url:s,mention_type:g,mentioned_user_ids:[]});null!=o&&A.add("file_name",o),null!=l&&A.add("file_size",l),null!=u&&A.add("file_type",u),null!=c&&A.add("custom_field",c),null!=d&&A.add("custom_type",d),h&&A.add("thumbnails",h),p&&A.add("require_auth",p),f&&f.length>0&&A.add("sorted_metaarray",f.map((function(e){return e.encode()}))),g===r.cls.BaseMessageParams.MentionType.CHANNEL?A.add("mentioned_user_ids",[]):Array.isArray(y)&&y.length>0&&A.add("mentioned_user_ids",y),_&&_!==U.PushNotificationDeliveryOption.DEFAULT&&A.add("push_option",_),m&&A.add("root_message_id",m),v&&A.add("parent_message_id",v),C&&A.add("apple_critical_alert_options",C.serialize()),r.post(b,A,t)}}))}},{key:"uploadFile",value:function(n,t){var r=this,i=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(r.sb._iid).container.appInfo;if(c)if("number"==typeof i.size||i.size||(i.size=0),"number"==typeof i.size)if(i.size<=c.uploadSizeLimit){var d=e.Path.STORAGE_FILE,h=new Z;if(h.add("file",i,i.name),s&&"string"==typeof s&&h.add("channel_url",s),a)for(var p=0;p0&&u.add("metaarray",i.metaArrayKeys),i.mentionType&&u.add("mention_type",i._mentionType),i._mentionType===r.cls.BaseMessageParams.MentionType.CHANNEL?u.add("mentioned_user_ids",[]):Array.isArray(i._mentionedUserIds)&&i._mentionedUserIds.length>0&&u.add("mentioned_user_ids",i._mentionedUserIds),i.translationTargetLanguages&&i.translationTargetLanguages.length>0&&u.add("translation_target_langs",i.translationTargetLanguages),i.pushNotificationDeliveryOption&&i.pushNotificationDeliveryOption!==r.cls.BaseMessageParams.PushNotificationDeliveryOption.DEFAULT&&u.add("push_option",i.pushNotificationDeliveryOption),i.appleCriticalAlertOptions&&u.add("apple_critical_alert_options",i.appleCriticalAlertOptions.serialize()),r.post(l,u,t)}}))}},{key:"getMyPushTriggerOption",value:function(n,t){var r=this,i=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(i));r.get(s,null,t)}}))}},{key:"setMyPushTriggerOption",value:function(n,t){var r=this,i=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(i)),u=new Z;a&&u.add("push_trigger_option",a),"boolean"==typeof s&&u.add("enable",s),r.put(l,u,t)}}))}},{key:"setMyCountPreference",value:function(n,t){var r=this,i=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(i)),l=new Z({count_preference:a});r.put(o,l,t)}}))}},{key:"resetMyHistory",value:function(n,t){var r=this,i=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(i));r.put(s,null,t)}}))}},{key:"addReaction",value:function(n,t){var r=this,i=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=i?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});r.post(u,c,t)}}))}},{key:"deleteReaction",value:function(n,t){var r=this,i=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=i?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});r.delete(u,c,t)}}))}},{key:"getAllEmoji",value:function(n){var t=this;this.sb.ConnectionManager.ready((function(r,i){r?n(r,null):t.get(e.Path.EMOJI_CATEGORIES,null,n)}))}},{key:"getEmojiCategory",value:function(n,t){var r=this,i=n.categoryId;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.EMOJI_CATEGORIES_CATEGORYID.replace("%s",i);r.get(s,null,t)}}))}},{key:"getEmoji",value:function(n,t){var r=this,i=n.emojiKey;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.EMOJIS_EMOJIKEY.replace("%s",i);r.get(s,null,t)}}))}},{key:"getAllowFriendDiscovery",value:function(n){var t=this;this.sb.ConnectionManager.ready((function(r,i){if(r)n(r,null);else{var a=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(i.userId));t.get(a,null,n)}}))}},{key:"setAllowFriendDiscovery",value:function(n,t){var r=this,i=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 i&&o.add("allow_friend_discovery",i),r.put(s,o,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"}}}]),e}(),ne=function(){function e(n,t){l(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 c(e,[{key:"connect",value:function(e,n,t){var r=this;Y.debug("`WebSocketClient.connect` called.");var i=M.get(this.sb._iid).container,a=i.pinger,s=i.auth,o=i.extensions,l=i.getUserAgentWithExtensions,u=i.sessionManager;this.wsHost=t;try{var c="/?p=JS&pv="+encodeURIComponent(R.OS_VERSION)+"&sv="+encodeURIComponent(R.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.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){Y.debug("`window` object does not exist.")}var d=!1;this.ws.onopen=function(e){Y.debug("`WebSocket.onopen` called."),r.handler.onOpen(e)},this.ws.onmessage=function(e){r.active();var n=e.data.split("\n");for(var t in n){var i=n[t];if(i&&"string"==typeof i){try{if("PONG"===i.substring(0,4)){a.pong();continue}}catch(e){Y.debug("`WebSocket.onmessage` command check error:",e)}r.handler.onMessage(i)}}},this.ws.onerror=function(e){Y.debug("`WebSocket.onerror` called:",e),a&&a.stop(),d=!0,r.sb.isReconnectingOnError=!0,r.handler.onError(e)},this.ws.onclose=function(e){Y.group("`WebSocket.onclose` called.",[{level:Y.supportedLogLevels.DEBUG,messages:["e",e]},{level:Y.supportedLogLevels.DEBUG,messages:["explicitDisconnect",r.explicitDisconnect]}]),a&&a.stop(),r.explicitDisconnect?r.handler.onClose(e):d||r.handler.onError(e),r.explicitDisconnect=!1}}},{key:"disconnect",value:function(e,n){Y.group("`WebSocketClient.onclose` called.",[{level:Y.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 L("Connection is not valid. Please reconnect.",L.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(){l(this,e),this.onReady=function(){},this.onOpen=function(){},this.onClose=function(){},this.onMessage=function(){},this.onError=function(){}}}();var te=function(){function e(n){l(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 c(e,[{key:"isConnected",get:function(){return this.client&&this.client.getConnectionState()===this.sb.ConnectionState.OPEN}},{key:"connect",value:function(e,n){var t=this,r=M.get(this.sb._iid).container,i=r.auth,a=r.apiClient,s=r.commandHandler;i.sessionToken=n||null;var o=this.cls.GroupChannel,l=null,u=new ne.ConnectionHandler;this.client=new ne(this.sb,u),u.onMessage=function(e){s.onRawCommandReceived(e)},this.sb.loginHandler=function(e,n){if(t.sb.connecting=!1,e)t.disconnect({clearSession:!0,err:e},null);else{clearInterval(t.sb.globalTimer);var r=function(){if(o.cachedChannels)for(var e in o.cachedChannels){var n=o.cachedChannels[e];if(n.invalidateTypingStatus())for(var r in t.sb.channelHandlers){t.sb.channelHandlers[r].onTypingStatusUpdated(n)}}};r(),t.sb.globalTimer=setInterval((function(){return r()}),1e3),t.flushConnectionCallbacks(null,n),t.sb.connecting=!1,t.sb.reconnecting=!1,t.sb.ConnectionManager.processAllReadyHandler(null)}},u.onOpen=function(){t.connectCount=0,t.sb.loginTimer=setTimeout((function(){t.sb.loginTimer=null,t.sb.onLoginTimerCancel=null,t.flushConnectionCallbacks(new L("Connection timeout.",L.LOGIN_TIMEOUT),null),t.sb.disconnect(null)}),t.sb.Options.websocketResponseTimeout),t.sb.onLoginTimerCancel=function(){t.connectCount=0,t.flushConnectionCallbacks(new L("Connection has been canceled.",L.REQUEST_FAILED),null)},t.sb.connecting=!1},u.onError=function(r){Y.debug("Connect: `WebSocketClient.ConnectionHandler.onError` called.",r),i.sessionKey?(t.sb.isReconnectingOnError=!0,t.sb.ConnectionManager.errorAllReadyHandler(),t.reconnect(e,!0),t.sb.connecting=!1):t.connectCount1&&void 0!==arguments[1])||arguments[1],r=M.get(this.sb._iid),i=r.container,a=i.auth,s=i.apiClient,o=i.commandHandler,l=i.sessionManager,u=this.cls.OpenChannel;if(this.sb.reconnecting=!0,this.sb.reconnectTimer)Y.debug("Reconnect: still reconnecting.");else{if(this.reconnectCount+=1,this.reconnectCount<=1){if(t)for(var c in this.sb.connectionHandlers){var d=this.sb.connectionHandlers[c];d.onReconnectStarted()}this.reconnectDelay=0}else 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);if(!e||!a.sessionKey||this.reconnectParams.retryCount>0&&this.reconnectCount>this.reconnectParams.retryCount){for(var h in this.disconnect({clearSession:!1,err:new L("Websocket connection failed.",L.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,this.sb.connectionHandlers){var p=this.sb.connectionHandlers[h];p.onReconnectFailed()}return 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,r){if(t)t.isSessionKeyExpiredError?l.refresh((function(){})):(clearTimeout(n.sb.reconnectTimer),n.sb.reconnectTimer=null,n.reconnect(e,!1));else{for(var i in n.reconnectCount=0,n.sb.connecting=!1,n.sb.reconnecting=!1,n.sb.isReconnectingOnError=!1,n.sb.connectionHandlers){n.sb.connectionHandlers[i].onReconnectSucceeded()}if(n.sb.ConnectionManager.processAllReadyHandler(null),n.sb.isReconnectingOnError)for(var a in n.sb.ConnectionManager.networkHandlers)n.sb.ConnectionManager.networkHandlers[a].onReconnected();Object.keys(u.enteredChannels).forEach((function(e){u.enteredChannels[e].enter((function(t,r){if(t){var i=n.cls.FileMessageQueue;delete u.enteredChannels[e],i.delete(e)}}))}))}},t.onOpen=function(){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),n.sb.loginTimer=setTimeout((function(){Y.debug("Reconnect: `loginTimer` timeout."),n.sb.loginTimer=null,n.reconnect(e,!0)}),n.sb.Options.websocketResponseTimeout),n.sb.onLoginTimerCancel=null,n.sb.reconnecting=!1},t.onMessage=function(e){o.onRawCommandReceived(e)},t.onError=function(t){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",t),n.sb.isReconnectingOnError=!0,n.sb.ConnectionManager.errorAllReadyHandler(),n.reconnect(e,!0)},t.onClose=function(){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),n.sb.reconnecting=!1},s.checkRouting((function(t,r){t?n.reconnect(e,!0):(n.sb.getCurrentApiHost()!==r.apiHost&&s.get("/",null,(function(){})),n.client.connect(e,null,r.wsHost))}))}),this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=M.get(this.sb._iid),r=t.container.ackStateMap,i=this.cls,a=i.GroupChannel,s=i.OpenChannel,o=e.clearSession,l=e.err;if(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){for(var u in s.clearEnteredChannels(),s.clearCache(),a.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),r)clearTimeout(r[u].timer);this.sb.currentUser=null,t.set("ackStateMap",{}),t.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),t.set("auth",new P)}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}(),re=function(){function e(n){var t=n.type,r=n.nullable,i=void 0!==r&&r,a=n.optional,s=void 0!==a&&a,o=n.optionalIf,u=void 0===o?null:o,c=n.ignoreIf,d=void 0===c?null:c,h=n.defaultValue,p=void 0===h?null:h,f=n.constraint,g=void 0===f?null:f;l(this,e),this.type=t,this.nullable=i,this.optional=s,this.optionalIf=u,this.ignoreIf=d,this.defaultValue=p,this.constraint=g}return c(e,[{key:"isMatchingType",value:function(e){var n=function(n,t){return"string"==typeof t?o(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"===o(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 r=!1,i=null;"callback"===t[t.length-1].type&&("function"==typeof n[n.length-1]&&(i=n.pop()),t.pop(),r=!0);var a=[],s=null,o=0;for(var l in t){var u=t[l];"function"==typeof u.ignoreIf&&u.ignoreIf(n)?a.push(u.hasOwnProperty("defaultValue")?u.defaultValue:null):u.isMatchingType(n[o])?(u.nullable&&null===n[o]||!u.constraint||u.constraint(n[o])||(s=e.error),a.push(n[o]),o++):u.optional||"function"==typeof u.optionalIf&&u.optionalIf(n)?a.push(u.hasOwnProperty("defaultValue")?u.defaultValue:null):(s=e.error,a.push(n[o]),o++)}return r&&i&&a.push(i),n.length!==o&&(s=e.error),[s].concat(a)}},{key:"error",get:function(){return new L("Invalid parameter.",L.INVALID_PARAMETER)}},{key:"toArray",value:function(e){for(var n=[],t=0;t1&&void 0!==arguments[1])||arguments[1],t=M.get(this.sb._iid),r=t.container,i=r.auth,a=r.isInBackground;n&&i.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 L("Connection should be made first.",L.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 L("Connection should be made first.",L.CONNECTION_REQUIRED),null)}),this.authenticateTimer);this.authInfoRequester((function(r){if(t){clearTimeout(t),t=null,n.authCount--;var i=function(t,r){n.sb.connecting=!1,e(t,null)};r&&r.hasOwnProperty("userId")?r.accessToken?r.apiHost&&r.wsHost?n.sb.connect(r.userId,r.accessToken,r.apiHost,r.wsHost,i):n.sb.connect(r.userId,r.accessToken,i):r.apiHost&&r.wsHost?n.sb.connect(r.userId,r.apiHost,r.wsHost,i):n.sb.connect(r.userId,i):e(re.error,null)}}))}else e(re.error,null)}}]),e}(),ae=function e(){l(this,e),this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,n){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},se=function(){function e(n){l(this,e),this.sb=n,this.handler=null,this.callbacks=[]}return c(e,[{key:"_refreshSessionKey",value:function(){var e=this;M.get(this._iid).container.wsAdapter.isConnected?this._refreshSessionKeyByCommand((function(n){n?n.isSessionTokenExpiredError?e._handleRefreshError(n):e._refreshSessionKeyByApi((function(n){n?e._handleRefreshError(n):e._handleRefreshSuccess()})):e._handleRefreshSuccess()})):this._refreshSessionKeyByApi((function(n){n?e._handleRefreshError(n):e._handleRefreshSuccess()}))}},{key:"_refreshSessionKeyByCommand",value:function(e){var n=this.sb,t=M.get(this._iid).container.auth,r=D.get(this._iid).Command,i=r.bSessionRefresh({token:t.sessionToken,requestId:r.generateRequestId()});n.sendCommand(i,(function(r,i){if(n.getErrorFirstCallback()){var a=[r,i];i=a[0],r=a[1]}r&&(r.hasOwnProperty("error")?i=new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED):r.hasOwnProperty("new_key")&&(t.sessionKey=r.new_key)),e(i)}))}},{key:"_refreshSessionKeyByApi",value:function(e){var n=this;!function t(r){if(r<3){var i=M.get(n._iid).container,a=i.auth,s=i.apiClient,o={};a.sessionToken&&(o.accessToken=a.sessionToken),s.refreshSessionKey(o,(function(n,i){if(n)n.isSessionTokenExpiredError?e(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED)):t(r+1);else{var s=i.key;a.sessionKey=s,e(null)}}))}else e(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED))}(0)}},{key:"_handleRefreshSuccess",value:function(){var e=this.sb;e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null),e.reconnect(),this._flushCallbacks(new L("Session key refreshed.",L.SESSION_TOKEN_REFRESHED)),this.handler&&this.handler.onSessionRefreshed()}},{key:"_handleRefreshError",value:function(e){this._flushCallbacks(e),this.handler&&this.handler.onSessionError(e)}},{key:"_handleClose",value:function(){var e=this;this.sb.disconnect((function(){e._flushCallbacks(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED)),e.handler&&e.handler.onSessionClosed()}))}},{key:"_flushCallbacks",value:function(e){this.callbacks.forEach((function(n){return n(e)})),this.callbacks=[]}},{key:"setHandler",value:function(e){e instanceof ae&&(this.handler=e)}},{key:"refresh",value:function(e){var n=this,t=this.sb,r=M.get(this._iid).container.auth;if(this.handler){if(this.callbacks.push(e),1===this.callbacks.length){this.handler.onSessionExpired(),r.sessionToken?this.handler.onSessionTokenRequired((function(e){e?(r.sessionToken=e,n._refreshSessionKey()):n._handleClose()}),(function(){t.reconnectTimer&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null);var e=new L("Failed to get the session token.",L.SESSION_TOKEN_REQUEST_FAILED);n._flushCallbacks(e),n.handler&&n.handler.onSessionError(e)})):this._refreshSessionKey()}}else e(null)}}]),e}(),oe=function(){function e(n){l(this,e),this.sb=n}return c(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){Y.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){Y.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){Y.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){Y.debug("There is no `window.addEventListener.ononline` or `navigator.onLine`")}}}]),e}(),le=(new Date).getTime(),ue=function(){function e(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;switch(l(this,e),this.command=n,this.requestId=r,arguments.length){case 1:if(!n||n.length<=4)this.command="NOOP",this.payload="{}";else if(this.decode(n),this.isRequestIdCommand){var i=this.getJsonElement();i&&(this.requestId=i.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 c(e,[{key:"isRequestIdCommand",get:function(){return this.isAckRequired||"EROR"===this.command}},{key:"isAckRequired",get:function(){return"MESG"===this.command||"FILE"===this.command||"ENTR"===this.command||"EXIT"===this.command||"READ"===this.command||"MEDI"===this.command||"FEDI"===this.command}},{key:"encode",value:function(){return this.command+this.payload+"\n"}},{key:"decode",value:function(e){e=e.trim(),this.command=e.substring(0,4),this.payload=e.substring(4)}},{key:"getJsonElement",value:function(){return JSON.parse(this.payload)}}],[{key:"bSessionRefresh",value:function(e){return new this("LOGI",{token:e.token},e.requestId)}},{key:"bPing",value:function(){return new this("PING",{id:(new Date).getTime(),active:1})}},{key:"bMessage",value:function(e){var n=e.channelUrl,t=e.message,r=e.data,i=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,g=e.rootMessageId,y=void 0===g?null:g,_=e.parentMessageId,m=void 0===_?null:_,v=D.get(this._iid),C=v.UserMessageParams,E=v.BaseMessageParams,U={};return U.channel_url=n,U.message=t,U.data=r,a&&a.length>0&&(U.metaarray=a.map((function(e){return e.encode()}))),s&&(U.mention_type=s),U.mentioned_user_ids=[],s===E.MentionType.CHANNEL?U.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(U.mentioned_user_ids=o),i&&(U.custom_type=i),l&&l.length>0&&(U.target_langs=l),u&&u!==C.PushNotificationDeliveryOption.DEFAULT&&(U.push_option=u),c&&(U.apple_critical_alert_options=c.serialize()),f&&(U.silent=f),y&&(U.root_message_id=y),m&&(U.parent_message_id=m),new this("MESG",U,h)}},{key:"bFile",value:function(e){var n=e.channelUrl,t=e.url,r=e.name,i=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,g=e.requestId,y=void 0===g?null:g,_=e.silent,m=void 0!==_&&_,v=e.rootMessageId,C=void 0===v?null:v,E=e.parentMessageId,U=void 0===E?null:E,b=D.get(this._iid),A=b.BaseMessageParams,S=b.FileMessageParams,I={};return I.channel_url=n,I.url=t,I.name=r||"",I.type=i||"",I.size=a||0,I.custom=s,o&&(I.custom_type=o),l&&(I.thumbnails=l),u&&(I.require_auth=u),c&&c.length>0&&(I.metaarray=c.map((function(e){return e.encode()}))),d&&(I.mention_type=d),I.mentioned_user_ids=[],d===A.MentionType.CHANNEL?I.mentioned_user_ids=[]:Array.isArray(h)&&h.length>0&&(I.mentioned_user_ids=h),p&&p!==S.PushNotificationDeliveryOption.DEFAULT&&(I.push_option=p),f&&(I.apple_critical_alert_options=f.serialize()),m&&(I.silent=m),C&&(I.root_message_id=C),U&&(I.parent_message_id=U),new this("FILE",I,y)}},{key:"bUpdateUserMessage",value:function(e){var n=e.channelUrl,t=e.messageId,r=e.appleCriticalAlertOptions,i=e.message,a=void 0===i?null:i,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,g=void 0===f?null:f,y=D.get(this._iid).BaseMessageParams,_={};return _.channel_url=n,_.msg_id=t,null!=a&&void 0!==a&&(_.message=a),null!=o&&void 0!==o&&(_.data=o),null!=u&&void 0!==u&&(_.custom_type=u),d&&(_.mention_type=d),d===y.MentionType.CHANNEL?_.mentioned_user_ids=[]:Array.isArray(p)&&p.length>0&&(_.mentioned_user_ids=p),g&&(_.metaarray=g),r&&(_.apple_critical_alert_options=r.serialize()),new this("MEDI",_)}},{key:"bUpdateFileMessage",value:function(e){var n=e.channelUrl,t=e.messageId,r=e.appleCriticalAlertOptions,i=e.data,a=void 0===i?null:i,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,g={};return g.channel_url=n,g.msg_id=t,null!=a&&void 0!==a&&(g.data=a),null!=o&&void 0!==o&&(g.custom_type=o),u&&(g.mention_type=u),u===f.MentionType.CHANNEL?g.mentioned_user_ids=[]:Array.isArray(d)&&d.length>0&&(g.mentioned_user_ids=d),p&&(g.metaarray=p),r&&(g.apple_critical_alert_options=r.serialize()),new this("FEDI",g)}},{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,r={};return r.channel_url=n,r.msg_id=t,new this("MACK",r)}},{key:"bTypeStart",value:function(e){var n=e.channelUrl,t=e.time,r={};return r.channel_url=n,r.time=t,new this("TPST",r)}},{key:"bTypeEnd",value:function(e){var n=e.channelUrl,t=e.time,r={};return r.channel_url=n,r.time=t,new this("TPEN",r)}},{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]:{};l(this,e);var t=[];if(n.hasOwnProperty("premium_feature_list")&&Array.isArray(n.premium_feature_list))try{var r=n.premium_feature_list;t.push.apply(t,S(r))}catch(e){}var i=[];if(n.hasOwnProperty("application_attributes")&&Array.isArray(n.application_attributes))try{var a=n.application_attributes;i.push.apply(i,S(a))}catch(e){}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,applicationAttributes:i,premiumFeatureList:t})}return c(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}}]),e}(),pe=function(){function e(){l(this,e),this.messageId=null,this.userId=null,this.key=null,this.operation="",this.updatedAt=null}return c(e,null,[{key:"createFromJson",value:function(e){var n=parseInt(e.msg_id),t=e.user_id,r=e.operation,i=e.reaction,a=e.updated_at;if(n&&"string"==typeof t&&"string"==typeof r&&["add","delete"].indexOf(r.toLowerCase())>=0&&"string"==typeof i&&i&&"number"==typeof a){var s=new this;return s.messageId=n,s.userId=t,s.key=i,s.operation=r.toLowerCase(),s.updatedAt=a,s}return null}}]),e}();function fe(e){return Object.keys(e).forEach((function(n){e[n]&&"object"===o(e[n])&&fe(e[n])})),Object.freeze(e)}var ge=function(){function e(){l(this,e)}return c(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}(),ye=function(e,n,t){return new Promise((function(r,i){n((function(n,a){t&&"function"==typeof t&&(M.get(e).container.isErrorFirstInCallback?t(n,a):t(a,n));n?i(n):r(a)}))}))},_e={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},me=new WeakMap,ve=function(){function e(n){l(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.ogMetaData=null,this.isOperatorMessage=!1,this.appleCriticalAlertOptions=null,n&&this.__update(n)}return c(e,[{key:"serialize",value:function(){return ge.serialize(this,(function(e){e.hasOwnProperty("_sender")&&(e.sender=e._sender,delete e._sender)}))}},{key:"isIdentical",value:function(e){return!("object"!==o(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=$n.getInstance(this._iid),r=D.get(this._iid),i=r.User,a=r.BaseChannel,s=r.BaseMessageParams,o=r.Reaction,l=r.MessageMetaArray,u=r.ThreadInfo,c=r.OGMetaData,d=r.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 h=e.hasOwnProperty("metaarray")?e.metaarray:{},p=e.hasOwnProperty("metaarray_key_order")?e.metaarray_key_order:Object.keys(h).sort((function(e,n){return e.localeCompare(n)}));this.metaArrays=[];for(var f=0;f0?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)),e.hasOwnProperty("parent_message_text")&&(this.parentMessageText=e.parent_message_text),this.threadInfo=new u(e.thread_info),e.hasOwnProperty("og_tag")&&(this.ogMetaData=new c(e.og_tag)),this.isOperatorMessage=!!e.hasOwnProperty("is_op_msg")&&e.is_op_msg,e.hasOwnProperty("apple_critical_alert_options")&&(this.appleCriticalAlertOptions=new d(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"===o(e)&&e){var n=D.get(this._iid).MessageMetaArray,t=[];for(var r in e)t.push(new n(r,e[r]));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),r=t.Reaction,i=null,a=re.parse(arguments,[new re({type:pe,constraint:function(e){return parseInt(e.messageId)===parseInt(n.messageId)}})]),s=A(a,2);if(i=s[0],e=s[1],!i){var o=!1;for(var l in this.reactions)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 r(e.key,[e.userId],e.updatedAt))}}},{key:"_getThreadedMessageList",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.ThreadedMessageListParams,o=null,l=re.parse(arguments,[new re({type:"number"}),new re({type:"string",constraint:function(e){return Object.values(_e).includes(e)}}),new re({type:s,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=D.get(i._iid),s=a.GroupChannel,l=a.OpenChannel;i.isGroupChannel()?s.getChannel(i.channelUrl,R.INTERNAL_CALL,(function(a,s){if($n.getInstance(i._iid).getErrorFirstCallback()){var o=[a,s];s=o[0],a=o[1]}s?r(s,null):M.get(i._iid).container.apiClient.getMessageList(p(p({channel:a,token:e,tokenType:n},t),{},{shouldReverse:t.reverse,rootMessageId:i.messageId,includeReplies:!0,includeThreadInfo:!0}),(function(e,n){if(e)r(e,null);else{var t=D.get(i._iid).BaseChannel,a=n.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e})),s=a.filter((function(e){return e.messageId===i.messageId}))[0],o=a.filter((function(e){return e.parentMessageId===i.messageId}));r(null,{parentMessage:s,threadedReplies:o})}}))})):i.isOpenChannel()&&l.getChannel(i.channelUrl,R.INTERNAL_CALL,(function(a,s){if($n.getInstance(i._iid).getErrorFirstCallback()){var o=[a,s];s=o[0],a=o[1]}s?r(s,null):M.get(i._iid).container.apiClient.getMessageList(p(p({channel:a,token:e,tokenType:n},t),{},{shouldReverse:t.reverse,rootMessageId:i.messageId,includeReplies:!0,includeThreadInfo:!0}),(function(e,n){if(e)r(e,null);else{var t=D.get(i._iid).BaseChannel,a=n.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e})),s=a.filter((function(e){return e.messageId===i.messageId}))[0],o=a.filter((function(e){return e.parentMessageId===i.messageId}));r(null,{parentMessage:s,threadedReplies:o})}}))}))}}),r)}},{key:"getThreadedMessagesByTimestamp",value:function(e,n,t){return this._getThreadedMessageList(e,_e.TIMESTAMP,n,t)}},{key:"applyThreadInfoUpdateEvent",value:function(e){var n=D.get(this._iid),t=n.ThreadInfo,r=n.ThreadInfoUpdateEvent,i=me.get(this),a=null,s=re.parse(arguments,[new re({type:r,constraint:function(e){return parseInt(e.targetMessageId)===parseInt(i)}})]),o=A(s,2);if(a=o[0],e=o[1],!a){var l=e,u=l.threadInfo;return this.threadInfo=new t(u),!0}return!1}}],[{key:"MESSAGE_TYPE_BASE",get:function(){return"base"}},{key:"MESSAGE_TYPE_ADMIN",get:function(){return"admin"}},{key:"MESSAGE_TYPE_USER",get:function(){return"user"}},{key:"MESSAGE_TYPE_FILE",get:function(){return"file"}},{key:"SendingStatus",get:function(){return{NONE:"none",PENDING:"pending",FAILED:"failed",CANCELED:"canceled",SUCCEEDED:"succeeded"}}},{key:"getMessage",value:function(e,n){var t=this,r=D.get(this._iid),i=r.BaseChannel,a=r.MessageRetrievalParams,s=null,o=re.parse(arguments,[new re({type:a,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),l=A(o,3);return s=l[0],e=l[1],n=l[2],ye(this._iid,(function(n){if(s)n(s,null);else{var r=D.get(t._iid),a=r.GroupChannel,o=r.OpenChannel;switch(e.channelType){case i.CHANNEL_TYPE_GROUP:a.getChannel(e.channelUrl,R.INTERNAL_CALL,(function(r,a){if($n.getInstance(t._iid).getErrorFirstCallback()){var s=[r,a];a=s[0],r=s[1]}a?n(a,null):M.get(t._iid).container.apiClient.getMessage(p({channel:r},e),(function(e,t){if(e)n(e,null);else{var a=i.buildMessage(t,r);n(null,a)}}))}));break;case i.CHANNEL_TYPE_OPEN:o.getChannel(e.channelUrl,R.INTERNAL_CALL,(function(r,a){if($n.getInstance(t._iid).getErrorFirstCallback()){var s=[r,a];a=s[0],r=s[1]}a?n(a,null):M.get(t._iid).container.apiClient.getMessage(p({channel:r},e),(function(e,t){if(e)n(e,null);else{var a=i.buildMessage(t,r);n(null,a)}}))}))}}}),n)}}]),e}(),Ce=function(){function e(n){l(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 c(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=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=D.get(this._iid),r=t.GroupChannel;for(var i in e)n?delete this.metaData[i]:this.metaData[i]=e[i];for(var a in r.cachedChannels)if(r.cachedChannels.hasOwnProperty(a)){var s=r.cachedChannels[a];if(s.memberMap.hasOwnProperty(this.userId)){var o=s.memberMap[this.userId];o.metaData=this.metaData}}}},{key:"serialize",value:function(){return ge.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("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,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.createUserMetaData({metaData:e},(function(e,r){e||t._updateMetaData(r),n(e,r)}))}),n)}},{key:"updateMetaData",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({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 re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateUserMetaData({metaData:e,upsert:n},(function(e,n){e||r._updateMetaData(n),t(e,n)}))}),t)}},{key:"deleteMetaData",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i={};i[e]="",M.get(t._iid).container.apiClient.deleteUserMetaData({metaDataKey:e},(function(e,r){e||t._updateMetaData(i,!0),n(e,r)}))}}),n)}},{key:"deleteAllMetaData",value:function(e){var n=this;return ye(this._iid,(function(e){var t=n.metaData;M.get(n._iid).container.apiClient.deleteAllUserMetaData({},(function(r,i){r||n._updateMetaData(t,!0),e(r,i)}))}),e)}}],[{key:"objectify",value:function(e){var n=e.userId,t=void 0===n?null:n,r=e.nickname,i=void 0===r?"":r,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,g=e.friendDiscoveryKey,y=void 0===g?null:g,_=e.friendName,m=void 0===_?null:_,v=e.preferredLanguages,C=void 0===v?null:v,E=e.requireAuth;return{user_id:t,nickname:i,profile_url:s,is_online:l,last_seen_at:c,metadata:h,is_active:f,friend_discovery_key:y,friend_name:m,preferred_languages:C,require_auth_for_profile_image:void 0!==E&&E}}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c){return this.objectify({userId:e,nickname:n,plainProfileUrl:t,connectionStatus:r,lastSeenAt:i,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=ge.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}(),Ee={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Ue=new WeakMap,be=function(){function e(n){l(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,Ue.set(this,{}),n&&this.__update(n)}return c(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"===o(e.created_by)&&Object.keys(e.created_by).length>0?this.creator=new Ce(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=Ue.get(this);Object.keys(e).forEach((function(r){var i=t[r],a=e[r];i?n>i.updatedAt&&(i.value=a,i.updatedAt=n,i.isRemoved=!1):t[r]={value:a,updatedAt:n,isRemoved:!1}}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,n){var t=Ue.get(this);e.forEach((function(e){var r=t[e];r?n>r.updatedAt&&(r.isRemoved=!0,r.updatedAt=n):t[e]={value:null,updatedAt:n,isRemoved:!0}}))}},{key:"_refreshMetaData",value:function(e,n){var t={};Object.keys(e).forEach((function(r){t[r]={value:e[r],updatedAt:n,isRemoved:!1}})),Ue.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:"serialize",value:function(){return ge.serialize(this,(function(e){if(null!==e.lastMessage&&"object"===o(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,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:e,token:null,isOpenChannel:i.isOpenChannel(),includeMetaArray:n,includeReactions:t},(function(e,n){var t=null;if(!e){var a=D.get(i._iid).BaseChannel;t={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}}r(e,t)}))}),r)}},{key:"getMessageChangeLogsByToken",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:null,token:e,isOpenChannel:i.isOpenChannel(),includeMetaArray:n,includeReactions:t},(function(e,n){var t=null;if(!e){var a=D.get(i._iid).BaseChannel;t={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}}r(e,t)}))}),r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.BaseChannel,s=i.MessageChangeLogsParams,o=null,l=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:s}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(this._iid,(function(t){o?t(o,null):M.get(r._iid).container.apiClient.getMessageChangeLogs(p({channelUrl:r.url,ts:null,token:e,isOpenChannel:r.isOpenChannel()},n),(function(e,n){var i=null;e||(i={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}),t(e,i)}))}),t)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.BaseChannel,s=i.MessageChangeLogsParams,o=null,l=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:s}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(this._iid,(function(t){o?t(o,null):M.get(r._iid).container.apiClient.getMessageChangeLogs(p({channelUrl:r.url,timestamp:e,token:null,isOpenChannel:r.isOpenChannel()},n),(function(e,n){var i=null;e||(i={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}),t(e,i)}))}),t)}},{key:"getMyMutedInfo",value:function(e){var n=this;return ye(this._iid,(function(e){var t=$n.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 r=null;n||(r={isMuted:t.is_muted,startAt:t.start_at,endAt:t.end_at,remainingDuration:t.remaining_duration,description:t.description}),e(n,r)}))}),e)}},{key:"_parseMessageListParams",value:function(e){for(var n=D.get(this._iid),t=n.MessageListParams,r=new t,i=null,a=!1,s=0,o=0,l=!1,u="",c="",d=null,h=!1,p=!1,f=null,g=arguments.length,y=new Array(g>1?g-1:0),_=1;_=0}}),new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"array"})]),8);i.error=a[0],i.file=a[1],i.name=a[2],i.type=a[3],i.size=a[4],i.data=a[5],i.customType=a[6],i.thumbnailSizes=a[7]}else i.error=re.error;return X.isFile(i.file)&&(i.name=i.name||i.file.name,i.type=i.type||i.file.type,i.size=i.size||i.file.size),i}},{key:"_createTempFileMessage",value:function(e){try{var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.Command,i=t.FileMessage,a=i.objectify(p(p({},e),{},{messageId:0,reqId:r.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 i(a)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this._parseFileMessageArguments(re.toArray(arguments)),n=D.get(this._iid),t=n.Command,r=null,i=t.generateRequestId();e.error||((r=this._createTempFileMessage(e)).requestedMentionUserIds=e.mentionedUserIds,i=r.reqId);var a=$n.getInstance(this._iid);a&&a.currentUser||(e.error=new L("Connection should be made first.",L.CONNECTION_REQUIRED));var s=D.get(this._iid),o=s.FileMessageQueue,l=o.create(this);return l.addJob(new o.Job({fileInfo:e,pendingMessage:r,requestId:i,error:e.error,response:null})),r}},{key:"sendFileMessages",value:function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.progress?t.progress:function(){},i=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,r,(function(n,t){i(n,t),o===e.length-1&&a(null)})))})),s}return a(re.error),null}},{key:"resendFileMessage",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.FileMessage,s=i.FileMessageParams,o=null,l=re.parse(arguments,[new re({type:a,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===r.url&&"string"==typeof e.data&&"string"==typeof e.customType&&Array.isArray(e.thumbnails)}}),new re({type:"file",optionalIf:function(e){return!!e[0].url},defaultValue:null}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(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 i=new s;e.url?i.fileUrl=e.url:i.file=n,i.fileName=e.name,i.fileSize=e.size,i.mimeType=e.type,i.data=e.data,i.customType=e.customType,i.mentionType=e.mentionType,i.mentionedUserIds=e.requestedMentionUserIds,i.metaArrays=e.metaArrays,i.thumbnailSizes=e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),i.appleCriticalAlertOptions=e.appleCriticalAlertOptions,r.sendFileMessage(i,t)}}),t)}},{key:"updateFileMessage",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.Command,o=a.FileMessage,l=a.FileMessageParams,u=arguments,c=null,d=null;if("number"==typeof e)switch(u.length){case 3:var h=re.parse(u,[new re({type:"number"}),new re({type:l}),new re({type:"callback"})]),f=A(h,4);c=f[0],e=f[1],d=f[2],r=f[3],d&&(d._isUpdate=!0);break;case 4:d=new l;var g=re.parse(u,[new re({type:"number"}),new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"callback"})]),y=A(g,5);c=y[0],e=y[1],n=y[2],t=y[3],r=y[4],d.data=n,d.customType=t,d._isUpdate=!0}return ye(this._iid,(function(n){if(!c&&d&&d._validate()){var t=s.bUpdateFileMessage(p(p({channelUrl:i.url,messageId:e},d),{},{mentionType:d._mentionType,mentionedUserIds:d._mentionedUserIds})),r=$n.getInstance(i._iid);r.sendCommand(t,(function(e,t){if(r.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}var a=null;t||(a=new o(e.getJsonElement())),n(t,a)}))}else n(re.error,null)}),r)}},{key:"cancelUploadingFileMessage",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:["number","string"]}),new re({type:"callback"})]),i=A(r,3);t=i[0],e=i[1],n=i[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 r=this,i=$n.getInstance(this._iid),a=D.get(this._iid),s=a.ReactionEvent,o=null,l=re.parse(arguments,[new re({type:ve}),new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(this._iid,(function(t){o?t(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?M.get(r._iid).container.apiClient.addReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:n},(function(n,r){var i=null;n||(i=s.createFromJson(p(p({},r),{},{msg_id:e.messageId}))),t(n,i)})):t(new L("Cannot add reaction to a non-succeeded message.",L.REQUEST_FAILED),null)}),t)}},{key:"deleteReaction",value:function(e,n,t){var r=this,i=$n.getInstance(this._iid),a=D.get(this._iid),s=a.ReactionEvent,o=null,l=re.parse(arguments,[new re({type:ve}),new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(this._iid,(function(t){o?t(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?M.get(r._iid).container.apiClient.deleteReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:n},(function(n,r){var i=null;n||(i=s.createFromJson(p(p({},r),{},{msg_id:e.messageId}))),t(n,i)})):t(new L("Cannot remove reaction to a non-succeeded message.",L.REQUEST_FAILED),null)}),t)}},{key:"deleteMessage",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r){var i=D.get(this._iid);i.Command;var a=i.UserMessage,s=i.BaseMessageParams,o=null,l=re.parse(arguments,[new re({type:e}),new re({type:a}),new re({type:"callback"})]),u=A(l,4);o=u[0],n=u[1],t=u[2],r=u[3];var c=M.get(this._iid),d=c.container.isErrorFirstInCallback;if(o)return d?r(re.error,null):r(null,re.error),null;if(this.url!==t.channelUrl){var h=new L("The message does not belong to this channel",L.INVALID_PARAMETER);return d?r(h,null):r(null,h),null}var f=Object.keys(t.translations);f.forEach((function(e){return""}));var g=s.PushNotificationDeliveryOption.DEFAULT;return n._sendUserMessage(p(p({},t),{},{reqId:null,pushNotificationDeliveryOption:g,translationTargetLanguages:f,rootMessageId:null,parentMessageId:null,parentMessageText:null,callback:r}))}},{key:"copyFileMessage",value:function(n,t,r){var i=D.get(this._iid),a=i.Command;i.GroupChannel;var s=i.FileMessage,o=i.BaseMessageParams;i.FileMessageParams;var l=i.User,u=null,c=re.parse(arguments,[new re({type:e}),new re({type:s}),new re({type:"callback"})]),d=A(c,4);u=d[0],n=d[1],t=d[2],r=d[3];var h=M.get(this._iid),p=h.container.isErrorFirstInCallback;if(u)return p?r(re.error,null):r(null,re.error),null;if(this.url!==t.channelUrl){var f=new L("The message does not belong to this channel");return p?r(f,null):r(null,f),null}var g=$n.getInstance(this._iid),y=t,_=y.url,m=y.name,v=y.type,C=y.size,E=y.data,U=y.customType,b=y.mentionType,S=y.mentionedUserIds,I=y.mentionedUsers,N=y.metaArrays,k=y.thumbnails,R=y.requireAuth,O=y.messageSurvivalSeconds,T=y.silent,P=y.appleCriticalAlertOptions,w=a.generateRequestId(),H=g.currentUser||{},F=n.url,G=n.isOpenChannel(),B=I.filter((function(e){return new l(l.objectify(e))})),j=o.PushNotificationDeliveryOption.DEFAULT,x=s.objectify({messageId:0,reqId:w,user:H,channel:n,plainUrl:_,name:m,type:v,size:C,data:E,customType:U,mentionType:b,mentionedUserIds:S,mentionedUsers:B,requestedMentionUserIds:S,metaArrays:N,thumbnails:k,requireAuth:R,messageSurvivalSeconds:O,silent:T,createdAt:(new Date).getTime(),appleCriticalAlertOptions:P}),q=new s(x);if(q.requestState=g.MessageRequestState.PENDING,q.sendingStatus=g.MessageSendingStatus.PENDING,!g.currentUser){var z=new L("Connection should be made first.",L.CONNECTION_REQUIRED),Q=new s(x);return Q.requestState=g.MessageRequestState.FAILED,Q.sendingStatus=g.MessageSendingStatus.FAILED,Q.errorCode=z.code,p?r(z,Q):r(Q,z),q}var Y=a.bFile({requestId:w,channelUrl:F,url:_,name:m,type:v,size:C,data:E,customType:U,metaArrays:N,mentionType:b,mentionedUserIds:S,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:j,silent:T,appleCriticalAlertOptions:P});return g.getConnectionState()===g.ConnectionState.OPEN||g.connecting||g.reconnecting?g.sendCommand(Y,(function(e,t){if(g.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}if(t)if(t.code!==L.INVALID_PARAMETER){var a=new s(x);a.requestState=g.MessageRequestState.FAILED,a.sendingStatus=g.MessageSendingStatus.FAILED,t.code!==L.FILE_UPLOAD_CANCEL_FAILED&&t.code!==SendBridException.REQUEST_CANCELED||(a.sendingStatus=g.MessageSendingStatus.CANCELED),a.errorCode=t.code,p?r(t,a):r(a,t)}else p?r(t,null):r(null,t);else{var o=new s(e.getJsonElement()),l=o._sender;if(H&&l&&H.userId===l.userId&&(H.nickname!==l.nickname&&(H.nickname=l.nickname),H.plainProfileUrl!==l.plainProfileUrl&&(H.plainProfileUrl=l.plainProfileUrl)),n.isGroupChannel())for(var u in n.lastMessage=o,g.channelHandlers){g.channelHandlers[u].onChannelChanged(n)}p?r(null,o):r(o,null)}})):h.container.apiClient.sendFileMessage({channelUrl:F,isOpenChannel:G,fileUrl:_,fileName:m,fileType:v,fileSize:C,data:E,customType:U,metaArrays:N,mentionType:b,mentionedUserIds:S,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:j,appleCriticalAlertOptions:P},(function(e,t){if(e)if(e.code!==L.INVALID_PARAMETER){var i=new s(commnad.getJsonElement());i.requestState=g.MessageRequestState.FAILED,i.sendingStatus=g.MessageSendingStatus.FAILED,e.code!==L.FILE_UPLOAD_CANCEL_FAILED&&e.code!==SendBridException.REQUEST_CANCELED||(i.sendingStatus=g.MessageSendingStatus.CANCELED),i.errorCode=e.code,p?r(e,i):r(i,e)}else p?r(e,null):r(null,e);else{var a=new s(t),o=a._sender;if(H&&o&&H.userId===o.userId&&(H.nickname!==o.nickname&&(H.nickname=o.nickname),H.plainProfileUrl!==o.plainProfileUrl&&(H.plainProfileUrl=o.plainProfileUrl)),n.isGroupChannel())for(var l in n.lastMessage=a,g.channelHandlers){g.channelHandlers[l].onChannelChanged(n)}p?r(null,a):r(a,null)}})),q}},{key:"addOperators",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({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 re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateMetaCounters({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaCounter:e,upsert:n,mode:"set"},(function(e,n){return t(e,n)}))}),t)}},{key:"increaseMetaCounters",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.updateMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),metaCounter:e,upsert:!1,mode:"decrease"},(function(e,t){var r=null;if(!e)for(var i in r={},t)r[i]=t[i];n(e,r)}))}),n)}},{key:"deleteMetaCounter",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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=Ue.get(this),n={};return Object.keys(e).forEach((function(t){var r=e[t];r.isRemoved||(n[t]=r.value)})),n}},{key:"getMetaData",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateMetaData({channelUrl:r.url,isOpenChannel:r.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,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r){var i=this;return ye(this._iid,(function(r){var a=D.get(i._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=$n.getInstance(i._iid);d.sendCommand(c,(function(e,t){if(d.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[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()))),r(t,a)}))}else r(re.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,n,t){var r=D.get(this._iid),i=r.MessageMetaArray,a=null,s=re.parse(arguments,[new re({type:ve}),new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(this._iid,(function(e){e(a,null)}),t);var l=[];if(Array.isArray(n))for(var u=0;u0&&e.every((function(e){return e instanceof i}))||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 re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(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 r=D.get(this._iid),i=r.MessageMetaArray,a=null,s=re.parse(arguments,[new re({type:ve}),new re({type:"object",constraint:function(e){return e&&(Array.isArray(e)&&e.length>0&&e.every((function(e){return e instanceof i}))||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 re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(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 r=this,i=D.get(this._iid),a=i.BaseChannel,s=null,o=re.parse(arguments,[new re({type:a.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),l=A(o,4);return s=l[0],e=l[1],n=l[2],t=l[3],ye(this._iid,(function(t){if(s)t(s,null);else{var i=$n.getInstance(r._iid);M.get(r._iid).container.apiClient.report({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),reportCategory:e,reportingUserId:i.currentUser?i.currentUser.userId:null,reportDescription:n},(function(e,n){t(e,null)}))}}),t)}},{key:"reportUser",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:Ce}),new re({type:s.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=$n.getInstance(i._iid);M.get(i._iid).container.apiClient.reportUser({channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:n,offendingUserId:e.userId,reportingUserId:a.currentUser?a.currentUser.userId:null,reportDescription:t},(function(e,n){r(e,null)}))}}),r)}},{key:"reportMessage",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:ve}),new re({type:s.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=$n.getInstance(i._iid);M.get(i._iid).container.apiClient.reportMessage({messageId:e.messageId,channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:n,offendingUserId:e.sender.userId,reportingUserId:a.currentUser?a.currentUser.userId:null,reportDescription:t},(function(e,n){r(e,null)}))}}),r)}}],[{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),r=t.UserMessage,i=t.FileMessage,a=t.AdminMessage;if(e)switch(e.hasOwnProperty("channel_type")||(e.channel_type=n.channelType),e.type){case"MESG":return new r(e);case"FILE":var s=e.file;return new i(p(p({},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){l(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):be.CHANNEL_TYPE_GROUP)}return c(e,[{key:"isGroupChannel",value:function(){return this.channelType===be.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===be.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 Se=function e(n){l(this,e),n&&(this.category=n.hasOwnProperty("cat")?parseInt(n.cat):0)};Se.CATEGORY_USER_BLOCK=20001,Se.CATEGORY_USER_UNBLOCK=2e4,Se.CATEGORY_FRIEND_DISCOVERED=20900;var Ie=function(){function e(n){l(this,e),this.sb=n,this.cls=D.get(this.sb._iid)}return c(e,[{key:"onRawCommandReceived",value:function(e){var n=this,t=this.cls,r=t.Command,i=t.User,a=t.Member,s=t.BaseChannel,l=t.GroupChannel,u=t.OpenChannel,c=t.UserMessage,d=t.FileMessage,h=t.AdminMessage,p=t.BaseMessageParams,f=t.ReactionEvent,g=t.ReadStatus,y=t.ThreadInfoUpdateEvent,_=M.get(this.sb._iid),m=_.container,v=m.pinger,C=m.auth,E=m.subscribedUnreadMessageCount,U=m.sessionManager,b=m.ackStateMap,A=new r(e),S=A.getJsonElement();if(S.hasOwnProperty("unread_cnt")&&"object"===o(S.unread_cnt)){var I=!1,N=S.unread_cnt.ts;if("number"==typeof N&&N>E.ts){if(E.all!==S.unread_cnt.all&&(I=!0),E.all=S.unread_cnt.all>=0?S.unread_cnt.all:0,S.unread_cnt.custom_types)for(var O in S.unread_cnt.custom_types)E.custom_types[O]!==S.unread_cnt.custom_types[O]&&(I=!0),E.custom_types[O]=S.unread_cnt.custom_types[O];I=I&&E.ts>0,E.ts=N}if(I)for(var T in this.sb.userEventHandlers)this.sb.userEventHandlers[T].onTotalUnreadMessageCountUpdated(E.all,E.custom_types)}var P=A.requestId;if(P){var w=b[P];if(w){clearTimeout(w.timer);var D=w.handler;D&&("EROR"===A.command?D(new L(S.message,S.code),null):D(null,A)),b.hasOwnProperty(P)&&delete b[P]}}else switch(v&&"LOGI"!==A.command&&v.refreshTimer(),A.command){case"LOGI":this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,S.hasOwnProperty("error")?(this.sb.isSessionOpened=!1,this.sb.loginHandler(new L(S.message,S.code),null)):(this.sb.isSessionOpened=!0,S.hasOwnProperty("key")&&(C.sessionKey=S.key),S.hasOwnProperty("ekey")&&(C.eKey=S.ekey),S.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(S)),"number"==typeof S.ping_interval&&S.ping_interval>0&&_.set("pingInterval",1e3*S.ping_interval),"number"==typeof S.pong_timeout&&S.pong_timeout>0&&_.set("pongTimeout",1e3*S.pong_timeout),"number"==typeof S.login_ts&&_.set("connectedAt",1e3*S.login_ts),"number"==typeof S.max_unread_cnt_on_super_group?_.set("maxUnreadCountOfSuperGroupChannel",S.max_unread_cnt_on_super_group):_.set("maxUnreadCountOfSuperGroupChannel",R.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),S.profile_image_encryption&&_.set("profileImageEncryption",!0),v&&v.start(),S.hasOwnProperty("file_upload_size_limit")&&S.hasOwnProperty("premium_feature_list")&&S.hasOwnProperty("emoji_hash")&&_.set("appInfo",new he(S)),this.sb.loginHandler(null,this.sb.currentUser)),this.sb.connecting=!1,this.sb.reconnecting=!1);break;case"EXPR":S.hasOwnProperty("expires_in")&&"number"==typeof S.expires_in&&S.expires_in>0&&U.refresh((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var H=null;if("MESG"===A.command?H=new c(S):"FILE"===A.command?H=new d(S):"BRDM"!==A.command&&"ADMM"!==A.command||(H=new h(S)),H){var F=this.sb.currentUser?this.sb.currentUser.userId:null,G=H.silent,B=!!S.force_update_last_message,j=H._sender&&H._sender.userId===F;if(H.isGroupChannel()){var x=r.bMessageAck({channelUrl:H.channelUrl,messageId:H.messageId});this.sb.sendCommand(x);var q=l.cachedChannels.hasOwnProperty(H.channelUrl);l.getChannel(H.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t){if(e.isHidden=!1,e.hiddenState=l.HiddenState.UNHIDDEN,l.cachedChannels[e.url]=e,H._sender&&e.memberMap.hasOwnProperty(H._sender.userId)){var i=e.memberMap[H._sender.userId];i.nickname!==H._sender.nickname&&(i.nickname=H._sender.nickname),i.plainProfileUrl!==H._sender.plainProfileUrl&&(i.plainProfileUrl=H._sender.plainProfileUrl),X.deepEqual(i.metaData,H._sender.metaData)||(i.metaData=H._sender.metaData),i.isBlockedByMe!==H._sender.isBlockedByMe&&(i.isBlockedByMe=H._sender.isBlockedByMe)}var a=n.sb.currentUser;a&&j&&(a.nickname!==H._sender.nickname&&(a.nickname=H._sender.nickname),a.plainProfileUrl!==H._sender.plainProfileUrl&&(a.plainProfileUrl=H._sender.plainProfileUrl),X.deepEqual(a.metaData,H._sender.metaData)||(a.metaData=H._sender.metaData));var s=!1;if(H.mentionType===p.MentionType.CHANNEL)j||(s=!0);else if(H.mentionType===p.MentionType.USERS)for(var o=0;o=z.createAt,s=n.sb.currentUser;s&&W&&(s.nickname!==z._sender.nickname&&(s.nickname=z._sender.nickname),s.plainProfileUrl!==z._sender.plainProfileUrl&&(s.plainProfileUrl=z._sender.plainProfileUrl),X.deepEqual(s.metaData,z._sender.metaData)||(s.metaData=z._sender.metaData));var o=!1,l=!1;if(!W&&!a&&S&&S.hasOwnProperty("old_values")){var u=S.old_values.mention_type||z.mentionType,c=S.old_values.mentioned_user_ids||z.mentionedUsers.map((function(e){return e.userId}));if(u===p.MentionType.USERS&&z.mentionType===p.MentionType.USERS){for(var d=!1,h=!1,f=0;f0||e.unreadMentionCount>0)for(var i in e._setGroupChannelUnreadCount(0,0),n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelChanged(e)}}else if(0===e.unreadMessageCount||0===e.unreadMentionCount)for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelChanged(e)}}else for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onReadReceiptUpdated(e)}}));break;case"MRCT":var te=String(S.channel_type),re=String(S.channel_url),ie=f.createFromJson(S);switch(te){case s.CHANNEL_TYPE_GROUP:l.getChannel(re,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"));else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onReactionUpdated(e,ie)}}));break;case s.CHANNEL_TYPE_OPEN:u.getChannel(re,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"));else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onReactionUpdated(e,ie)}}))}break;case"DLVR":var ae=String(S.channel_url),se=S.hasOwnProperty("updated")?S.updated:null,oe=l.cachedChannels.hasOwnProperty(ae);l.getChannel(ae,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t){var i=!1;for(var a in se)n.sb.currentUser&&a===n.sb.currentUser.userId&&(i=!0),oe&&e.updateDeliveryReceipt(a,parseInt(se[a]));if(l.cachedChannels[e.url]=e,!i||1!==Object.keys(se).length)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onDeliveryReceiptUpdated(e)}}}));break;case"MTHD":var le=String(S.channel_url),ue=String(S.channel_type),ce=y.createFromJson(S);switch(ue){case s.CHANNEL_TYPE_GROUP:l.getChannel(le,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onThreadInfoUpdated(e,ce)}}));break;case s.CHANNEL_TYPE_OPEN:u.getChannel(le,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onThreadInfoUpdated(e,ce)}}))}break;case"MCNT":if(S.hasOwnProperty("group_channels")&&Array.isArray(S.group_channels)){var de,pe=[],fe=k(S.group_channels);try{for(fe.s();!(de=fe.n()).done;){var ge=de.value;if(ge){ge.hasOwnProperty("joined_member_count")&&ge.joined_member_count,ge.hasOwnProperty("member_count")&&ge.member_count;var ye=l.cachedChannels[ge.channel_url];if(ye&&ye.isBroadcast)ye.setLatestMemberCount(ge.member_count,ge.joined_member_count,ge.ts)&&pe.push(ye)}}}catch(e){fe.e(e)}finally{fe.f()}if(pe.length>0)for(var _e in this.sb.channelHandlers){this.sb.channelHandlers[_e].onChannelMemberCountChanged(pe)}}if(S.hasOwnProperty("open_channels")&&Array.isArray(S.open_channels)){var me,ve=[],Ce=k(S.open_channels);try{for(Ce.s();!(me=Ce.n()).done;){var Ee=me.value;if(Ee){Ee.hasOwnProperty("participant_count")&&Ee.participant_count;var Ue=u.cachedChannels[Ee.channel_url];if(Ue)Ue.setLatestParticipantCount(Ee.participant_count,Ee.ts)&&ve.push(Ue)}}}catch(e){Ce.e(e)}finally{Ce.f()}if(ve.length>0)for(var be in this.sb.channelHandlers){this.sb.channelHandlers[be].onChannelParticipantCountChanged(ve)}}break;case"SYEV":var Ie=new Ae(S),Ne=S.ts;switch(Ie.category){case Ae.CATEGORY_CHANNEL_JOIN:case Ae.CATEGORY_CHANNEL_LEAVE:l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var s=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,o=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null,u=!1;if(Ie.category===Ae.CATEGORY_CHANNEL_JOIN){(Ie.data.hasOwnProperty("users")?Ie.data.users:[Ie.data]).forEach((function(t){e.isSuper||e.isBroadcast?u=e.setLatestMemberCount(s,o,S.ts):(t.state=a.JOINED,e.addMember(new a(t),Ne),e.updateJoinedMemberCount());var r=new i(t);for(var c in n.sb.currentUser&&r.userId===n.sb.currentUser.userId&&(e.myMemberState="joined",l.cachedChannels[e.url]=e),n.sb.channelHandlers){var d=n.sb.channelHandlers[c];d.onUserJoined(e,r),e.isBroadcast&&u&&d.onChannelMemberCountChanged([e])}}))}else{var c=new i(Ie.data);for(var d in n.sb.currentUser&&c.userId===n.sb.currentUser.userId?(e.isPublic||l.removeCachedChannel(Ie.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)):l.cachedChannels[e.url]=e,e.isSuper||e.isBroadcast?u=e.setLatestMemberCount(s,o,S.ts):(e.removeMember(c),e.updateJoinedMemberCount()),n.sb.channelHandlers){var h=n.sb.channelHandlers[d];h.onUserLeft(e,c),e.isBroadcast&&u&&h.onChannelMemberCountChanged([e])}}}}));break;case Ae.CATEGORY_CHANNEL_OPERATOR_UPDATE:Ie.isGroupChannel()?l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=Ie.data.operators.map((function(e){return new i(e)})),s=a.map((function(e){return e.userId}));for(var o in e.members)e.members[o].role=s.indexOf(e.members[o].userId)>=0?l.Role.OPERATOR:l.Role.NONE;for(var u in e.myRole=n.sb.currentUser&&s.indexOf(n.sb.currentUser.userId)>=0?l.Role.OPERATOR:l.Role.NONE,n.sb.channelHandlers){n.sb.channelHandlers[u].onOperatorUpdated(e,a)}}})):Ie.isOpenChannel()&&u.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else for(var a in e.operators=Ie.data.operators.map((function(e){return new i(e)})),n.sb.channelHandlers){n.sb.channelHandlers[a].onOperatorUpdated(e,e.operators)}}));break;case Ae.CATEGORY_CHANNEL_INVITE:l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var s=null;Ie.data&&Ie.data.inviter&&Object.keys(Ie.data.inviter).length>0&&(s=new i(Ie.data.inviter));for(var o=[],u=0;u0&&(a=new i(Ie.data.inviter));var s=new i(Ie.data.invitee);if(n.sb.currentUser&&s.userId===n.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||l.removeCachedChannel(Ie.channelUrl)),e.isSuper||e.isBroadcast){var o=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,u=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null;e.setLatestMemberCount(o,u,S.ts)}else e.removeMember(s);for(var c in n.sb.currentUser&&s.userId!==n.sb.currentUser.userId&&(l.cachedChannels[e.url]=e),n.sb.channelHandlers){n.sb.channelHandlers[c].onUserDeclinedInvitation(e,a,s)}}}));break;case Ae.CATEGORY_TYPING_START:case Ae.CATEGORY_TYPING_END:l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);for(var s in Ie.category===Ae.CATEGORY_TYPING_START?e.updateTypingStatus(a,!0):e.updateTypingStatus(a,!1),n.sb.channelHandlers){n.sb.channelHandlers[s].onTypingStatusUpdated(e)}}}));break;case Ae.CATEGORY_CHANNEL_ENTER:case Ae.CATEGORY_CHANNEL_EXIT:u.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=Ie.data.hasOwnProperty("participant_count")?Ie.data.participant_count:null,s=e.setLatestParticipantCount(a,S.ts),o=new i(Ie.data);if(Ie.category===Ae.CATEGORY_CHANNEL_ENTER)for(var l in n.sb.channelHandlers){var u=n.sb.channelHandlers[l];u.onUserEntered(e,o),s&&u.onChannelParticipantCountChanged([e])}else for(var c in n.sb.channelHandlers){var d=n.sb.channelHandlers[c];d.onUserExited(e,o),s&&d.onChannelParticipantCountChanged([e])}}}));break;case Ae.CATEGORY_USER_CHANNEL_MUTE:case Ae.CATEGORY_USER_CHANNEL_UNMUTE:Ie.isOpenChannel()?u.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserMuted(e,a)}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnmuted(e,a)}}})):l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId&&(e.myMutedState=Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE?"muted":"unmuted"),Array.isArray(e.members)&&e.members.forEach((function(e){e&&e.userId===a.userId&&(e.isMuted=Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)})),Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserMuted(e,a)}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnmuted(e,a)}}}));break;case Ae.CATEGORY_USER_CHANNEL_BAN:case Ae.CATEGORY_USER_CHANNEL_UNBAN:Ie.isOpenChannel()?u.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_BAN){if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId)delete u.enteredChannels[Ie.channelUrl],n.cls.FileMessageQueue.delete(Ie.channelUrl);for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserBanned(e,a)}}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnbanned(e,a)}}})):l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_BAN){if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId&&(e.isPublic||l.removeCachedChannel(Ie.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var s=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,o=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null;e.setLatestMemberCount(s,o,S.ts)}else e.removeMember(a),e.updateJoinedMemberCount();for(var u in n.sb.channelHandlers){n.sb.channelHandlers[u].onUserBanned(e,a)}}else for(var c in n.sb.channelHandlers){n.sb.channelHandlers[c].onUserUnbanned(e,a)}}}));break;case Ae.CATEGORY_CHANNEL_FREEZE:case Ae.CATEGORY_CHANNEL_UNFREEZE:Ie.isOpenChannel()?u.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(e.isFrozen=Ie.data.freeze,u.cachedChannels[e.url]=e,Ie.category===Ae.CATEGORY_CHANNEL_FREEZE)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelFrozen(e)}else for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelUnfrozen(e)}})):l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(e.isFrozen=Ie.data.freeze,l.cachedChannels[e.url]=e,Ie.category===Ae.CATEGORY_CHANNEL_FREEZE)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelFrozen(e)}else for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelUnfrozen(e)}}));break;case Ae.CATEGORY_CHANNEL_DELETED:for(var ke in Ie.isGroupChannel()?l.removeCachedChannel(Ie.channelUrl):u.removeCachedChannel(Ie.channelUrl),this.sb.channelHandlers){this.sb.channelHandlers[ke].onChannelDeleted(Ie.channelUrl,Ie.isGroupChannel()?"group":"open")}break;case Ae.CATEGORY_CHANNEL_PROP_CHANGED:Ie.isOpenChannel()?u.getChannelWithoutCache(Ie.channelUrl,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelChanged(e)}})):l.getChannelWithoutCache(Ie.channelUrl,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var i=e.unreadMessageCount,a=e.unreadMentionCount;for(var s in e.myCountPreference!==l.CountPreference.ALL&&(e.myCountPreference===l.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?a=0:e.myCountPreference===l.CountPreference.UNREAD_MENTION_COUNT_ONLY?i=0:(i=0,a=0)),e._setGroupChannelUnreadCount(i,a),n.sb.channelHandlers){n.sb.channelHandlers[s].onChannelChanged(e)}}}));break;case Ae.CATEGORY_CHANNEL_META_DATA_CHANGED:case Ae.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var Re=Ie.data.hasOwnProperty("created"),Oe=Ie.data.hasOwnProperty("updated"),Te=Ie.data.hasOwnProperty("deleted");(Ie.isOpenChannel()?u.getChannel(Ie.channelUrl,R.INTERNAL_CALL):l.getChannel(Ie.channelUrl,R.INTERNAL_CALL)).then((function(e){var t=Ie.data.created,r=Ie.data.updated,i=Ie.data.deleted,a=S.ts;for(var s in Re&&e._addOrUpdateCachedMetaData(t,a),Oe&&e._addOrUpdateCachedMetaData(r,a),Te&&e._markAsDeletedCachedMetaData(i,a),n.sb.channelHandlers){var o=n.sb.channelHandlers[s];Ie.category===Ae.CATEGORY_CHANNEL_META_DATA_CHANGED?(Re&&o.onMetaDataCreated(e,t),Oe&&o.onMetaDataUpdated(e,r),Te&&o.onMetaDataDeleted(e,i)):(Re&&o.onMetaCountersCreated(e,t),Oe&&o.onMetaCountersUpdated(e,r),Te&&o.onMetaCountersDeleted(e,i))}})).catch((function(e){return Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category)}));break;case Ae.CATEGORY_CHANNEL_HIDE:case Ae.CATEGORY_CHANNEL_UNHIDE:l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(Ie.category===Ae.CATEGORY_CHANNEL_HIDE)for(var i in e.isHidden=!0,Ie.data&&(Ie.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=Ie.data.allow_auto_unhide?l.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:l.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),Ie.data.hasOwnProperty("hide_previous_messages")&&Ie.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),S.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=S.ts_message_offset),l.cachedChannels[e.url]=e,n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelHidden(e)}else for(var a in e.isHidden=!1,e.hiddenState=l.HiddenState.UNHIDDEN,l.cachedChannels[e.url]=e,n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelChanged(e)}}))}break;case"USEV":var Me=new Ae(S);switch(Me.category){case Se.CATEGORY_USER_BLOCK:case Se.CATEGORY_USER_UNBLOCK:var Le=Me.data.blocker.user_id,Pe=Me.data.blockee.user_id;Object.keys(l.cachedChannels).forEach((function(e){var t=l.cachedChannels[e];try{n.sb.currentUser&&(n.sb.currentUser.userId===Le?t.memberMap[Pe].isBlockedByMe=Me.category===Se.CATEGORY_USER_BLOCK:n.sb.currentUser.userId===Pe&&(t.memberMap[Le].isBlockingMe=Me.category===Se.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Se.CATEGORY_FRIEND_DISCOVERED:var we=Me.data.friend_discoveries.map((function(e){return new i(e)}));for(var De in this.sb.userEventHandlers){this.sb.userEventHandlers[De].onFriendsDiscovered(we)}}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:Y.debug("Discard command:","`".concat(A.command,"`"))}}}]),e}(),Ne={},ke={},Re=function(){function e(n){l(this,e),this.channel=n,this.uploadQueue=[],this.messageQueue=[],this.latestTimestampToSendMessage=0,D.get(this._iid).FileMessageQueue.queueMap[n.url]=this}return c(e,[{key:"_handleMessageQueueUpdated",value:function(e){var n=this;switch(Y.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,r=this.messageQueue[0];if(r)if(r.state===t.State.UPLOADED){if(r&&r.state===t.State.UPLOADED){for(r.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(r,(function(e,i){r.state=t.State.SENT,r.error=e||null,r.response=i||null,n._handleMessageQueueUpdated("update")}))}}else r.state===t.State.SENT&&this._finalizeMessage()}}}},{key:"_handleUploadQueueUpdated",value:function(e,n){var t=this;switch(Y.debug("`fileMessageQueue` upload queue updated:",this.uploadQueue),e){case"add":var r=D.get(this._iid).FileMessageQueue;if(n.state=r.State.UPLOADING,n.error)this.messageQueue.map((function(e){return e.requestId})).indexOf(n.requestId)>-1&&(n.state=r.State.SENT,this._handleMessageQueueUpdated("update")),this._finalizeUpload(n.requestId);else this._uploadFile(n,(function(e){n.error&&n.state===r.State.SENT||(n.state=r.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),r=t.Command,i=t.FileMessage,a=e.fileInfo,s=r.bFile(p(p({},a),{},{requestId:e.requestId,channelUrl:this.channel.url,url:a.file,metaArrays:a.metaArrays})),o=$n.getInstance(this._iid),l=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 r=[e,t];t=r[0],e=r[1]}if(t){var l=new i(s.getJsonElement());l.requestedMentionUserIds=a.mentionedUserIds,n(t,l)}else{var u=new i(e.getJsonElement());n(null,u)}})):l.container.apiClient.sendFileMessage(p(p({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 r=new i(e?s.getJsonElement():t);e&&(r.requestedMentionUserIds=a.mentionedUserIds),n(e,r)}))}},{key:"_uploadFile",value:function(e,n){var t=e.fileInfo,r=e.pendingMessage;if("string"!=typeof t.file&&t.file){var i=D.get(this._iid).FileMessageQueue;M.get(this._iid).container.apiClient.uploadFile(p(p({},t),{},{fileType:t.type,channelUrl:this.channel.url,reqId:r?r.reqId:null}),(function(r,a){if(r)e.state=i.State.SENT,e.error=r,e.response=null,n(t);else{var s="object"===o(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=M.get(this._iid).container.isErrorFirstInCallback,n=$n.getInstance(this._iid),t=D.get(this._iid).FileMessageQueue,r=this.messageQueue[0];if(r&&r.state===t.State.SENT){r.state=t.State.DONE;var i=r.response,a=r.error,s=r.fileInfo.callback;if(i&&!a){var o=n.currentUser;if(o&&i._sender&&o.userId===i._sender.userId&&(o.nickname!==i._sender.nickname&&(o.nickname=i._sender.nickname),o.plainProfileUrl!==i._sender.plainProfileUrl&&(o.plainProfileUrl=i._sender.plainProfileUrl)),this.channel.isGroupChannel())for(var l in this.channel.lastMessage=i,n.channelHandlers){n.channelHandlers[l].onChannelChanged(this.channel)}return e?s(null,i):s(i,null),this.messageQueue.shift(),void this._handleMessageQueueUpdated("remove")}a&&(i=r.pendingMessage)&&(a.code!==L.INVALID_PARAMETER?(i.requestState=n.MessageRequestState.FAILED,i.sendingStatus=n.MessageSendingStatus.FAILED,a.code!==L.FILE_UPLOAD_CANCEL_FAILED&&a.code!==L.REQUEST_CANCELED||(i.sendingStatus=n.MessageSendingStatus.CANCELED),i.requestedMentionUserIds=r.fileInfo.mentionedUserIds,i.errorCode=a.code):i=null),e?s(a,i):s(i,a),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 r=D.get(this._iid).FileMessageQueue,i=this.messageQueue[t];!i||i.state!==r.State.UPLOADING&&i.state!==r.State.PENDING||(i.state=r.State.SENT,i.response=null,i.error=new L("Uploading has been completed or canceled.",L.FILE_UPLOAD_CANCEL_FAILED),this._handleMessageQueueUpdated("update"));var a=r.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 L("Uploading has been completed or canceled.",L.FILE_UPLOAD_CANCEL_FAILED),!1)}else n(new L("Uploading has been completed or canceled.",L.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(){ke[this._iid]={}}},{key:"queueMap",get:function(){return ke[this._iid]||(ke[this._iid]={}),ke[this._iid]}},{key:"uploadRequest",get:function(){return Ne[this._iid]||(Ne[this._iid]={}),Ne[this._iid]}}]),e}();Re.Job=function(){return function e(n){var t=n.fileInfo,r=n.requestId,i=n.pendingMessage,a=n.state,s=n.error,o=void 0===s?null:s,u=n.response,c=void 0===u?null:u;l(this,e),this.fileInfo=t,this.requestId=r,this.pendingMessage=i,this.state=a||Re.State.PENDING,this.error=o,this.response=c}}();var Oe=function(){function e(){l(this,e)}return c(e,null,[{key:"create",value:function(){return"".concat(parseInt(1e5*Math.random()),"-").concat((new Date).getTime())}}]),e}(),Te={},Me={},Le=new WeakMap,Pe=new WeakMap,we=new WeakMap,De=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).channelType=be.CHANNEL_TYPE_GROUP,r.isDistinct=!1,r.isSuper=!1,r.isBroadcast=!1,r.isPublic=!1,r.unreadMessageCount=0,r.inviter=null,r.members=[],r.memberMap={},r.lastMessage=null,r.memberCount=0,r.joinedMemberCount=0,r.cachedReadReceiptStatus={},r.cachedDeliveryReceiptStatus=null,r.myPushTriggerOption=t.PushTriggerOption.DEFAULT,r.isPushEnabled,r.isHidden=!1,r.hiddenState=t.HiddenState.UNHIDDEN,r.isDiscoverable=!0,r.myLastRead=0,r.messageSurvivalSeconds=-1,r.invitedAt=0,r.joinedAt=0,r._messageOffsetTimestamp=0,r._cachedLastDeliveredReceipt={sentAt:0,timeout:null},Le.set(C(r),{}),Pe.set(C(r),{start:0,end:0}),we.set(C(r),0),e&&r._update(e),r}return c(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=D.get(this._iid),t=n.BaseChannel,r=n.GroupChannel,i=n.User,a=n.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"))for(var s in this.cachedReadReceiptStatus={},e.read_receipt){var l=e.read_receipt[s];this.updateReadReceipt(s,parseInt(l))}if(e.hasOwnProperty("delivery_receipt")&&"object"===o(e.delivery_receipt)&&null!==e.delivery_receipt)for(var u in this.cachedDeliveryReceiptStatus||(this.cachedDeliveryReceiptStatus={}),e.delivery_receipt){var c=e.delivery_receipt[u];this.updateDeliveryReceipt(u,parseInt(c))}if(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 d=0;d0?this.inviter=new i(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),r=t.Member,i=this.removeMember(e);i&&i.state===r.JOINED&&(e.state=r.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;t0&&e.every((function(e){return!!e.userId&&"string"==typeof e.userId}))}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){return e(re.error,null)}),n):this.inviteWithUserIds(e.map((function(e){return e.userId})),n)}},{key:"inviteWithUserIds",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.inviteToGroupChannel({channelUrl:t.url,userIds:e},(function(e,r){var i=null;e||(i=D.get(t._iid).GroupChannel.upsert(r));n(e,i)}))}),n)}},{key:"acceptInvitation",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.acceptInvitation({channelUrl:t.url,accessCode:e},(function(e,r){var i=null;e||((i=D.get(t._iid).GroupChannel.upsert(r)).myMemberState="joined");n(e,i)}))}),n)}},{key:"declineInvitation",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.declineInvitation({channelUrl:n.url},(function(t,r){var i=null;if(!t){var a=D.get(n._iid).GroupChannel;(i=a.upsert(r)).myMemberState="none",n.isPublic||a.removeCachedChannel(n.url)}e(t,i)}))}),e)}},{key:"join",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.joinGroupChannel({channelUrl:t.url,accessCode:e},(function(e,r){var i=null;e||((i=D.get(t._iid).GroupChannel.upsert(r)).myMemberState="joined");n(e,i)}))}),n)}},{key:"leave",value:function(e){var n=this;return ye(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,r){return this.muteUserWithUserId(e?e.userId:null,n,t,r)}},{key:"muteUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string",optional:!0,defaultValue:""}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!0},(function(e,n){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,n){return this.unmuteUserWithUserId(e?e.userId:null,n)}},{key:"unmuteUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r){return this.banUserWithUserId(e?e.userId:null,n,t,r)}},{key:"banUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string"}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.banUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!0},(function(e,n){r(e,null)}))}),r)}},{key:"unbanUser",value:function(e,n){return this.unbanUserWithUserId(e?e.userId:null,n)}},{key:"unbanUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=!1;return"number"==typeof e&&"number"==typeof n&&"number"==typeof t&&t>=we.get(this)&&(we.set(this,t),r=n!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=n),r}},{key:"hide",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.hideGroupChannel({channelUrl:r.url,hidePreviousMessages:e,allowAutoUnhide:n},(function(i,a){if(!i){var s=D.get(r._iid).GroupChannel;r.isHidden=!0,r.hiddenState=n?s.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:s.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,e&&r._setGroupChannelUnreadCount(0,0),a.hasOwnProperty("ts_message_offset")&&(r._messageOffsetTimestamp=a.ts_message_offset),s.cachedChannels[r.url]=r}t(i,a)}))}),t)}},{key:"unhide",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.unhideGroupChannel({channelUrl:n.url},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isHidden=!1,n.hiddenState=i.HiddenState.UNHIDDEN,i.cachedChannels[n.url]=n}e(t,r)}))}),e)}},{key:"freeze",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.freeze({channelUrl:n.url,isGroupChannel:!0,freezing:!0},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isFrozen=!0,i.cachedChannels[n.url]=n}e(t,null)}))}),e)}},{key:"unfreeze",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.freeze({channelUrl:n.url,isGroupChannel:!0,freezing:!1},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isFrozen=!1,i.cachedChannels[n.url]=n}e(t,null)}))}),e)}},{key:"delete",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.deleteGroupChannel({channelUrl:n.url},(function(t,r){t||D.get(n._iid).GroupChannel.removeCachedChannel(n.url);e(t,r)}))}),e)}},{key:"markAsRead",value:function(){var e=this,n=D.get(this._iid).Command,t=$n.getInstance(this._iid),r=n.bRead({channelUrl:this.url});t.sendCommand(r,(function(n,r){if(t.getErrorFirstCallback()){var i=[n,r];r=i[0],n=i[1]}if(!r&&t.currentUser&&(e.updateReadReceipt(t.currentUser.userId,n.getJsonElement().ts),e.unreadMessageCount>0||e.unreadMentionCount>0))for(var a in e._setGroupChannelUnreadCount(0,0),t.channelHandlers){t.channelHandlers[a].onChannelChanged(e)}}))}},{key:"getUnreadMemberCount",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid).Member;if(e instanceof ve&&!e.isAdminMessage()&&n.currentUser&&!this.isSuper&&!this.isBroadcast){for(var r=0,i=e.createdAt,a=this.members,s=0;s1&&void 0!==arguments[1]&&arguments[1],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof ve&&!e.isAdminMessage()){for(var r=[],i=0;i=e.createdAt&&r.push(a)}}return r}return[]}},{key:"getUnreadMembers",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof ve&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast){var r={},i=function(i){if(!n&&i===t.currentUser.userId)return"continue";var a=e.cachedReadReceiptStatus[i],s=e.members.filter((function(e){return e.userId===i}));r[i]={user:s.length>0?s[0]:null,last_seen_at:parseInt(a)}};for(var a in this.cachedReadReceiptStatus)i(a);return r}return{}}},{key:"updateReadReceipt",value:function(e,n){var t=this.cachedReadReceiptStatus[e];if(!t||t9e3)&&(t=1e3);var r=Pe.get(this);if(n-r.start>=t){r.end=0,r.start=n;var i=D.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=$n.getInstance(this._iid),n=(new Date).getTime(),t=e.Options.typingIndicatorThrottle;("number"!=typeof t||t<1e3||t>9e3)&&(t=1e3);var r=Pe.get(this);if(n-r.end>=t){r.start=0,r.end=n;var i=D.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=Le.get(this),n=(new Date).getTime(),t=!1;for(var r in e){n-e[r].ts>=1e4&&(delete e[r],t=!0)}return t}},{key:"getTypingMembers",value:function(){var e=Le.get(this),n=[];for(var t in e){var r=this.memberMap[t];r&&n.push(r)}return n}},{key:"getTypingUsers",value:function(){var e=Le.get(this),n=[];for(var t in e){var r=e[t].user;n.push(r)}return n}},{key:"updateTypingStatus",value:function(e,n){var t=Le.get(this);n?t[e.userId]={user:e,ts:(new Date).getTime()}:delete t[e.userId]}},{key:"isTyping",value:function(){var e=Le.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var t=this,r=D.get(this._iid),i=r.ScheduledUserMessage,a=r.ScheduledUserMessageParams,s=null,o=re.parse(arguments,[new re({type:a,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new re({type:"callback"})]),l=A(o,3);return s=l[0],e=l[1],n=l[2],ye(this._iid,(function(n){s?n(s,null):M.get(t._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:t.url,isOpenChannel:!1},(function(e,r){var a=null;if(!e){a=new i(r);var s=$n.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 ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getMyPushTriggerOption({channelUrl:n.url},(function(t,r){var i=null;if(!t){try{i=r.enable}catch(e){i=!1}n.isPushEnabled=i}e&&e(t,i)}))}),e)}},{key:"setPushPreference",value:function(e,n){var t=this;return ye(this._iid,(function(n){var r=D.get(t._iid).GroupChannel;M.get(t._iid).container.apiClient.setMyPushTriggerOption({channelUrl:t.url,enable:e},(function(e,i){e||(t.isPushEnabled=i.enable,t.isPushEnabled||(t.myPushTriggerOption=r.PushTriggerOption.OFF)),n(e,i)}))}),n)}},{key:"getMyPushTriggerOption",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getMyPushTriggerOption({channelUrl:n.url},(function(r,i){var a=null;if(!r){try{a=i.push_trigger_option||t.PushTriggerOption.DEFAULT}catch(e){Y.debug(e)}n.myPushTriggerOption=a}e(r,a)}))}),e)}},{key:"setMyPushTriggerOption",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.PushTriggerOption}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.setMyPushTriggerOption({channelUrl:t.url,pushTriggerOption:e},(function(e,r){var i=null;if(!e){try{i=r.push_trigger_option}catch(e){Y.debug(e)}t.myPushTriggerOption=i}n(e,i)}))}),n)}},{key:"setMyCountPreference",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.CountPreference}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.setMyCountPreference({channelUrl:t.url,countPreference:e},(function(e,r){var a=null;e||(a=t.myCountPreference=r.count_preference,t._setGroupChannelUnreadCount(t.unreadMessageCount,t.unreadMentionCount),i.cachedChannels[t.url]=t),n(e,a)}))}),n)}},{key:"resetMyHistory",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.resetMyHistory({channelUrl:n.url},(function(t,r){if(!t&&r.hasOwnProperty("ts_message_offset")){var i=D.get(n._iid).GroupChannel;n._messageOffsetTimestamp=r.ts_message_offset,i.cachedChannels[n.url]=n}e(t,r)}))}),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"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return Te[this._iid]||(Te[this._iid]={}),Te[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid),t=n.User,r=n.Member,i=n.GroupChannel,a=n.BaseMessage,s=n.UserMessage,l=n.FileMessage,u=n.AdminMessage,c=ge.deserialize(e),d=function(e){return null!=e&&"object"===o(e)?e.messageType===a.MESSAGE_TYPE_USER?new s(s.objectify(p(p({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):e.messageType===a.MESSAGE_TYPE_FILE?new l(l.objectify(p(p({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):new u(u.objectify(p(p({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},mentionedUsers:e.mentionedUsers}))):null}(c.lastMessage);return new i({channel_url:c.url,name:c.name,cover_url:c.coverUrl,data:c.data,custom_type:c.customType,invited_at:c.invitedAt,created_at:c.createdAt/1e3,joined_ts:c.joinedAt,is_access_code_required:c.isAccessCodeRequired,is_distinct:c.isDistinct,is_super:c.isSuper,is_broadcast:c.isBroadcast,is_public:c.isPublic,is_discoverable:c.isDiscoverable,is_hidden:c.isHidden,is_ephemeral:c.isEphemeral,is_muted:c.myMutedState,is_push_enabled:c.isPushEnabled,freeze:c.isFrozen,unread_message_count:c.unreadMessageCount,unread_mention_count:c.unreadMentionCount,push_trigger_option:c.myPushTriggerOption,count_preference:c.myCountPreference,hidden_state:c.hiddenState,member_count:c.memberCount,joined_member_count:c.joinedMemberCount,member_state:c.myMemberState,my_role:c.myRole,user_last_read:c.myLastRead,ts_message_offset:c.messageOffsetTimestamp,message_survival_seconds:c.messageSurvivalSeconds,read_receipt:c.cachedReadReceiptStatus,delivery_receipt:c.cachedDeliveryReceiptStatus,members:c.members.map((function(e){return r.objectify(p({user:e},e))})),last_message:d,created_by:null!==c.creator&&void 0!==c.creator&&"object"===o(c.creator)?t.objectify(c.creator):null,inviter:null!==c.inviter&&void 0!==c.inviter&&"object"===o(c.inviter)?t.objectify(c.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 r=n.cachedChannels[t.url];e.last_message=r.lastMessage,e.unread_message_count=r.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,r=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){Te[this._iid]={},D.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,n){var t=null,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,4);if(t=a[0],e=a[1],r=a[2],n=a[3],t)return ye(this._iid,(function(e){e(t,null)}),n);var s=D.get(this._iid),o=s.GroupChannel;return o.cachedChannels[e]?ye(this._iid,(function(n){n(null,o.cachedChannels[e])}),n):o.getChannelWithoutCache(e,r,n)}},{key:"getChannelWithoutCache",value:function(e,n){var t=this,r=null,i=null,a=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),s=A(a,4);return r=s[0],e=s[1],i=s[2],n=s[3],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},(function(e,r){var i=null;e||(i=t.upsert(r)),n(e,i)}))}),n)}},{key:"createDistinctChannelIfNotExist",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannelParams,a=null,s=re.parse(arguments,[new re({type:i,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):(e.isPublic||(e.accessCode=null),M.get(t._iid).container.apiClient.createGroupChannel(p(p({},e),{},{isDistinct:!0}),(function(e,r){var i=null;if(!e){var a=D.get(t._iid).GroupChannel;i={channel:new a(r),isCreated:r.is_created},a.cachedChannels[i.channel.url]=i.channel}n(e,i)})))}),n)}},{key:"createChannel",value:function(){var e=this,n=re.toArray(arguments),t=void 0;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.GroupChannel,a=r.GroupChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];(r.isPublic||(r.accessCode=null),r._validate())?M.get(e._iid).container.apiClient.createGroupChannel(r,(function(e,n){var r=null;e||(r=new i(n),i.cachedChannels[r.url]=r),t(e,r)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}return t?i.createChannel(s,t):i.createChannel(s)}return ye(this._iid,(function(e){return e(re.error,null)}),t)}},{key:"createChannelWithUserIds",value:function(){var e=re.toArray(arguments),n=void 0;"function"==typeof e[e.length-1]&&(n=e.pop());var t=D.get(this._iid),r=t.GroupChannel,i=t.GroupChannelParams,a=new i;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 ye(this._iid,(function(e){return e(re.error,null)}),n)}return r.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 $n.getInstance(this._iid).getGroupChannelCount(e,n)}},{key:"getUnreadItemCount",value:function(e,n){return $n.getInstance(this._iid).getUnreadItemCount(e,n)}},{key:"getTotalUnreadMessageCount",value:function(){var e=re.toArray(arguments),n="function"==typeof e[e.length-1]?e.pop():null,t=$n.getInstance(this._iid);return t.getTotalUnreadMessageCount.apply(t,S(e).concat([n]))}},{key:"getTotalUnreadChannelCount",value:function(e){return $n.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),t}(be),He=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).state="",r.role="",r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,e&&r._update(e),r}return c(t,[{key:"_update",value:function(e){this.state=e.state,this.role=e.role||De.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me)}},{key:"parse",value:function(e){this._update(e)}}],[{key:"objectify",value:function(e){var n=D.get(this._iid).User,t=e.user,r=e.state,i=e.role,a=void 0===i?"":i,s=e.isMuted,o=void 0!==s&&s,l=e.isBlockedByMe,u=void 0!==l&&l,c=e.isBlockingMe,d=void 0!==c&&c,h=n.objectify(t);return h.state=r,h.role=a,h.is_muted=o,h.is_blocked_by_me=u,h.is_blocking_me=d,h}},{key:"build",value:function(e,n,t,r,i,a){var s=D.get(this._iid).User;return this.objectify({user:new s(e),state:n,role:t,isMuted:r,isBlockedByMe:i,isBlockingMe:a})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).Member,t=ge.deserialize(e);return new n(n.objectify(p({user:t},t)))}},{key:"JOINED",get:function(){return"joined"}},{key:"INVITED",get:function(){return"invited"}}]),t}(Ce),Fe=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).role="",r.isBlockedByMe=!1,e&&r._update(e),r}return c(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,r=e.role,i=void 0===r?"":r,a=e.isBlockedByMe,s=void 0!==a&&a,o=n.objectify(t);return o.role=i,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=ge.deserialize(e);return new n(n.objectify(p({user:t},t)))}}]),t}(Ce),Ge=function(){function e(n){l(this,e),this.emojiHash=null,this.emojiCategories=null,n&&this._update(n)}return c(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){l(this,e),this.id=null,this.name=null,this.url=null,this.emojis=null,n&&this._update(n)}return c(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}(),je=function(){function e(n){l(this,e),this.key=null,this.url=null,n&&this._update(n)}return c(e,[{key:"_update",value:function(e){this.key=e.key,this.url=e.url}}]),e}(),xe={},qe={},ze=new WeakMap,Qe=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).channelType=be.CHANNEL_TYPE_OPEN,r.participantCount=0,ze.set(C(r),0),r.operators=[],e&&r._update(e),r}return c(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 ye(this._iid,(function(e){var t=D.get(n._iid).Command.bEnter({channelUrl:n.url}),r=$n.getInstance(n._iid);r.sendCommand(t,(function(t,i){if(r.getErrorFirstCallback()){var a=[t,i];i=a[0],t=a[1]}i?(i=i?new L(i.message,i.code):null,e(i,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 ye(this._iid,(function(e){var t=D.get(n._iid),r=t.Command,i=t.FileMessageQueue,a=r.bExit({channelUrl:n.url}),s=$n.getInstance(n._iid);s.sendCommand(a,(function(t,r){if(s.getErrorFirstCallback()){var a=[t,r];r=a[0],t=a[1]}r?(r=r?new L(r.message,r.code):null,e(r,null)):(delete D.get(n._iid).OpenChannel.enteredChannels[n.url],i.delete(n.url),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,n=re.toArray(arguments),t=null;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.OpenChannel,a=r.OpenChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];(r.channelUrl=e.url,r._validate())?M.get(e._iid).container.apiClient.updateOpenChannel(r,(function(e,n){var r=null;e||(r=i.upsert(n)),t(e,r)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=re.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,S(e).concat([n]));default:return ye(this._iid,(function(e){return e(re.error,null)}),n)}}},{key:"muteUser",value:function(e,n,t,r){return this.muteUserWithUserId(e?e.userId:null,n,t,r)}},{key:"muteUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string",optional:!0,defaultValue:""}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!1},(function(e,n){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,n){return this.unmuteUserWithUserId(e?e.userId:null,n)}},{key:"unmuteUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.banUser({channelUrl:r.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,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.unbanUser({channelUrl:t.url,userId:e,isGroupChannel:!1},(function(e,t){n(e,null)}))}),n)}},{key:"setLatestParticipantCount",value:function(e,n){var t=!1;return"number"==typeof e&&"number"==typeof n&&n>=ze.get(this)&&(ze.set(this,n),t=e!==this.participantCount,this.participantCount=e),t}},{key:"delete",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.deleteOpenChannel({channelUrl:n.url},(function(t,r){t||(delete D.get(n._iid).OpenChannel.cachedChannels[n.url],D.get(n._iid).FileMessageQueue.delete(n.url));e(t,r)}))}),e)}}],[{key:"cachedChannels",get:function(){return xe[this._iid]||(xe[this._iid]={}),xe[this._iid]}},{key:"enteredChannels",get:function(){return qe[this._iid]||(qe[this._iid]={}),qe[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid),t=n.User,r=n.OpenChannel,i=ge.deserialize(e);return new r({channel_url:i.url,name:i.name,cover_url:i.coverUrl,data:i.data,custom_type:i.customType,created_at:i.createdAt/1e3,freeze:i.isFrozen,is_ephemeral:i.isEphemeral,participant_count:i.participantCount,operators:i.operators.map((function(e){return t.objectify(e)}))})}},{key:"getChannel",value:function(e,n){var t=null,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,4);if(t=a[0],e=a[1],r=a[2],n=a[3],t)return ye(this._iid,(function(e){e(t,null)}),n);var s=D.get(this._iid),o=s.OpenChannel;return o.cachedChannels[e]?ye(this._iid,(function(n){n(null,o.cachedChannels[e])}),n):o.getChannelWithoutCache(e,r,n)}},{key:"getChannelWithoutCache",value:function(e,n){var t=this,r=null,i=null,a=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),s=A(a,4);return r=s[0],e=s[1],i=s[2],n=s[3],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getOpenChannel({channelUrl:e,internalCall:i},(function(e,r){var i=null;e||(i=D.get(t._iid).OpenChannel.upsert(r));n(e,i)}))}),n)}},{key:"createChannel",value:function(){var e=this,n=re.toArray(arguments),t=null;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.OpenChannel,a=r.OpenChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];r._validate()?M.get(e._iid).container.apiClient.createOpenChannel(r,(function(n,r){var i=null;n||(i=D.get(e._iid).OpenChannel.upsert(r));t(n,i)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}return t?i.createChannel(s,t):i.createChannel(s)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=re.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,S(e).concat([n]));default:return ye(this._iid,(function(e){return e(re.error,null)}),n)}}},{key:"upsert",value:function(e){var n=new(0,D.get(this._iid).OpenChannel)(e);return this.cachedChannels.hasOwnProperty(n.url)?this.cachedChannels[n.url].update(e):this.cachedChannels[n.url]=n,this.cachedChannels[n.url]}},{key:"removeCachedChannel",value:function(e){this.cachedChannels[e]&&delete this.cachedChannels[e],D.get(this._iid).FileMessageQueue.delete(e)}},{key:"clearCache",value:function(){xe[this._iid]={},D.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){qe[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,D.get(this._iid).OpenChannelListQuery)}}]),t}(be),Ye=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_USER,r.message=null,r._sender=null,r.reqId="",r.translations={},r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r.plugins=[],e&&r._update(e),r}return c(t,[{key:"_update",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.Sender,i=t.Plugin;this.message=String(e.message),this._sender=new r(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 i(e)})))}},{key:"sender",get:function(){var e=$n.getInstance(this._iid),n=D.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var t=n.cachedChannels[this.channelUrl];if(t){var r=t.memberMap[this._sender.userId];r&&(this._sender.nickname!==r.nickname&&(this._sender.nickname=r.nickname),this._sender.plainProfileUrl!==r.plainProfileUrl&&(this._sender.plainProfileUrl=r.plainProfileUrl),X.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"isResendable",value:function(){var e=$n.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.BaseChannel,i=t.BaseMessageParams,a=t.Sender,s=t.User,o=t.ThreadInfo,l=t.OGMetaData,u=t.Plugin,c=e.messageId,d=e.reqId,h=void 0===d?"":d,p=e.user,f=e.channel,g=e.message,y=e.data,_=void 0===y?"":y,m=e.customType,v=void 0===m?"":m,C=e.appleCriticalAlertOptions,E=e.mentionType,U=void 0===E?i.MentionType.USERS:E,b=e.mentionedUsers,A=void 0===b?[]:b,S=e.mentionedUserIds,I=void 0===S?[]:S,N=e.requestedMentionUserIds,k=void 0===N?[]:N,R=e.reactions,O=void 0===R?[]:R,T=e.metaArrays,M=void 0===T?[]:T,L=e.rootMessageId,P=void 0===L?0:L,w=e.parentMessageId,H=void 0===w?0:w,F=e.parentMessageText,G=void 0===F?"":F,B=e.threadInfo,j=void 0===B?null:B,x=e.translations,q=void 0===x?{}:x,z=e.sendingStatus,Q=e.errorCode,Y=void 0===Q?0:Q,K=e.silent,W=void 0!==K&&K,V=e.isGlobalBlocked,J=void 0!==V&&V,X=e.messageSurvivalSeconds,Z=void 0===X?-1:X,$=e.ogMetaData,ee=void 0===$?null:$,ne=e.isOperatorMessage,te=void 0!==ne&&ne,re=e.plugins,ie=void 0===re?[]:re,ae=e.createdAt,se=e.updatedAt,oe=void 0===se?0:se,le={};for(var ue in le.req_id=h,le.msg_id=c,le.user=a.objectify({user:p,role:n.currentUser&&n.currentUser.userId===p.userId?f.myRole:p.role,isBlockedByMe:p.isBlockedByMe}),le.channel_url=f.url,le.channel_type=f.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,le.message=g,le.data=_,le.custom_type=v,C&&(le.apple_critical_alert_options=C.serialize()),le.translations=q,le.is_global_block=!!J,le.ts=ae,le.updated_at=oe,le.mention_type=U,le.mentioned_users=A.map((function(e){return s.objectify(e)})),le.mentioned_user_ids=I,le.requested_mention_user_ids=k,le.reactions=O.map((function(e){return e.serialize()})),le.metaarray={},M){var ce=M[ue].key;le.metaarray[ce]=M[ue].value}return le.metaarray_key_order=M.map((function(e){return e.key})),le.root_message_id=P,le.parent_message_id=H,le.parent_message_text=G,j&&(le.thread_info=o.objectify(j)),le.sending_status=c>0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,z&&(le.sending_status=z),le.silent=!!W,le.error_code=Y,le.message_survival_seconds=Z,ee&&(le.og_tag=l.objectify(ee)),le.is_op_msg=!!te,le.plugins=ie.map((function(e){return u.objectify(e)})),le}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c,d,h,p,f,g,y,_,m,v,C,E,U,b,A,S,I,N){return this.objectify({messageId:n,reqId:e,user:t,channel:r,message:i,data:a,customType:s,appleCriticalAlertOptions:o,mentionType:f,mentionedUsers:g,mentionedUserIds:C,requestedMentionUserIds:U,reactions:p,metaArrays:h,rootMessageId:y,parentMessageId:_,parentMessageText:m,threadInfo:v,translations:l,sendingStatus:E,errorCode:b,isGlobalBlocked:u,messageSurvivalSeconds:A,ogMetaData:S,isOperatorMessage:I,plugins:N,createdAt:c,updatedAt:d})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).UserMessage,t=ge.deserialize(e);return new n(n.objectify(p(p({},t),{},{channel:{url:t.channelUrl,channelType:t.channelType},user:t.sender})))}}]),t}(ve),Ke=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_FILE,r.plainUrl=null,r.name="File",r.size=0,r.type=null,r.thumbnails=[],r._sender=null,r.reqId="",r.requireAuth=null,r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,e&&r._update(e),r}return c(t,[{key:"_update",value:function(e){var n=$n.getInstance(this._iid),t=M.get(this._iid).container.auth,r=D.get(this._iid).Sender;if(this._sender=new r(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 i in this.thumbnails)this.thumbnails[i].plainUrl=String(this.thumbnails[i].url).split("?auth=")[0],this.thumbnails[i].url=this.requireAuth?"".concat(this.thumbnails[i].plainUrl,"?auth=").concat(t.eKey):this.thumbnails[i].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=$n.getInstance(this._iid),n=D.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var t=n.cachedChannels[this.channelUrl];if(t){var r=t.memberMap[this._sender.userId];r&&(this._sender.nickname!==r.nickname&&(this._sender.nickname=r.nickname),this._sender.plainProfileUrl!==r.plainProfileUrl&&(this._sender.plainProfileUrl=r.plainProfileUrl),X.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"isResendable",value:function(){var e=$n.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.BaseChannel,i=t.BaseMessageParams,a=t.Sender,s=t.User,o=t.ThreadInfo,l=t.OGMetaData,u=e.messageId,c=e.reqId,d=void 0===c?"":c,h=e.user,p=void 0===h?{}:h,f=e.channel,g=e.plainUrl,y=e.name,_=e.type,m=e.size,v=void 0===m?0:m,C=e.data,E=void 0===C?"":C,U=e.customType,b=void 0===U?"":U,A=e.appleCriticalAlertOptions,S=e.mentionType,I=void 0===S?i.MentionType.USERS:S,N=e.mentionedUsers,k=void 0===N?[]:N,R=e.mentionedUserIds,O=void 0===R?[]:R,T=e.requestedMentionUserIds,M=void 0===T?[]:T,L=e.reactions,P=void 0===L?[]:L,w=e.metaArrays,H=void 0===w?[]:w,F=e.rootMessageId,G=void 0===F?0:F,B=e.parentMessageId,j=void 0===B?0:B,x=e.parentMessageText,q=void 0===x?"":x,z=e.threadInfo,Q=void 0===z?null:z,Y=e.thumbnails,K=void 0===Y?[]:Y,W=e.requireAuth,V=void 0!==W&&W,J=e.sendingStatus,X=e.errorCode,Z=void 0===X?0:X,$=e.silent,ee=void 0!==$&&$,ne=e.isGlobalBlocked,te=void 0!==ne&&ne,re=e.messageSurvivalSeconds,ie=void 0===re?-1:re,ae=e.ogMetaData,se=void 0===ae?null:ae,oe=e.isOperatorMessage,le=void 0!==oe&&oe,ue=e.createdAt,ce=e.updatedAt,de=void 0===ce?0:ce,he={};he.req_id=d,he.msg_id=u,he.user=a.objectify({user:p,role:n.currentUser&&n.currentUser.userId===p.userId?f.myRole:p.role,isBlockedByMe:p.isBlockedByMe}),he.channel_url=f.url,he.channel_type=f.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,he.url=g,he.name=y,he.type=_,he.size=v,he.custom=E,he.custom_type=b,A&&(he.apple_critical_alert_options=A.serialize()),he.thumbnails=K,he.require_auth=V,he.is_global_block=!!te,he.ts=ue,he.updated_at=de,he.mention_type=I,he.mentioned_users=k.map((function(e){return s.objectify(e)})),he.mentioned_user_ids=O,he.requested_mention_user_ids=M,he.reactions=P.map((function(e){return e.serialize()})),he.metaarray={};for(var pe=0;pe0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,J&&(he.sending_status=J),he.silent=!!ee,he.error_code=Z,he.message_survival_seconds=ie,se&&(he.og_tag=l.objectify(se)),he.is_op_msg=!!le,he}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c,d,h,p,f,g,y,_,m,v,C,E,U,b,A,S,I,N,k,R,O){return this.objectify({messageId:n,reqId:e,user:t,channel:r,plainUrl:i,name:a,type:s,size:o,data:l,customType:u,appleCriticalAlertOptions:c,mentionType:m,mentionedUsers:v,mentionedUserIds:A,requestedMentionUserIds:I,reactions:_,metaArrays:y,rootMessageId:C,parentMessageId:E,parentMessageText:U,threadInfo:b,thumbnails:p,requireAuth:f,sendingStatus:S,errorCode:N,isGlobalBlocked:d,messageSurvivalSeconds:k,ogMetaData:R,isOperatorMessage:O,createdAt:h,updatedAt:g})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).FileMessage,t=ge.deserialize(e);return new n(n.objectify(p(p({},t),{},{channel:{url:t.channelUrl,channelType:t.channelType},user:t.sender})))}}]),t}(ve),We=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_ADMIN,r.message="",r.translations={},e&&r._update(e),r}return c(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,r=n.BaseMessageParams,i=n.User,a=n.ThreadInfo,s=n.OGMetaData,o=e.messageId,l=e.channel,u=e.message,c=e.data,d=void 0===c?"":c,h=e.customType,p=void 0===h?"":h,f=e.mentionType,g=void 0===f?r.MentionType.USERS:f,y=e.mentionedUsers,_=void 0===y?[]:y,m=e.reactions,v=void 0===m?[]:m,C=e.metaArrays,E=void 0===C?[]:C,U=e.rootMessageId,b=void 0===U?0:U,A=e.parentMessageId,S=void 0===A?0:A,I=e.parentMessageText,N=void 0===I?"":I,k=e.threadInfo,R=void 0===k?null:k,O=e.translations,T=void 0===O?{}:O,M=e.silent,L=void 0!==M&&M,P=e.ogMetaData,w=void 0===P?null:P,H=e.createdAt,F=e.updatedAt,G=void 0===F?0:F,B={msg_id:o,channel_url:l.url,channel_type:l.channelType===t.CHANNEL_TYPE_OPEN?t.CHANNEL_TYPE_OPEN:t.CHANNEL_TYPE_GROUP,message:u,data:d,custom_type:p,silent:L,ts:H,updated_at:G};B.translations=T,B.mention_type=g,B.mentioned_users=_.map((function(e){return i.objectify(e)})),B.reactions=v.map((function(e){return e.serialize()})),B.metaarray={};for(var j=0;j0&&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 L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadUserList(p(p({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),Ze=function(){function e(n){l(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 c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadBannedUserList(p(p({},n),{},{channelUrl:n._channelUrl,isOpenChannel:n._isOpenChannel,token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.banned_list.map((function(e){return new a(e.user)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),$e=function(){function e(){l(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.userIdsFilter=[],this._token=""}return c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0&&Array.isArray(n.userIdsFilter)?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadBlockedUserList(p(p({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),en=function(){function e(){l(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,this._token=""}return c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasMore?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadFriendList(p(p({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasMore=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),nn=function(){function e(){l(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.hiddenChannelFilter=De.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0,this.includeMetaData=!0}return c(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 ge.serialize(this,(function(e){e.isLoading=!1}))}},{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){var t=D.get(n._iid),r=t.GroupChannel,i=t.GroupChannelListQuery;!("number"==typeof n.limit&&n.limit>0&&"boolean"==typeof n.includeEmpty&&"string"==typeof n.order&&[i.ORDER_CHRONOLOGICAL,i.ORDER_LATEST_LAST_MESSAGE,i.CHANNEL_NAME_ALPHABETICAL,i.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(i.QueryType).map((function(e){return i.QueryType[e]})).indexOf(n._userIdsIncludeFilterQueryType.toUpperCase())>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(n.memberStateFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(n.superChannelFilter)>-1&&Object.keys(r.PublicChannelFilter).map((function(e){return r.PublicChannelFilter[e]})).indexOf(n.publicChannelFilter)>-1&&Object.keys(r.UnreadChannelFilter).map((function(e){return r.UnreadChannelFilter[e]})).indexOf(n.unreadChannelFilter)>-1&&Object.keys(r.HiddenChannelFilter).map((function(e){return r.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||"boolean"!=typeof n.includeFrozen||"boolean"!=typeof n.includeMetaData?e(re.error,null):n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadGroupChannelList(p(p({},n),{},{token:n._token,userIdsFilter:n._userIdsFilter,searchFilter:n._searchFilter}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).GroupChannel,s=String(r.next);n._token=s,n.hasNext=!!s;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),a.upsert(e)})):t=new L("Failed at loading group channels.",L.MALFORMED_DATA)}n.isLoading=!1,e(t,i)}))):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=ge.deserialize(e),r=n.createMyGroupChannelListQuery();for(var i in t)r.hasOwnProperty(i)&&(r[i]=t[i]);return r}}]),e}(),tn=function(){function e(n){l(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 c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){var t=D.get(n._iid),r=t.GroupChannel,i=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(r.MemberStateFilter).map((function(e){return r.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 L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadMemberList(p(p({},n),{},{channelUrl:n._channelUrl,token:n._token}),(function(t,r){var a=null;if(!t){var s=String(r.next);n._token=s,n.hasNext=!!s,a=r.members.map((function(e){return new i(e)}))}n.isLoading=!1,e(t,a)}))):e(null,[]):e(re.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}(),rn=function(){function e(n){l(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 c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadMutedUserList(p(p({},n),{},{channelUrl:n._channelUrl,isOpenChannel:n._isOpenChannel,token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.muted_list.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),an=function(){function e(){l(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 c(e,[{key:"next",value:function(e){var n=this;return ye(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(re.error,null):n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadOpenChannelList(p(p({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).OpenChannel,s=String(r.next);n._token=s,n.hasNext=!!s;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),a.upsert(e)})):t=new L("Failed at loading open channels.",L.MALFORMED_DATA)}n.isLoading=!1,e(t,i)}))):e(null,[])}),e)}}]),e}(),sn=new WeakMap,on=function(){function e(n){l(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",sn.set(this,n)}return c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){if("number"==typeof n.limit&&n.limit>0)if(n.isLoading)e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else if(n.hasNext){n.isLoading=!0;var t=sn.get(n);M.get(n._iid).container.apiClient.loadOperatorList(p(p({},n),{},{token:n._token,channelUrl:t.url,isOpenChannel:t.isOpenChannel()}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.operators.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))}else e(null,[]);else e(re.error,null)}),e)}}]),e}(),ln=new WeakMap,un=function(){function e(n){l(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",n&&ln.set(this,n.channelUrl)}return c(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadParticipantList(p(p({},n),{},{channelUrl:ln.get(n),token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.participants.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),cn=new WeakMap,dn=function(){function e(n,t){var r=t.limit,i=void 0===r?20:r,a=t.reverse,s=void 0!==a&&a,o=t.exactMatch,u=void 0!==o&&o,c=t.channelUrl,d=void 0===c?"":c,h=t.channelCustomType,p=void 0===h?"":h,f=t.messageTimestampFrom,g=void 0===f?null:f,y=t.messageTimestampTo,_=void 0===y?null:y,m=t.order,v=void 0===m?"score":m,C=t.advancedQuery,E=void 0!==C&&C,U=t.targetFields,b=void 0===U?null:U;l(this,e),this.isLoading=!1,this.hasNext=!0,cn.set(this,{keyword:n,limit:i,reverse:s,exactMatch:u,channelUrl:d,channelCustomType:p,messageTimestampFrom:g,messageTimestampTo:_,order:v,advancedQuery:E,targetFields:b,previousToken:"",nextToken:""})}return c(e,[{key:"key",get:function(){return cn.get(this).keyword}},{key:"limit",get:function(){return cn.get(this).limit}},{key:"reverse",get:function(){return cn.get(this).reverse}},{key:"exactMatch",get:function(){return cn.get(this).exactMatch}},{key:"channelUrl",get:function(){return cn.get(this).channelUrl}},{key:"channelCustomType",get:function(){return cn.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return cn.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return cn.get(this).messageTimestampTo}},{key:"order",get:function(){return cn.get(this).order}},{key:"next",value:function(e){var n=this,t=D.get(this._iid),r=t.BaseChannel,i=t.GroupChannel,a=t.OpenChannel;return ye(this._iid,(function(e){var t=cn.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,g=t.advancedQuery,y=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 g&&null!==g||!Array.isArray(y)&&null!==y?e(re.error,null):n.isLoading?e(new L("Query in progress.",L.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:g,targetFields:y,nextToken:_},(function(t,s){var o=null;if(!t){for(var l in o=[],s.results){var u=s.results[l];if(u.channel.hasOwnProperty("members")){var c=new i(u.channel);i.cachedChannels[c.url]=c,o.push(r.buildMessage(u,c))}else{var d=new a(u.channel);a.cachedChannels[d.url]=d,o.push(r.buildMessage(u,d))}}n.hasNext=s.has_next,cn.get(n).nextToken=s.end_cursor}n.isLoading=!1,e(t,o)}))):e(null,[])}),e)}}]),e}(),hn=new WeakMap,pn=new WeakMap,fn=function(){function e(n){l(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,pn.set(this,Number.MAX_SAFE_INTEGER),hn.set(this,n),this.reverse=!1,this.messageTypeFilter=null,this.customTypeFilter=null,this.customTypesFilter=[],this.senderUserIdsFilter=[],this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1}return c(e,[{key:"load",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:"number",optional:!0,defaultValue:this.limit}),new re({type:"boolean",optional:!0,defaultValue:this.reverse}),new re({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 re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(Array.isArray(i.customTypesFilter)&&!i.customTypesFilter.some((function(e){return"string"!=typeof e&&null!==e}))&&Array.isArray(i.senderUserIdsFilter)&&!i.senderUserIdsFilter.some((function(e){return"string"!=typeof e}))||(o=re.error),o)r(o,null);else{if(i.limit=e,i.reverse=n,i.messageTypeFilter=t,"number"==typeof i.messageTypeFilter)switch(i.messageTypeFilter){case 0:i.messageTypeFilter=s.MessageTypeFilter.ALL;break;case 1:i.messageTypeFilter=s.MessageTypeFilter.USER;break;case 2:i.messageTypeFilter=s.MessageTypeFilter.FILE;break;case 3:i.messageTypeFilter=s.MessageTypeFilter.ADMIN}if(i.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else if(i.hasMore){i.isLoading=!0;var a=hn.get(i),l=M.get(i._iid);"boolean"==typeof i.includeReaction&&i.includeReaction&&(i.includeReactions=i.includeReaction),l.container.apiClient.getMessageList({channel:a,token:pn.get(i)||(new Date).getTime()+1e4,tokenType:"timestamp",isInclusive:!1,prevResultSize:e,nextResultSize:0,shouldReverse:n,messageType:i.messageTypeFilter,customType:i.customTypeFilter,customTypes:i.customTypesFilter,senderUserIds:i.senderUserIdsFilter,includeMetaArray:i.includeMetaArray,includeReactions:i.includeReactions,includeReplies:i.includeReplies,includeParentMessageText:i.includeParentMessageText,includeThreadInfo:i.includeThreadInfo,showSubchannelMessagesOnly:i.showSubchannelMessagesOnly},(function(n,t){var o=null;if(!n){(0===(o=t.messages.map((function(e){return s.buildMessage(e,a)}))).length||o.length0&&"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(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(t.superChannelFilter)>-1)||"string"!=typeof t.customTypeStartsWithFilter&&null!==t.customTypeStartsWithFilter||"string"!=typeof t.channelNameContainsFilter||"string"!=typeof t.metadataOrderKeyFilter&&null!==t.metadataOrderKeyFilter||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?n(re.error,null):t.isLoading?n(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,M.get(t._iid).container.apiClient.loadPublicGroupChannelList(p(p({},t),{},{token:t._token}),(function(e,i){var a=null;if(!e){var s=String(i.next);t._token=s,t.hasNext=!!s;var o=i.channels;o&&Array.isArray(o)?a=o.map((function(e){return"number"==typeof i.ts&&(e.ts=i.ts),r.upsert(e)})):e=new L("Failed at loading group channels.",L.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}(),yn=function(){function e(){l(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 c(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,S(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,S(t))}}},{key:"addUserId",value:function(e){"string"==typeof e&&this._invitedUserIds.push(e)}}]),e}(),_n=function(){function e(){l(this,e),this.channelUrl=null,this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this._operatorUserIds=[]}return c(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||null===this.channelUrl)}}]),e}(),mn=new WeakMap,vn=function(){function e(){l(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],mn.set(this,null),this._parentMessageId=null}return c(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=$n.getInstance(this._iid),t=0;t-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 r||null===r)&&("number"==typeof this._parentMessageId||null===this._parentMessageId)}}],[{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),Cn=function(e){f(t,e);var n=U(t);function t(){var e;return l(this,t),(e=n.call(this)).message=null,e.data=null,e.customType=null,e.pushNotificationDeliveryOption=null,e.appleCriticalAlertOptions=null,e._translationTargetLanguages=[],e}return c(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-1)&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof r)}}]),t}(vn),En=function(e){f(t,e);var n=U(t);function t(){var e;return l(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 c(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;n0&&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 r)}}]),t}(vn),Un=function(e){f(t,e);var n=U(t);function t(e){var r;return l(this,t),(r=n.call(this)).year=null,r.month=null,r.day=null,r.hour=null,r.min=null,r.timezone=null,r._scheduledDateTimeString=null,e&&r._update(e),r}return c(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,r,i,a){"number"==typeof e&&4===e.toString().length&&"number"==typeof n&&n>=1&&n<=12&&"number"==typeof t&&t>=1&&t<=31&&"number"==typeof r&&r>=0&&r<=24&&"number"==typeof i&&i>=0&&i<=60&&"string"==typeof a&&a.length>0&&(this.scheduledDateTimeString=e.toString()+"-"+("0"+n.toString()).substr(-2)+"-"+("0"+t.toString()).substr(-2)+" "+("0"+r.toString()).substr(-2)+":"+("0"+i.toString()).substr(-2),this.timezone=a)}}]),t}(Cn),bn=function e(){l(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=De.SuperChannelFilter.ALL},An=function(){function e(){l(this,e),this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeMetaArray=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1}return c(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.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo}}]),e}(),Sn=function(){function e(){l(this,e);var n=D.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=n.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1}return c(e,[{key:"_validate",value:function(){"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction);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&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeReplies&&"boolean"==typeof this.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo&&"boolean"==typeof this.showSubchannelMessagesOnly}}]),e}(),In=function(){function e(){l(this,e);var n=D.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=n.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeParentMessageText=!1}return c(e,[{key:"_validate",value:function(){"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction);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&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeParentMessageText}}]),e}(),Nn=function(){function e(){l(this,e),this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1}return c(e,[{key:"_validate",value:function(){return"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction),"boolean"==typeof this.includeMetaArray&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeReplies&&"boolean"==typeof this.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo}}]),e}(),kn=function(){function e(){l(this,e),this.customTypes=[],this.includeEmpty=!1,this.includeFrozen=!0}return c(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}(),Rn=function e(){l(this,e),this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},On=function e(){l(this,e),this.onFriendsDiscovered=function(e){},this.onTotalUnreadMessageCountUpdated=function(e,n){}},Tn=function e(){l(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){}},Mn=function e(n){if(l(this,e),n){var t=D.get(this._iid),r=t.User,i=t.BaseChannel;this.reader=new r(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):i.CHANNEL_TYPE_GROUP}},Ln=function(){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];l(this,e),this.key=n,this.value=Array.isArray(t)&&t.every((function(e){return"string"==typeof e}))?t:[]}return c(e,[{key:"encode",value:function(){return{key:this.key,value:this.value||[]}}}]),e}(),Pn=new WeakMap,wn=function(){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;l(this,e),this.key=n,this.userIds=t,this.updatedAt=r;var i={};for(var a in this.userIds){var s=this.userIds[a];i[s]=this.updatedAt}Pn.set(this,i)}return c(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=Pn.get(this);if(e.key===this.key&&(!n[e.userId]||n[e.userId]=0&&this.userIds.splice(t,1)}n[e.userId]=e.updatedAt}}}}],[{key:"createFromJson",value:function(e){var n=e.key,t=e.user_ids,r=e.updated_at;return"string"==typeof n&&n&&Array.isArray(t)&&t.length>0&&"number"==typeof r?new this(n,t,r):null}}]),e}(),Dn=function(){function e(n){l(this,e),this.replyCount=0,this.mostRepliedUsers=[],this.lastRepliedAt=0,this.updatedAt=0,n&&this._update(n)}return c(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"===o(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,r=e.mostRepliedUsers,i=e.lastRepliedAt,a=e.updatedAt,s={};return s.reply_count=t,Array.isArray(r)&&r.every((function(e){return e instanceof n}))&&(s.most_replies=r.map((function(e){return n.objectify(e)}))),s.last_replied_at=i,s.updated_at=a,s}},{key:"build",value:function(e,n,t,r){return this.objectify({replyCount:e,mostRepliedUsers:n,lastRepliedAt:t,updatedAt:r})}}]),e}(),Hn=function(){function e(n){l(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,n&&this._update(n)}return c(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,r=void 0===t?null:t,i=e.url,a=void 0===i?null:i,s=e.description,o=void 0===s?null:s,l=e.defaultImage,u=void 0===l?null:l,c={};return c["og:title"]=r,c["og:url"]=a,c["og:description"]=o,u&&(c["og:image"]=n.objectify(u)),c}}]),e}(),Fn=function(){function e(n){l(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 c(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,r=e.secureUrl,i=void 0===r?null:r,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=i,p.type=s,p.width=l,p.height=c,p.alt=h,p}}]),e}(),Gn=function(){function e(n){l(this,e),this.type=null,this.vendor=null,this.detail={},n&&this._update(n)}return c(e,[{key:"_update",value:function(e){this.type=e.hasOwnProperty("type")?e.type:"",this.vendor=e.hasOwnProperty("vendor")?e.vendor:"",e.hasOwnProperty("detail")&&"object"===o(e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}}],[{key:"objectify",value:function(e){var n=e.type,t=void 0===n?"":n,r=e.vendor,i=void 0===r?"":r,a=e.detail,s=void 0===a?{}:a,o={};return o.type=t,o.vendor=i,o.detail=s,o}}]),e}(),Bn=function(){function e(n){l(this,e),this.name="default",this.volume=1,n&&this._update(n)}return c(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{name:this.name,volume:this.volume}}}]),e}(),jn=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];l(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.userIds=n,this.metaDataKey="",this.metaDataValues=[],this._token=""}return c(e,[{key:"next",value:function(e){var n=this;return ye(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 L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadUserList(p(p({},n),{},{userIdsFilter:n.userIds,metaDataKeyFilter:n.metaDataKey,metaDataValuesFilter:n.metaDataValues,token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),xn=new WeakMap,qn=function(){function e(n){l(this,e),this.isLoading=!1,xn.set(this,n)}return c(e,[{key:"prev",value:function(e,n,t,r){var i=arguments,a=this;return ye(this._iid,(function(r){var s,o=D.get(a._iid).BaseChannel,l=A(re.parse(i,[new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"function"})]),5);if(s=l[0],e=l[1],n=l[2],t=l[3],r=l[4],s)r(s,null);else if(a.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var u=xn.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,r(e,t)}))}}),r)}},{key:"next",value:function(e,n,t,r){var i=arguments,a=this;return ye(this._iid,(function(r){var s,o=D.get(a._iid).BaseChannel,l=A(re.parse(i,[new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"function"})]),5);if(s=l[0],e=l[1],n=l[2],t=l[3],r=l[4],s)r(s,null);else if(a.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var u=xn.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,r(e,t)}))}}),r)}},{key:"load",value:function(e,n,t,r,i){var a=arguments,s=this;return ye(this._iid,(function(i){var o,l=D.get(s._iid).BaseChannel,u=A(re.parse(a,[new re({type:"number"}),new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"callback"})]),6);if(o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],i=u[5],o)i(o,null);else if(s.isLoading)i(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var c=xn.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:r,messageType:"",customType:""},(function(e,n){var t=null;e||(t=n.messages.map((function(e){return l.buildMessage(e,c)}))),s.isLoading=!1,i(e,t)}))}}),i)}}]),e}(),zn=0,Qn=1,Yn=2,Kn=function(){function e(n){var t=this;l(this,e),this.state=zn,this._value=null,this._reason=null;if("function"!=typeof n)throw"Promise resolver ".concat(n," is not a function");n((function(e){t.state===zn&&(t.state=Qn,t._value=e)}),(function(e){t.state===zn&&(t.state=Yn,t._reason=e)}))}return c(e,[{key:"length",get:function(){return 1}},{key:"then",value:function(n,t){var r=this,i=this;switch(this.state){case zn:setTimeout((function(){return r.then(n,t)}),100);break;case Qn:n&&"function"==typeof n&&(i=n(this._value));break;case Yn:t&&"function"==typeof t&&(i=t(this._reason))}return i instanceof e?i:this}},{key:"catch",value:function(n){var t=this,r=this;switch(this.state){case zn:setTimeout((function(){return t.catch(n)}),100);break;case Qn:break;case Yn:r=n(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(n){var t=this,r=this;switch(this.state){case zn:setTimeout((function(){return t.finally(n)}),100);break;case Qn:case Yn:r=n()}return r instanceof e?r:this}}],[{key:"all",value:function(n){return new e((function(t,r){if(Array.isArray(n)||"string"==typeof n)if(n.length>0){var i=[];for(var a in n)n[a]instanceof e?i.push(n[a]):i.push(e.resolve(n[a]));var s=new Array(i.length).fill(null),l=i.length,u=function(e,n,i){n?r(n):(l--,s[e]=i,l<=0&&t(s))};i.forEach((function(e,n){e.then((function(e){u(n,null,e)})).catch((function(e){u(n,e,null)}))}))}else t([]);else r(new Error("Uncaught (in promise) TypeError: ".concat(o(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}(),Wn=function(){"undefined"==typeof Promise&&("undefined"!=typeof window?window.Promise=Kn:"undefined"!=typeof global?global.Promise=Kn:"undefined"!=typeof self?self.Promise=Kn:"undefined"!=typeof globalThis&&(globalThis.Promise=Kn)),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})},Vn=3e5,Jn=null,Xn={},Zn=!1,$n=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l(this,e),Wn();var t=!1;if((n.newInstance||!Jn||Jn&&n.appId!==Jn.getApplicationId()&&Jn.getConnectionState()===Jn.ConnectionState.CLOSED)&&(t=!0,Jn=this),t){try{if(!n.hasOwnProperty("appId"))return Y.warn("Must be set appId."),Jn=null,null}catch(e){return Y.warn("Must be set appId."),Jn=null,null}var r=Oe.create();Object.defineProperty(this,"_iid",{get:function(){return r}}),Xn[r]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new ie(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:be.MessageTypeFilter};var i={User:Ce,Member:He,GroupChannel:De,OpenChannel:Qe,UserMessage:Ye,FileMessage:Ke,AdminMessage:We,GroupChannelListQuery:nn,MemberListQuery:tn,GroupChannelParams:yn,OpenChannelParams:_n,BaseMessageParams:vn,UserMessageParams:Cn,FileMessageParams:En,ScheduledUserMessageParams:Un,GroupChannelTotalUnreadMessageCountParams:bn,MessageRetrievalParams:An,MessageListParams:Sn,ThreadedMessageListParams:In,MessageChangeLogsParams:Nn,GroupChannelChangeLogsParams:kn,MessageMetaArray:Ln,UserEventHandler:On,SessionHandler:ae,ChannelHandler:Tn,ConnectionHandler:Rn,AppleCriticalAlertOptions:Bn},a={SessionManager:se,BaseChannel:be,BaseMessage:ve,UserListQuery:jn,ApplicationUserListQuery:Xe,BannedUserListQuery:Ze,BlockedUserListQuery:$e,FriendListQuery:en,MutedUserListQuery:rn,OpenChannelListQuery:an,OperatorListQuery:on,ParticipantListQuery:un,MessageListQuery:qn,PreviousMessageListQuery:fn,MessageSearchQuery:dn,PublicGroupChannelListQuery:gn,ScheduledUserMessage:Ve,ThreadInfo:Dn,ThreadInfoUpdateEvent:Je,OGMetaData:Hn,OGImage:Fn,Plugin:Gn,Command:ue,Sender:Fe,ReadStatus:Mn,Reaction:wn,ReactionEvent:pe,Emoji:je,EmojiCategory:Be,EmojiContainer:Ge,FileMessageQueue:Re},s=new D(this._iid,p(p({},i),a));for(var o in s)i[o]&&(this[o]=s[o]);M.create(r,{appId:n.appId,pinger:new W(this),apiClient:new ee(this),wsAdapter:new te(this),commandHandler:new Ie(this),onlineDetector:new oe(this),ackStateMap:{},subscribedUnreadMessageCount:{all:0,custom_types:{},ts:0},maxUnreadCountOfSuperGroupChannel:R.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,auth:new P,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(R.SDK_VERSION,"/").concat(n,"/").concat(t)},sessionManager:new s.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<=Vn&&(this._websocketResponseTimeout=e)}}}return Jn}return c(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 Zn}},{key:"setDebugMode",value:function(e){Zn=e,Y.mode=e?Y.Mode.DEBUG:Y.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,r,i){var a=this,s=M.get(this._iid),o=s.container,l=o.wsAdapter,u=o.onlineDetector;u&&u.start();var c=null,d=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new re({type:"callback"})]),h=A(d,6);return c=h[0],e=h[1],n=h[2],t=h[3],r=h[4],i=h[5],ye(this._iid,(function(i){c?i(c,null):(a.customApiHost=t,a.customWsHost=r,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,i(null,a.currentUser)):(a.connectionCallbacks.push(i),1===a.connectionCallbacks.length&&(l.disconnect({clearSession:!0,err:null},null),l.connect(e,n))))}),i)}},{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 L("Connection has been canceled.",L.CONNECTION_CANCELED)},null),n.reconnectCount=0,n.reconnect(this.currentUser.userId,t),!0}return!1}},{key:"disconnect",value:function(e){var n=this;return ye(this._iid,(function(e){var t=M.get(n._iid).container,r=t.wsAdapter,i=t.onlineDetector;i&&i.stop(),r.disconnect({clearSession:!0,err:new L("Connection has been canceled.",L.CONNECTION_CANCELED)},e)}),e)}},{key:"setBackgroundState",value:function(){var e=M.get(this._iid),n=e.container,t=n.wsAdapter,r=n.stateChangeEnabled;!n.isInBackground&&r&&(e.set("isInBackground",!0),this.getConnectionState()!==this.ConnectionState.CLOSED?(e.set("closedByGoingBackground",!0),t.disconnect({clearSession:!1,err:new L("Websocket connection failed.",L.WEBSOCKET_CONNECTION_FAILED)},null)):e.set("closedByGoingBackground",!1))}},{key:"setForegroundState",value:function(){var e=M.get(this._iid),n=e.container,t=n.wsAdapter,r=n.stateChangeEnabled,i=n.isInBackground,a=n.closedByGoingBackground;i&&r&&(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,r=t.extensions;t.supportedExtensionKeys.indexOf(e)>-1&&(r[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 ye(this._iid,(function(n){t.ConnectionManager.ready((function(r,i){if(r)n(r,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 L("Connection is not valid. Please reconnect.",L.WEBSOCKET_CONNECTION_CLOSED),null);if(e.isAckRequired){var l=e.requestId,u={handler:n,timer:setTimeout((function(){n(new L("Command received no ack.",L.ACK_TIMEOUT),null),delete o[l]}),t.Options.websocketResponseTimeout)};o[l]=u,s.client.send(e,(function(e){e&&(clearTimeout(u.timer),n(e,null))}))}else s.client.send(e,n)}}),!1)}),n)}},{key:"setSessionHandler",value:function(e){M.get(this._iid).container.sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,n){n instanceof D.get(this._iid).UserEventHandler&&(this.userEventHandlers[e]=n)}},{key:"removeUserEventHandler",value:function(e){delete this.userEventHandlers[e]}},{key:"removeAllUserEventHandler",value:function(){this.userEventHandlers={}}},{key:"addChannelHandler",value:function(e,n){n instanceof D.get(this._iid).ChannelHandler&&(this.channelHandlers[e]=n)}},{key:"removeChannelHandler",value:function(e){delete this.channelHandlers[e]}},{key:"removeAllChannelHandlers",value:function(){this.channelHandlers={}}},{key:"addConnectionHandler",value:function(e,n){n instanceof D.get(this._iid).ConnectionHandler&&(this.connectionHandlers[e]=n)}},{key:"removeConnectionHandler",value:function(e){delete this.connectionHandlers[e]}},{key:"removeAllConnectionHandlers",value:function(){this.connectionHandlers={}}},{key:"updateCurrentUserInfo",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:n},(function(i,a){var s=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),n&&(r.currentUser.plainProfileUrl=n)),s=r.currentUser),t(i,s)}))}),t)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"file",nullable:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:n},(function(n,i){var a=null;n||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url)),a=r.currentUser),t(n,a)}))}),t)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.updateCurrentUserInfo({preferredLanguages:e},(function(r,i){var a=null;r||(t.currentUser&&e&&(t.currentUser._preferredLanguages=e),a=t.currentUser),n(r,a)}))}),n)}},{key:"registerGCMPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,t.pushTokenRegistrationState.ERROR):t.currentUser?M.get(t._iid).container.apiClient.registerGCMPushToken({token:e},(function(e,r){var i=t.pushTokenRegistrationState.ERROR;e||(t.GCMPushToken="",i=t.pushTokenRegistrationState.SUCCESS),n(e,i)})):(t.GCMPushToken=e,n(null,t.pushTokenRegistrationState.PENDING))}),n)}},{key:"unregisterGCMPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,t.pushTokenRegistrationState.ERROR):t.currentUser?M.get(t._iid).container.apiClient.registerAPNSPushToken({token:e},(function(e,r){var i=t.pushTokenRegistrationState.ERROR;e||(t.APNSPushToken="",i=t.pushTokenRegistrationState.SUCCESS),n(e,i)})):(t.APNSPushToken=e,n(null,t.pushTokenRegistrationState.PENDING))}),n)}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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 ye(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,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"array",optional:!0,nullable:!0,defaultValue:null}),new re({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new re({type:"callback"})]),o=A(s,5);a=o[0],e=o[1],n=o[2],t=o[3],r=o[4];var l=D.get(this._iid),u=l.GroupChannelChangeLogsParams,c=null;if(a){var d=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:u,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),h=A(d,4);a=h[0],e=h[1],c=h[2],r=h[3]}else(c=new u).customTypes=n,c.includeEmpty=t,c.includeFrozen=!0;return ye(this._iid,(function(n){a?n(a,null):M.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(p({ts:null,token:e},c),(function(e,t){if(e)n(e,null);else{var r=D.get(i._iid).GroupChannel,a=t.updated.map((function(e){return new r(e)})),s=t.deleted,o=t.has_more,l=t.next;n(null,{updatedChannels:a,deletedChannelUrls:s,hasMore:o,token:l})}}))}),r)}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"array",optional:!0,nullable:!0,defaultValue:null}),new re({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new re({type:"callback"})]),o=A(s,5);a=o[0],e=o[1],n=o[2],t=o[3],r=o[4];var l=D.get(this._iid),u=l.GroupChannelChangeLogsParams,c=null;if(a){var d=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:u,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),h=A(d,4);a=h[0],e=h[1],c=h[2],r=h[3]}else(c=new u).customTypes=n,c.includeEmpty=t,c.includeFrozen=!0;return ye(this._iid,(function(n){a?n(a,null):M.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(p({ts:e,token:null},c),(function(e,t){if(e)n(e,null);else{var r=D.get(i._iid).GroupChannel,a=t.updated.map((function(e){return new r(e)})),s=t.deleted,o=t.has_more,l=t.next;n(null,{updatedChannels:a,deletedChannelUrls:s,hasMore:o,token:l})}}))}),r)}},{key:"getChannelInvitationPreference",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getChannelInvitationPreference({},(function(n,t){var r=null;n||(r={autoAccept:t.auto_accept}),e(n,r)}))}),e)}},{key:"setChannelInvitationPreference",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"boolean"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.setChannelInvitationPreference({isAutoAccept:e},(function(e,t){var r=null;e||(r={autoAccept:t.auto_accept}),n(e,r)}))}),n)}},{key:"getDoNotDisturb",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getDoNotDisturb({},(function(n,t){var r=null;n||(r={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,r)}))}),e)}},{key:"setDoNotDisturb",value:function(e,n,t,r,i,a,s){var o=this,l=null,u=re.parse(arguments,[new re({type:"boolean"}),new re({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new re({type:"string"}),new re({type:"callback"})]),c=A(u,8);return l=c[0],e=c[1],n=c[2],t=c[3],r=c[4],i=c[5],a=c[6],s=c[7],ye(this._iid,(function(s){l?s(l,null):M.get(o._iid).container.apiClient.setDoNotDisturb({doNotDisturbOn:e,startHour:n,startMin:t,endHour:r,endMin:i,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 ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getSnoozePeriod({},(function(n,t){var r=null;n||(r={isSnoozeOn:t.snooze_enabled,startTs:t.snooze_start_ts,endTs:t.snooze_end_ts}),e(n,r)}))}),e)}},{key:"setSnoozePeriod",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"boolean"}),new re({type:"number",constraint:function(e){return e>0}}),new re({type:"number",constraint:function(e){return e>0}}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._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}),r(e,t)}))}),r)}},{key:"blockUser",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.blockUserWithUserId(e.userId,n)}},{key:"blockUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e&&(!t.currentUser||e!==t.currentUser.userId)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.blockUser({blockedUserId:e},(function(e,t){var r=null;e||(r=new Ce(t)),n(e,r)}))}),n)}},{key:"unblockUser",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.unblockUserWithUserId(e.userId,n)}},{key:"unblockUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e&&(!t.currentUser||e!==t.currentUser.userId)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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 ye(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(re.error,null)}),n)}},{key:"getGroupChannelCount",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.getGroupChannelCount({memberStateFilter:e},(function(e,t){var r=null;e||(r=parseInt(t.group_channel_count)),n(e,r)}))}),n)}},{key:"getTotalUnreadChannelCount",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getTotalUnreadChannelCount({},(function(n,t){var r=null;n||(r=parseInt(t.unread_count)),e(n,r)}))}),e)}},{key:"getTotalUnreadMessageCount",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=r.GroupChannelTotalUnreadMessageCountParams,s=null,o=re.parse(arguments,[new re({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 re({type:"callback"})]),l=A(o,3);return s=l[0],e=l[1],n=l[2],ye(this._iid,(function(n){if(s)n(s,null);else{var r=i.SuperChannelFilter.ALL;if(e instanceof a){var o=e;e=o.channelCustomTypesFilter,r=o.superChannelFilter}M.get(t._iid).container.apiClient.getTotalUnreadMessageCount({customTypesFilter:e,superChannelFilter:r},(function(e,t){var r=null;e||(r=parseInt(t.unread_count)),n(e,r)}))}}),n)}},{key:"getUnreadItemCount",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i=e.filter((function(n,t){return e.indexOf(n)===t}));M.get(t._iid).container.apiClient.getUnreadItemCount({keys:i},(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;for(var t in e.custom_types)n+=e.custom_types[t];return 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 r=this,i=null,a=re.parse(arguments,[new re({type:"string"}),new re({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.getPushTokens({ts:null,token:e,type:n},(function(e,n){if(e)t(e,null);else{var r=n.type;t(null,{deviceTokens:n.device_tokens,type:r?r.toLowerCase():"unknown",hasMore:n.has_more,token:n.token})}}))}),t)}},{key:"getPushTemplate",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getPushTemplate({},(function(n,t){var r=null;n||(r=t.name.toString()),e(n,r)}))}),e)}},{key:"setPushTemplate",value:function(e,n){var t=this;return ye(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 r=null;e||(r=t.name.toString()),n(e,r)})):n(re.error,null)}),n)}},{key:"markAsReadAll",value:function(e){var n=this;return ye(this._iid,(function(e){var t=D.get(n._iid).GroupChannel,r=(new Date).getTime();r-t.markAsReadAllLastSentAt<1e3?e(new L("MarkAsRead rate limit exceeded.",L.MARK_AS_READ_RATE_LIMIT_EXCEEDED),null):(t.markAsReadAllLastSentAt=r,M.get(n._iid).container.apiClient.markAsReadAll({channelUrls:null},(function(i,a){if(!i)for(var s in t.cachedChannels)n.currentUser&&t.cachedChannels[s].updateReadReceipt(n.currentUser.userId,r),t.cachedChannels[s]._setGroupChannelUnreadCount(0,0);e(i,null)})))}),e)}},{key:"markAsReadWithChannelUrls",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i=(new Date).getTime();M.get(t._iid).container.apiClient.markAsReadAll({channelUrls:e},(function(r,a){if(!r)for(var s in e){var o=e[s];De.cachedChannels[o]&&(t.currentUser&&De.cachedChannels[o].updateReadReceipt(t.currentUser.userId,i),De.cachedChannels[o]._setGroupChannelUnreadCount(0,0))}n(r,null)}))}}),n)}},{key:"markAsDelivered",value:function(e){"string"==typeof e&&D.get(this._iid).GroupChannel.getChannel(e,R.INTERNAL_CALL,(function(e,n){e||n.markAsDelivered()}))}},{key:"getFriendChangeLogsByToken",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getFriendChangeLogsByToken({token:e},(function(e,r){var i=null;if(!e){var a=D.get(t._iid).User;i={updatedUsers:r.updated.map((function(e){return new a(e)})),deletedUserIds:r.deleted,hasMore:r.has_more,token:r.next}}n(e,i)}))}),n)}},{key:"uploadFriendDiscoveries",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.deleteFriendDiscoveries([e],n)}},{key:"deleteFriendDiscoveries",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.addFriends({userIds:e},(function(e,r){var i=null;if(!e){var a=D.get(t._iid).User;i=r.users.map((function(e){return new a(e)}))}n(e,i)}))}),n)}},{key:"deleteFriend",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.deleteFriends([e],n)}},{key:"deleteFriends",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=re.parse(arguments,[new re({type:"callback"})]),i=A(r,2);return t=i[0],e=i[1],ye(this._iid,(function(e){t?e(t,null):M.get(n._iid).container.apiClient.getAllEmoji((function(t,r){if(t)e(t,null);else{var i=new(0,D.get(n._iid).EmojiContainer)(r);e(null,i)}}))}),e)}},{key:"getEmojiCategory",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getEmojiCategory({categoryId:e},(function(e,r){if(e)n(e,null);else{var i=new(0,D.get(t._iid).EmojiCategory)(r);n(null,i)}}))}),n)}},{key:"getEmoji",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getEmoji({emojiKey:e},(function(e,r){if(e)n(e,null);else{var i=new(0,D.get(t._iid).Emoji)(r);n(null,i)}}))}),n)}},{key:"getAllowFriendDiscovery",value:function(e){var n=this,t=null,r=re.parse(arguments,[new re({type:"callback"})]),i=A(r,2);return t=i[0],e=i[1],ye(this._iid,(function(e){t?e(t,null):M.get(n._iid).container.apiClient.getAllowFriendDiscovery((function(n,t){var r=t.allow_friend_discovery;n||e(null,r)}))}),e)}},{key:"setAllowFriendDiscovery",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"boolean"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.setAllowFriendDiscovery({allowFriendDiscovery:e},(function(t,r){t||n(null,e)}))}),n)}}],[{key:"version",get:function(){return R.SDK_VERSION}},{key:"LogLevel",get:function(){return Y.supportedLogLevels}},{key:"getInstance",value:function(e){return e?Xn[e]:Jn}},{key:"getLogLevel",value:function(){return Y.logLevel}},{key:"setLogLevel",value:function(e){var n=Object.values(Y.supportedLogLevels);if(n.includes(e))Y.logLevel=e;else{Y.logLevel=Y.defaultLogLevel;var t=n.map((function(e){return"'".concat(e,"'")})).join(", ");Y.warn("`logLevel` parameter should be one of","".concat(t,","),"not `'".concat(e,"'`."),"Set to default log level","`".concat(Y.defaultLogLevel,"`."))}}}]),e}();return $n})); \ No newline at end of file +!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 r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e),a=r(n),s=r(t);function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;ne.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 R=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.152"}},{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}(),O={},T=new WeakMap,M=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),T.set(this,"object"===u(n)&&n?n:{})}return h(e,[{key:"container",get:function(){return T.get(this)}},{key:"get",value:function(e){return T.get(this)[e]}},{key:"set",value:function(e,n){T.get(this)[e]=n}},{key:"remove",value:function(e){var n=T.get(this);n.hasOwnProperty(e)&&delete n[e]}}],[{key:"create",value:function(n,t){return O[n]=new e(t),O[n]}},{key:"get",value:function(e){return e||(e=$n.getInstance()._iid),O[e]}}]),e}(),L=function(e){f(t,e);var n=U(t);function t(e,r){var i;return c(this,t),(i=n.call(this,r)).name="SendBirdException",i.code=r||0,i.message=e,i}return h(t,[{key:"isSessionKeyExpiredError",get:function(){return 400309===this.code}},{key:"isSessionTokenExpiredError",get:function(){return 400302===this.code}}],[{key:"INVALID_INITIALIZATION",get:function(){return 800100}},{key:"CONNECTION_REQUIRED",get:function(){return 800101}},{key:"CONNECTION_CANCELED",get:function(){return 800102}},{key:"INVALID_PARAMETER",get:function(){return 800110}},{key:"NETWORK_ERROR",get:function(){return 800120}},{key:"NETWORK_ROUTING_ERROR",get:function(){return 800121}},{key:"MALFORMED_DATA",get:function(){return 800130}},{key:"MALFORMED_ERROR_DATA",get:function(){return 800140}},{key:"WRONG_CHANNEL_TYPE",get:function(){return 800150}},{key:"MARK_AS_READ_RATE_LIMIT_EXCEEDED",get:function(){return 800160}},{key:"QUERY_IN_PROGRESS",get:function(){return 800170}},{key:"ACK_TIMEOUT",get:function(){return 800180}},{key:"LOGIN_TIMEOUT",get:function(){return 800190}},{key:"WEBSOCKET_CONNECTION_CLOSED",get:function(){return 800200}},{key:"WEBSOCKET_CONNECTION_FAILED",get:function(){return 800210}},{key:"REQUEST_FAILED",get:function(){return 800220}},{key:"FILE_UPLOAD_CANCEL_FAILED",get:function(){return 800230}},{key:"REQUEST_CANCELED",get:function(){return 800240}},{key:"REQUEST_DUPLICATED",get:function(){return 800250}},{key:"FILE_SIZE_LIMIT_EXCEEDED",get:function(){return 800260}},{key:"SESSION_TOKEN_REQUEST_FAILED",get:function(){return 800500}},{key:"SESSION_TOKEN_REFRESHED",get:function(){return 800501}},{key:"SESSION_TOKEN_REFRESH_FAILED",get:function(){return 800502}}]),t}(v(Error)),P=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=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var r in c(this,e),this._iid=n,t){var i=t[r];"function"==typeof i&&(this[r]=this.getClonedClass(i))}w[n]=this}return h(e,[{key:"getClonedClass",value:function(e){var n=this._iid;return function(t){f(i,t);var r=U(i);function i(){return c(this,i),r.apply(this,arguments)}return h(i,[{key:"_iid",get:function(){return n}}],[{key:"_iid",get:function(){return n}},{key:"_name",get:function(){return e.name}}]),i}(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=U(t);function t(){return c(this,t),n.apply(this,arguments)}return h(t,[{key:"log",value:function(e){for(var n,t,r,i,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-1&&(B=n)}},{key:"supportedLogLevels",get:function(){return j}},{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,r=new Array(t>1?t-1:0),i=1;i0){var e=this._queue.shift();this.lock(e)}}}]),e}(),W=function(){function e(n){c(this,e),this.sb=n,this.mutex=new K,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,r=t.wsAdapter,i=t.pongTimeout;r.client.send(n),Y.debug("`PING`"),this.pingTimeoutTimer=setTimeout((function(){Y.debug("`PING` timeout."),e.stop(),r.client.handler&&r.client.handler.onError()}),i)}},{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 V(){return"undefined"==typeof window&&"undefined"!=typeof process&&("node"===process.title||void 0!==process.versions&&process.versions.node||"[object process]"===String(process))}var J=[L.CONNECTION_REQUIRED,L.NETWORK_ERROR,L.ACK_TIMEOUT,L.WEBSOCKET_CONNECTION_CLOSED,L.WEBSOCKET_CONNECTION_FAILED,L.FILE_UPLOAD_CANCEL_FAILED,L.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),r=l({},n);return(!t.messageId||!r.messageId||t.messageId===r.messageId)&&((!t.reqId||!r.reqId||t.reqId===r.reqId)&&(t.hasOwnProperty("messageId")&&delete t.messageId,t.hasOwnProperty("reqId")&&delete t.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(t)===JSON.stringify(r)))}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(V()){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){if(c(this,e),this.fields={},n)for(var t in n)this.fields[t]={value:n[t]},X.isFile(n[t])&&(this.fields[t].filename=n[t].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(){var e=!1;for(var n in this.fields)if(X.isFile(this.fields[n].value)){e=!0;break}if(e){var t=new a.default;for(var r in this.fields){var i=this.fields[r];if(X.isFile(i.value)){var s=i.value;s.filename||s.name?t.append(r,i.value,s.filename||s.name):s.data?t.append(r,i.value,s.data.name):t.append(r,i.value,"unnamed")}else t.append(r,i.value)}return t}var o={};for(var l in this.fields)o[l]=this.fields[l].value;return 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,r=e.params;return t?r&&r.internal?"".concat(n,"/v").concat(R.SDK_MAJOR_VERSION,"/sdk").concat(t):"".concat(n,"/v").concat(R.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,r=void 0!==t&&t,i=n.accessToken,s=void 0===i?null:i,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(R.OS_VERSION,",").concat(R.SDK_VERSION,",").concat(c),o["SB-User-Agent"]=encodeURIComponent(p(h)),!r&&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=[];for(var r in n){var i=n[r];if(null!=i){var a="";a="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(r,"=").concat(a))}}return t.length>0?"".concat(e,"?").concat(t.join("&")):e}catch(n){return Y.debug("createWithEncodedGetParams is failed. - ",n),e}}},{key:"_request",value:function(e,n,t,r){var s=this;this.checkRouting((function(o,l){if(o)r(new L("Request failed.",L.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:Y.supportedLogLevels.DEBUG,messages:["url:",n]},{level:Y.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||V()||"function"!=typeof fetch)switch(e){case"GET":f=i.default.get(p,{headers:d,validateStatus:s._validateStatus});break;case"POST":var g=null;if(c instanceof a.default){var y=i.default.CancelToken.source();g=y.token;var _=s.cls.FileMessageQueue,m=t.upload.reqId;m&&(h.push({level:Y.supportedLogLevels.DEBUG,messages:["request id:",m]}),_.uploadRequest[m]=y)}f=i.default.post(p,"function"==typeof c.getBuffer?c.getBuffer():c,{headers:d,validateStatus:s._validateStatus,cancelToken:g,onUploadProgress:function(e){t.upload.progressHandler&&t.upload.progressHandler(e,t.upload.reqId)}});break;case"PUT":f=i.default.put(p,c,{headers:d,validateStatus:s._validateStatus});break;case"DELETE":f=i.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 C=new AbortController,E=C.signal;v.signal=E;var U=s.cls.FileMessageQueue,b=t.upload.reqId;b&&(h.push({level:Y.supportedLogLevels.DEBUG,messages:["request id:",b]}),U.uploadRequest[b]=C)}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})}))}))}Y.group("".concat(e," request"),h),h=[],f.then((function(n){try{var i=n.data;"POST"===e&&"function"==typeof t.upload.deleteRequest&&t.upload.deleteRequest(),h.push({level:Y.supportedLogLevels.DEBUG,messages:["data:",i]}),r(null,i)}catch(e){throw{code:$,rawError:e}}})).catch((function(i){if(i.code===$)throw i.rawError;"POST"===e&&"function"==typeof t.upload.deleteRequest&&t.upload.deleteRequest();var a=s._handleError(i);h.push({level:Y.supportedLogLevels.DEBUG,messages:["error:",a]}),n&&t&&a.isSessionKeyExpiredError?M.get(s.sb._iid).container.sessionManager.refresh((function(e){return r(e,null)})):r(a,null)})).finally((function(){return Y.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 L("Request has been canceled.",L.REQUEST_CANCELED);if(t){var r=t.data,i=r?r.message:"Request failed.",a=r?r.code:L.REQUEST_FAILED;return new L(i,a)}return new L("Request failed.",L.REQUEST_FAILED)}return new L("There was a network error.",L.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 r=this,i=n.accessToken;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.USERS_USERID_SESSION_KEY.replace("%s",encodeURIComponent(a.userId)),o=new Z;o.options.noSessionKey=!0,o.options.accessToken=i,r.post(s,o,t)}}))}},{key:"updateCurrentUserInfo",value:function(n,t){var r=this,i=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;i&&c.add("nickname",i),a&&c.add("profile_url",a),s&&c.add("profile_file",s,s.name),o&&c.add("preferred_languages",o),r.put(u,c,t)}}))}},{key:"getMyGroupChannelChangeLogs",value:function(n,t){var r=this,i=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),i&&d.add("change_ts",i),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),r.get(c,d,t)}}))}},{key:"getChannelInvitationPreference",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"getGroupChannelCount",value:function(n,t){var r=this,i=n.memberStateFilter;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=r.cls.GroupChannel,o=e.Path.USERS_USERID_GROUP_CHANNEL_COUNT.replace("%s",encodeURIComponent(a.userId)),l="";switch(i){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});r.get(o,u,t)}}))}},{key:"getUnreadItemCount",value:function(n,t){var r=this,i=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:i});r.get(s,o,t)}}))}},{key:"getTotalUnreadMessageCount",value:function(n,t){var r=this,i=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!==i&&i.length>0&&l.add("custom_types",i),r.get(o,l,t)}}))}},{key:"getTotalUnreadChannelCount",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_UNREAD_CHANNEL_COUNT.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"searchMessages",value:function(n,t){var r=this,i=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,g=n.targetFields;this.sb.ConnectionManager.ready((function(n,y){if(n)t(n,null);else{var _=e.Path.SEARCH_MESSAGE,m=new Z({limit:a,reverse:s,query:i,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),g&&Array.isArray(g)&&m.add("target_fields",g),r.get(_,m,t)}}))}},{key:"markAsReadAll",value:function(n,t){var r=this,i=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;i&&o.add("channel_urls",i),r.put(s,o,t)}}))}},{key:"markAsDelivered",value:function(n,t){var r=this,i=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(i)),l=new Z;a&&l.add("user_id",a),r.put(o,l,t)}}))}},{key:"setChannelInvitationPreference",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"blockUser",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"unblockUser",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"getPushTriggerOption",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setPushTriggerOption",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"getPushTokens",value:function(n,t){var r=this,i=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),i&&u.add("created_ts",i),r.get(l,u,t)}}))}},{key:"getPushTemplate",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setPushTemplate",value:function(n,t){var r=this,i=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:i});r.put(s,o,t)}}))}},{key:"getDoNotDisturb",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setDoNotDisturb",value:function(n,t){var r=this,i=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:i,start_hour:a,start_min:s,end_hour:o,end_min:l,timezone:u});r.put(d,h,t)}}))}},{key:"getSnoozePeriod",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(a,null,t)}}))}},{key:"setSnoozePeriod",value:function(n,t){var r=this,i=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:i,snooze_start_ts:a,snooze_end_ts:s});r.put(l,u,t)}}))}},{key:"registerGCMPushToken",value:function(n,t){var r=this,i=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:i,always_push:!0});r.post(s,o,t)}}))}},{key:"unregisterGCMPushToken",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"unregisterAllGCMPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"registerAPNSPushToken",value:function(n,t){var r=this,i=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:i,always_push:!0});r.post(s,o,t)}}))}},{key:"unregisterAPNSPushToken",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"unregisterAllAPNSPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"unregisterAllPushTokens",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_PUSH.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"loadFriendList",value:function(n,t){var r=this,i=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:i});r.get(o,l,t)}}))}},{key:"getFriendChangeLogsByToken",value:function(n,t){var r=this,i=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;i&&o.add("token",i),r.get(s,o,t)}}))}},{key:"addFriends",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"deleteFriends",value:function(n,t){var r=this,i=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:i});r.delete(s,o,t)}}))}},{key:"uploadFriendDiscoveries",value:function(n,t){var r=this,i=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=[];i.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});r.put(s,l,t)}}))}},{key:"deleteFriendDiscoveries",value:function(n,t){var r=this,i=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:i});r.delete(s,o,t)}}))}},{key:"loadUserList",value:function(n,t){var r=this,i=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:i,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),r.get(d,h,t)}}))}},{key:"loadBlockedUserList",value:function(n,t){var r=this,i=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:i,limit:a});s&&s.length>0&&u.add("user_ids",s),r.get(l,u,t)}}))}},{key:"createUserMetaData",value:function(n,t){var r=this,i=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:i});r.post(s,o,t)}}))}},{key:"updateUserMetaData",value:function(n,t){var r=this,i=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:i,upsert:a});r.put(o,l,t)}}))}},{key:"deleteUserMetaData",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"deleteAllUserMetaData",value:function(n,t){var r=this;this.sb.ConnectionManager.ready((function(n,i){if(n)t(n,null);else{var a=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(i.userId));r.delete(a,null,t)}}))}},{key:"getMessageChangeLogs",value:function(n,t){var r=this,i=n.channelUrl,a=n.ts,s=n.timestamp,o=n.token,l=n.isOpenChannel,u=n.includeMetaArray,c=n.includeReactions,d=n.includeReplies,h=n.includeParentMessageText,p=n.includeThreadInfo;this.sb.ConnectionManager.ready((function(n,f){if(n)t(n,null);else{var g=l?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)),y=new Z;o&&y.add("token",o),a&&y.add("change_ts",a),s&&y.add("change_ts",s),"boolean"==typeof u&&y.add("with_sorted_meta_array",u),"boolean"==typeof c&&y.add("include_reactions",c),"boolean"==typeof d&&y.add("include_replies",d),"boolean"==typeof h&&y.add("include_parent_text_message",h),"boolean"==typeof p&&y.add("include_thread_info",p),r.get(g,y,t)}}))}},{key:"getMyMutedInfo",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.get(l,null,t)}}))}},{key:"loadBannedUserList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(u,c,t)}}))}},{key:"loadMutedUserList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(u,c,t)}}))}},{key:"getMessageList",value:function(n,t){var r=this,i=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,g=n.customTypes,y=n.senderUserIds,_=n.includeMetaArray,m=n.includeReactions,v=n.includeThreadInfo,C=n.includeReplies,E=n.includeParentMessageText,U=n.showSubchannelMessagesOnly,b=n.rootMessageId,A=n.parentMessageId;this.sb.ConnectionManager.ready((function(n,l){if(n)t(n,null);else{var c=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url),S=new Z({is_sdk:String(!0),prev_limit:String(u),next_limit:String(d),include:String(o),reverse:String(h)});"timestamp"===s?S.add("message_ts",a):"messageId"===s&&S.add("message_id",String(a)),p&&S.add("message_type",String(p)),Array.isArray(g)&&(0===g.length&&("string"==typeof f?g.push(f):g.push("*")),S.add("custom_types",g)),Array.isArray(y)&&y.length>0&&S.add("sender_ids",y),"boolean"==typeof _&&S.add("with_sorted_meta_array",_),"boolean"==typeof m&&S.add("include_reactions",m),"boolean"==typeof v&&S.add("include_thread_info",v),"boolean"==typeof C&&S.add("include_replies",C),"boolean"==typeof E&&S.add("include_parent_message_text",E),"boolean"==typeof U&&i.isOpenChannel()&&S.add("show_subchannel_messages_only",U),b&&S.add("root_message_id",b),A&&S.add("parent_message_id",A),r.get(c,S,t)}}))}},{key:"translateUserMessage",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",s),c=new Z({target_langs:o});r.post(u,c,t)}}))}},{key:"getMessage",value:function(n,t){var r=this,i=n.channel,a=n.messageId;this.sb.ConnectionManager.ready((function(n,s){if(n)t(n,null);else{var o=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(a));r.get(o,null,t)}}))}},{key:"deleteMessage",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,t)}}))}},{key:"muteUser",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(i)),d=new Z({user_id:a});o&&(o>0||-1!==o)&&d.add("seconds",o),s&&d.add("description",s),r.post(c,d,t)}}))}},{key:"unmuteUser",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,t)}}))}},{key:"banUser",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(i)),d=new Z({user_id:a});s&&d.add("description",s),d.add("seconds",String(o)),r.post(c,d,t)}}))}},{key:"unbanUser",value:function(n,t){var r=this,i=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(i)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,t)}}))}},{key:"getMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new Z({keys:s});r.get(l,u,t)}}))}},{key:"createMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new Z({metacounter:s});r.post(l,u,t)}}))}},{key:"updateMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),d=new Z({metacounter:s,upsert:o,mode:l});r.put(c,d,t)}}))}},{key:"deleteMetaCounter",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",s);r.delete(l,null,t)}}))}},{key:"deleteAllMetaCounters",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i));r.delete(o,null,t)}}))}},{key:"getMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new Z({keys:s,include_ts:!0});r.get(l,u,t)}}))}},{key:"createMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new Z({metadata:s,include_ts:!0});r.post(l,u,t)}}))}},{key:"updateMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),c=new Z({metadata:s,upsert:o,include_ts:!0});r.put(u,c,t)}}))}},{key:"deleteMetaData",value:function(n,t){var r=this,i=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(i)).replace("%s",s):e.Path.GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",s),u=new Z({include_ts:!0});r.delete(l,u,t)}}))}},{key:"deleteAllMetaData",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),l=new Z({include_ts:!0});r.delete(o,l,t)}}))}},{key:"loadOperatorList",value:function(n,t){var r=this,i=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(i)):e.Path.GROUPCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)),c=new Z({token:s,limit:o});r.get(u,c,t)}}))}},{key:"getOpenChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({});l.internal=a===R.INTERNAL_CALL,r.get(o,l,t)}}))}},{key:"loadOpenChannelList",value:function(n,t){var r=this,i=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:i,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),r.get(h,p,t)}}))}},{key:"loadParticipantList",value:function(n,t){var r=this,i=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:i,limit:a});r.get(l,u,t)}}))}},{key:"createOpenChannel",value:function(n,t){var r=this,i=n.name,a=n.coverUrlOrImage,s=n.data,o=n.operatorUserIds,l=n.customType;this.sb.ConnectionManager.ready((function(n,u){if(n)t(n,null);else{var c=e.Path.OPENCHANNELS,d=new Z;"string"==typeof a&&d.add("cover_url",a),X.isFile(a)&&d.add("cover_file",a),null!==i&&"string"==typeof i&&d.add("name",i),s&&d.add("data",s),o&&(Array.isArray(o)?d.add("operators",o):d.add("operators",[o])),l&&d.add("custom_type",l),r.post(c,d,t)}}))}},{key:"updateOpenChannel",value:function(n,t){var r=this,i=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(i)),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),r.put(d,h,t)}}))}},{key:"deleteOpenChannel",value:function(n,t){var r=this,i=n.channelUrl;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(s,null,t)}}))}},{key:"getGroupChannel",value:function(n,t){var r=this,i=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(i)),u=new Z({show_member:a,show_read_receipt:!0,show_delivery_receipt:!0});u.internal=s===R.INTERNAL_CALL,r.get(l,u,t)}}))}},{key:"loadGroupChannelList",value:function(n,t){var r=this,i=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,g=n.superChannelFilter,y=n.publicChannelFilter,_=n.unreadChannelFilter,m=n.metadataOrderKeyFilter,v=n.hiddenChannelFilter,C=n.searchFilter,E=n.includeFrozen,U=n.includeMetaData;this.sb.ConnectionManager.ready((function(n,b){if(n)t(n,null);else{var A=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(b.userId)),S=new Z({token:i,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&&S.add("custom_types",h),u&&S.add("members_nickname_contains",u),c&&S.add("name_contains",c),C.hasOwnProperty("search_query")&&C.hasOwnProperty("search_fields")&&(S.add("search_query",C.search_query),S.add("search_fields",C.search_fields)),l.userIds&&l.userIds.length>0&&(l.includeMode?(S.add("members_include_in",l.userIds),S.add("query_type",l.queryType.toUpperCase())):S.add("members_exactly_in",l.userIds)),d&&d.length>0&&S.add("channel_urls",d),S.add("super_mode",g),S.add("public_mode",y),S.add("unread_filter",_),m&&S.add("metadata_order_key",m),p&&S.add("custom_type_startswith",p),v&&S.add("hidden_mode",v),"boolean"==typeof E&&S.add("show_frozen",E),"boolean"==typeof U&&S.add("show_metadata",U),r.get(A,S,t)}}))}},{key:"loadPublicGroupChannelList",value:function(n,t){var r=this,i=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,g=n.includeFrozen,y=n.includeMetaData;this.sb.ConnectionManager.ready((function(n,_){if(n)t(n,null);else{var m=r.cls.GroupChannel,v=e.Path.GROUPCHANNELS,C=new Z({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(s),public_mode:m.PublicChannelFilter.PUBLIC,public_membership_mode:p});c&&c.length>0&&C.add("custom_types",c),l&&C.add("name_contains",l),u&&u.length>0&&C.add("channel_urls",u),C.add("super_mode",h),f&&C.add("metadata_order_key",f),d&&C.add("custom_type_startswith",d),"boolean"==typeof g&&C.add("show_frozen",g),"boolean"==typeof y&&C.add("show_metadata",y),r.get(v,C,t)}}))}},{key:"createGroupChannel",value:function(n,t){var r=this,i=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,g=n.coverImage,y=n.accessCode,_=n.isEphemeral,m=n._invitedUserIds,v=void 0===m?[]:m,C=n.operatorUserIds,E=n.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(n,m){if(n)t(n,null);else{var U=e.Path.GROUPCHANNELS,b=new Z({user_ids:[m.userId].concat(S(v)).filter((function(e,n,t){return n===t.indexOf(e)}))});null!==f&&"string"==typeof f&&b.add("cover_url",f),X.isFile(g)&&b.add("cover_file",g,g.name),null!==l&&b.add("channel_url",l),null!==i&&b.add("is_distinct",i),null!==a&&b.add("is_super",a),null!==s&&b.add("is_broadcast",s),null!==o&&b.add("is_public",o),null!==u&&b.add("is_discoverable",u),null!==c&&b.add("strict",c),null!==_&&b.add("is_ephemeral",_),y&&b.add("access_code",y),null!==d&&"string"==typeof d&&b.add("name",d),h&&b.add("data",h),p&&b.add("custom_type",p),Array.isArray(C)&&C.length>0&&b.add("operator_ids",C),null!==E&&E>-1&&b.add("message_survival_seconds",E),r.post(U,b,t)}}))}},{key:"updateGroupChannel",value:function(n,t){var r=this,i=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,g=n.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(n,y){if(n)t(n,null);else{var _=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(s)),m=new Z;null!==i&&m.add("is_distinct",i),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!==g&&g>-1&&m.add("message_survival_seconds",g),r.put(_,m,t)}}))}},{key:"addOperators",value:function(n,t){var r=this,i=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(i)),u=new Z({operator_ids:o});r.post(l,u,t)}}))}},{key:"removeOperators",value:function(n,t){var r=this,i=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(i)),u=new Z({operator_ids:o});r.delete(l,u,t)}}))}},{key:"inviteToGroupChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({user_ids:a});r.post(o,l,t)}}))}},{key:"acceptInvitation",value:function(n,t){var r=this,i=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(i)),l=new Z({user_id:s.userId});a&&l.add("access_code",a),r.put(o,l,t)}}))}},{key:"declineInvitation",value:function(n,t){var r=this,i=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(i)),o=new Z({user_id:a.userId});r.put(s,o,t)}}))}},{key:"joinGroupChannel",value:function(n,t){var r=this,i=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(i)),l=new Z({user_id:s.userId});a&&l.add("access_code",a),r.put(o,l,t)}}))}},{key:"leaveGroupChannel",value:function(n,t){var r=this,i=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(i)),o=new Z({user_id:a.userId});r.put(s,o,t)}}))}},{key:"hideGroupChannel",value:function(n,t){var r=this,i=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(i)),u=new Z({user_id:o.userId,hide_previous_messages:a,allow_auto_unhide:s});r.put(l,u,t)}}))}},{key:"unhideGroupChannel",value:function(n,t){var r=this,i=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(i));r.delete(s,null,t)}}))}},{key:"freeze",value:function(n,t){var r=this,i=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(i)):e.Path.OPENCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)),u=new Z({freeze:s});r.put(l,u,t)}}))}},{key:"deleteGroupChannel",value:function(n,t){var r=this,i=n.channelUrl;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(s,null,t)}}))}},{key:"loadMemberList",value:function(n,t){var r=this,i=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(i)),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),r.get(h,p,t)}}))}},{key:"report",value:function(n,t){var r=this,i=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(i)),d=new Z({report_category:s});null!=o&&d.add("reporting_user_id",o),null!=l&&d.add("report_description",l),r.post(c,d,t)}}))}},{key:"reportUser",value:function(n,t){var r=this,i=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(i)),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),r.post(d,h,t)}}))}},{key:"reportMessage",value:function(n,t){var r=this,i=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(i)).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),r.post(h,p,t)}}))}},{key:"sendUserMessage",value:function(n,t){var r=this,i=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,g=n.parentMessageId,y=n.appleCriticalAlertOptions;this.sb.ConnectionManager.ready((function(n,_){if(n)t(n,null);else{var m=r.cls.FileMessageParams,v=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),C=new Z({message_type:"MESG",user_id:_.userId,message:s,mention_type:d,mentioned_user_ids:[]});null!=o&&C.add("data",o),null!=l&&C.add("custom_type",l),u&&C.add("translation_target_langs",u),c&&c.length>0&&C.add("sorted_metaarray",c.map((function(e){return e.encode()}))),d===r.cls.BaseMessageParams.MentionType.CHANNEL?C.add("mentioned_user_ids",[]):Array.isArray(h)&&h.length>0&&C.add("mentioned_user_ids",h),p&&p!==m.PushNotificationDeliveryOption.DEFAULT&&C.add("push_option",p),f&&C.add("root_message_id",f),g&&C.add("parent_message_id",g),y&&C.add("apple_critical_alert_options",y.serialize()),r.post(v,C,t)}}))}},{key:"sendFileMessage",value:function(n,t){var r=this,i=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,g=n.mentionType,y=n.mentionedUserIds,_=n.pushNotificationDeliveryOption,m=n.rootMessageId,v=n.parentMessageId,C=n.appleCriticalAlertOptions;this.sb.ConnectionManager.ready((function(n,E){if(n)t(n,null);else{var U=r.cls.FileMessageParams,b=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),A=new Z({message_type:"FILE",user_id:E.userId,url:s,mention_type:g,mentioned_user_ids:[]});null!=o&&A.add("file_name",o),null!=l&&A.add("file_size",l),null!=u&&A.add("file_type",u),null!=c&&A.add("custom_field",c),null!=d&&A.add("custom_type",d),h&&A.add("thumbnails",h),p&&A.add("require_auth",p),f&&f.length>0&&A.add("sorted_metaarray",f.map((function(e){return e.encode()}))),g===r.cls.BaseMessageParams.MentionType.CHANNEL?A.add("mentioned_user_ids",[]):Array.isArray(y)&&y.length>0&&A.add("mentioned_user_ids",y),_&&_!==U.PushNotificationDeliveryOption.DEFAULT&&A.add("push_option",_),m&&A.add("root_message_id",m),v&&A.add("parent_message_id",v),C&&A.add("apple_critical_alert_options",C.serialize()),r.post(b,A,t)}}))}},{key:"uploadFile",value:function(n,t){var r=this,i=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(r.sb._iid).container.appInfo;if(c)if("number"==typeof i.size||i.size||(i.size=0),"number"==typeof i.size)if(i.size<=c.uploadSizeLimit){var d=e.Path.STORAGE_FILE,h=new Z;if(h.add("file",i,i.name),s&&"string"==typeof s&&h.add("channel_url",s),a)for(var p=0;p0&&u.add("metaarray",i.metaArrayKeys),i.mentionType&&u.add("mention_type",i._mentionType),i._mentionType===r.cls.BaseMessageParams.MentionType.CHANNEL?u.add("mentioned_user_ids",[]):Array.isArray(i._mentionedUserIds)&&i._mentionedUserIds.length>0&&u.add("mentioned_user_ids",i._mentionedUserIds),i.translationTargetLanguages&&i.translationTargetLanguages.length>0&&u.add("translation_target_langs",i.translationTargetLanguages),i.pushNotificationDeliveryOption&&i.pushNotificationDeliveryOption!==r.cls.BaseMessageParams.PushNotificationDeliveryOption.DEFAULT&&u.add("push_option",i.pushNotificationDeliveryOption),i.appleCriticalAlertOptions&&u.add("apple_critical_alert_options",i.appleCriticalAlertOptions.serialize()),r.post(l,u,t)}}))}},{key:"getMyPushTriggerOption",value:function(n,t){var r=this,i=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(i));r.get(s,null,t)}}))}},{key:"setMyPushTriggerOption",value:function(n,t){var r=this,i=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(i)),u=new Z;a&&u.add("push_trigger_option",a),"boolean"==typeof s&&u.add("enable",s),r.put(l,u,t)}}))}},{key:"setMyCountPreference",value:function(n,t){var r=this,i=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(i)),l=new Z({count_preference:a});r.put(o,l,t)}}))}},{key:"resetMyHistory",value:function(n,t){var r=this,i=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(i));r.put(s,null,t)}}))}},{key:"addReaction",value:function(n,t){var r=this,i=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=i?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});r.post(u,c,t)}}))}},{key:"deleteReaction",value:function(n,t){var r=this,i=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=i?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});r.delete(u,c,t)}}))}},{key:"getAllEmoji",value:function(n){var t=this;this.sb.ConnectionManager.ready((function(r,i){r?n(r,null):t.get(e.Path.EMOJI_CATEGORIES,null,n)}))}},{key:"getEmojiCategory",value:function(n,t){var r=this,i=n.categoryId;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.EMOJI_CATEGORIES_CATEGORYID.replace("%s",i);r.get(s,null,t)}}))}},{key:"getEmoji",value:function(n,t){var r=this,i=n.emojiKey;this.sb.ConnectionManager.ready((function(n,a){if(n)t(n,null);else{var s=e.Path.EMOJIS_EMOJIKEY.replace("%s",i);r.get(s,null,t)}}))}},{key:"getAllowFriendDiscovery",value:function(n){var t=this;this.sb.ConnectionManager.ready((function(r,i){if(r)n(r,null);else{var a=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(i.userId));t.get(a,null,n)}}))}},{key:"setAllowFriendDiscovery",value:function(n,t){var r=this,i=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 i&&o.add("allow_friend_discovery",i),r.put(s,o,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"}}}]),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 r=this;Y.debug("`WebSocketClient.connect` called.");var i=M.get(this.sb._iid).container,a=i.pinger,s=i.auth,o=i.extensions,l=i.getUserAgentWithExtensions,u=i.sessionManager;this.wsHost=t;try{var c="/?p=JS&pv="+encodeURIComponent(R.OS_VERSION)+"&sv="+encodeURIComponent(R.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.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){Y.debug("`window` object does not exist.")}var d=!1;this.ws.onopen=function(e){Y.debug("`WebSocket.onopen` called."),r.handler.onOpen(e)},this.ws.onmessage=function(e){r.active();var n=e.data.split("\n");for(var t in n){var i=n[t];if(i&&"string"==typeof i){try{if("PONG"===i.substring(0,4)){a.pong();continue}}catch(e){Y.debug("`WebSocket.onmessage` command check error:",e)}r.handler.onMessage(i)}}},this.ws.onerror=function(e){Y.debug("`WebSocket.onerror` called:",e),a&&a.stop(),d=!0,r.sb.isReconnectingOnError=!0,r.handler.onError(e)},this.ws.onclose=function(e){Y.group("`WebSocket.onclose` called.",[{level:Y.supportedLogLevels.DEBUG,messages:["e",e]},{level:Y.supportedLogLevels.DEBUG,messages:["explicitDisconnect",r.explicitDisconnect]}]),a&&a.stop(),r.explicitDisconnect?r.handler.onClose(e):d||r.handler.onError(e),r.explicitDisconnect=!1}}},{key:"disconnect",value:function(e,n){Y.group("`WebSocketClient.onclose` called.",[{level:Y.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 L("Connection is not valid. Please reconnect.",L.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,r=M.get(this.sb._iid).container,i=r.auth,a=r.apiClient,s=r.commandHandler;i.sessionToken=n||null;var o=this.cls.GroupChannel,l=null,u=new ne.ConnectionHandler;this.client=new ne(this.sb,u),u.onMessage=function(e){s.onRawCommandReceived(e)},this.sb.loginHandler=function(e,n){if(t.sb.connecting=!1,e)t.disconnect({clearSession:!0,err:e},null);else{clearInterval(t.sb.globalTimer);var r=function(){if(o.cachedChannels)for(var e in o.cachedChannels){var n=o.cachedChannels[e];if(n.invalidateTypingStatus())for(var r in t.sb.channelHandlers){t.sb.channelHandlers[r].onTypingStatusUpdated(n)}}};r(),t.sb.globalTimer=setInterval((function(){return r()}),1e3),t.flushConnectionCallbacks(null,n),t.sb.connecting=!1,t.sb.reconnecting=!1,t.sb.ConnectionManager.processAllReadyHandler(null)}},u.onOpen=function(){t.connectCount=0,t.sb.loginTimer=setTimeout((function(){t.sb.loginTimer=null,t.sb.onLoginTimerCancel=null,t.flushConnectionCallbacks(new L("Connection timeout.",L.LOGIN_TIMEOUT),null),t.sb.disconnect(null)}),t.sb.Options.websocketResponseTimeout),t.sb.onLoginTimerCancel=function(){t.connectCount=0,t.flushConnectionCallbacks(new L("Connection has been canceled.",L.REQUEST_FAILED),null)},t.sb.connecting=!1},u.onError=function(r){Y.debug("Connect: `WebSocketClient.ConnectionHandler.onError` called.",r),i.sessionKey?(t.sb.isReconnectingOnError=!0,t.sb.ConnectionManager.errorAllReadyHandler(),t.reconnect(e,!0),t.sb.connecting=!1):t.connectCount1&&void 0!==arguments[1])||arguments[1],r=M.get(this.sb._iid),i=r.container,a=i.auth,s=i.apiClient,o=i.commandHandler,l=i.sessionManager,u=this.cls.OpenChannel;if(this.sb.reconnecting=!0,this.sb.reconnectTimer)Y.debug("Reconnect: still reconnecting.");else{if(this.reconnectCount+=1,this.reconnectCount<=1){if(t)for(var c in this.sb.connectionHandlers){var d=this.sb.connectionHandlers[c];d.onReconnectStarted()}this.reconnectDelay=0}else 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);if(!e||!a.sessionKey||this.reconnectParams.retryCount>0&&this.reconnectCount>this.reconnectParams.retryCount){for(var h in this.disconnect({clearSession:!1,err:new L("Websocket connection failed.",L.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,this.sb.connectionHandlers){var p=this.sb.connectionHandlers[h];p.onReconnectFailed()}return 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,r){if(t)t.isSessionKeyExpiredError?l.refresh((function(){})):(clearTimeout(n.sb.reconnectTimer),n.sb.reconnectTimer=null,n.reconnect(e,!1));else{for(var i in n.reconnectCount=0,n.sb.connecting=!1,n.sb.reconnecting=!1,n.sb.isReconnectingOnError=!1,n.sb.connectionHandlers){n.sb.connectionHandlers[i].onReconnectSucceeded()}if(n.sb.ConnectionManager.processAllReadyHandler(null),n.sb.isReconnectingOnError)for(var a in n.sb.ConnectionManager.networkHandlers)n.sb.ConnectionManager.networkHandlers[a].onReconnected();Object.keys(u.enteredChannels).forEach((function(e){u.enteredChannels[e].enter((function(t,r){if(t){var i=n.cls.FileMessageQueue;delete u.enteredChannels[e],i.delete(e)}}))}))}},t.onOpen=function(){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),n.sb.loginTimer=setTimeout((function(){Y.debug("Reconnect: `loginTimer` timeout."),n.sb.loginTimer=null,n.reconnect(e,!0)}),n.sb.Options.websocketResponseTimeout),n.sb.onLoginTimerCancel=null,n.sb.reconnecting=!1},t.onMessage=function(e){o.onRawCommandReceived(e)},t.onError=function(t){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",t),n.sb.isReconnectingOnError=!0,n.sb.ConnectionManager.errorAllReadyHandler(),n.reconnect(e,!0)},t.onClose=function(){Y.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),n.sb.reconnecting=!1},s.checkRouting((function(t,r){t?n.reconnect(e,!0):(n.sb.getCurrentApiHost()!==r.apiHost&&s.get("/",null,(function(){})),n.client.connect(e,null,r.wsHost))}))}),this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=M.get(this.sb._iid),r=t.container.ackStateMap,i=this.cls,a=i.GroupChannel,s=i.OpenChannel,o=e.clearSession,l=e.err;if(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){for(var u in s.clearEnteredChannels(),s.clearCache(),a.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),r)clearTimeout(r[u].timer);this.sb.currentUser=null,t.set("ackStateMap",{}),t.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),t.set("auth",new P)}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}(),re=function(){function e(n){var t=n.type,r=n.nullable,i=void 0!==r&&r,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,g=void 0===f?null:f;c(this,e),this.type=t,this.nullable=i,this.optional=s,this.optionalIf=l,this.ignoreIf=d,this.defaultValue=p,this.constraint=g}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 r=!1,i=null;"callback"===t[t.length-1].type&&("function"==typeof n[n.length-1]&&(i=n.pop()),t.pop(),r=!0);var a=[],s=null,o=0;for(var l in t){var u=t[l];"function"==typeof u.ignoreIf&&u.ignoreIf(n)?a.push(u.hasOwnProperty("defaultValue")?u.defaultValue:null):u.isMatchingType(n[o])?(u.nullable&&null===n[o]||!u.constraint||u.constraint(n[o])||(s=e.error),a.push(n[o]),o++):u.optional||"function"==typeof u.optionalIf&&u.optionalIf(n)?a.push(u.hasOwnProperty("defaultValue")?u.defaultValue:null):(s=e.error,a.push(n[o]),o++)}return r&&i&&a.push(i),n.length!==o&&(s=e.error),[s].concat(a)}},{key:"error",get:function(){return new L("Invalid parameter.",L.INVALID_PARAMETER)}},{key:"toArray",value:function(e){for(var n=[],t=0;t1&&void 0!==arguments[1])||arguments[1],t=M.get(this.sb._iid),r=t.container,i=r.auth,a=r.isInBackground;n&&i.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 L("Connection should be made first.",L.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 L("Connection should be made first.",L.CONNECTION_REQUIRED),null)}),this.authenticateTimer);this.authInfoRequester((function(r){if(t){clearTimeout(t),t=null,n.authCount--;var i=function(t,r){n.sb.connecting=!1,e(t,null)};r&&r.hasOwnProperty("userId")?r.accessToken?r.apiHost&&r.wsHost?n.sb.connect(r.userId,r.accessToken,r.apiHost,r.wsHost,i):n.sb.connect(r.userId,r.accessToken,i):r.apiHost&&r.wsHost?n.sb.connect(r.userId,r.apiHost,r.wsHost,i):n.sb.connect(r.userId,i):e(re.error,null)}}))}else e(re.error,null)}}]),e}(),ae=function e(){c(this,e),this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,n){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},se=function(){function e(n){c(this,e),this.sb=n,this.handler=null,this.callbacks=[]}return h(e,[{key:"_refreshSessionKey",value:function(){var e=this;M.get(this._iid).container.wsAdapter.isConnected?this._refreshSessionKeyByCommand((function(n){n?n.isSessionTokenExpiredError?e._handleRefreshError(n):e._refreshSessionKeyByApi((function(n){n?e._handleRefreshError(n):e._handleRefreshSuccess()})):e._handleRefreshSuccess()})):this._refreshSessionKeyByApi((function(n){n?e._handleRefreshError(n):e._handleRefreshSuccess()}))}},{key:"_refreshSessionKeyByCommand",value:function(e){var n=this.sb,t=M.get(this._iid).container.auth,r=D.get(this._iid).Command,i=r.bSessionRefresh({token:t.sessionToken,requestId:r.generateRequestId()});n.sendCommand(i,(function(r,i){if(n.getErrorFirstCallback()){var a=[r,i];i=a[0],r=a[1]}r&&(r.hasOwnProperty("error")?i=new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED):r.hasOwnProperty("new_key")&&(t.sessionKey=r.new_key)),e(i)}))}},{key:"_refreshSessionKeyByApi",value:function(e){var n=this;!function t(r){if(r<3){var i=M.get(n._iid).container,a=i.auth,s=i.apiClient,o={};a.sessionToken&&(o.accessToken=a.sessionToken),s.refreshSessionKey(o,(function(n,i){if(n)n.isSessionTokenExpiredError?e(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED)):t(r+1);else{var s=i.key;a.sessionKey=s,e(null)}}))}else e(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED))}(0)}},{key:"_handleRefreshSuccess",value:function(){var e=this.sb;e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null),e.reconnect(),this._flushCallbacks(new L("Session key refreshed.",L.SESSION_TOKEN_REFRESHED)),this.handler&&this.handler.onSessionRefreshed()}},{key:"_handleRefreshError",value:function(e){this._flushCallbacks(e),this.handler&&this.handler.onSessionError(e)}},{key:"_handleClose",value:function(){var e=this;this.sb.disconnect((function(){e._flushCallbacks(new L("Failed to refresh the session key.",L.SESSION_TOKEN_REFRESH_FAILED)),e.handler&&e.handler.onSessionClosed()}))}},{key:"_flushCallbacks",value:function(e){this.callbacks.forEach((function(n){return n(e)})),this.callbacks=[]}},{key:"setHandler",value:function(e){e instanceof ae&&(this.handler=e)}},{key:"refresh",value:function(e){var n=this,t=this.sb,r=M.get(this._iid).container.auth;if(this.handler){if(this.callbacks.push(e),1===this.callbacks.length){this.handler.onSessionExpired(),r.sessionToken?this.handler.onSessionTokenRequired((function(e){e?(r.sessionToken=e,n._refreshSessionKey()):n._handleClose()}),(function(){t.reconnectTimer&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null);var e=new L("Failed to get the session token.",L.SESSION_TOKEN_REQUEST_FAILED);n._flushCallbacks(e),n.handler&&n.handler.onSessionError(e)})):this._refreshSessionKey()}}else e(null)}}]),e}(),oe=function(){function e(n){c(this,e),this.sb=n}return h(e,[{key:"onlineWorker",value:function(){try{if("undefined"!=typeof navigator&&navigator.onLine){var e=M.get(this.sb._iid).container.auth;this.sb.reconnecting||this.sb.connecting||!e.sessionKey||this.sb.getConnectionState()===this.sb.ConnectionState.OPEN||this.sb.reconnect()}}catch(e){Y.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){Y.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){Y.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){Y.debug("There is no `window.addEventListener.ononline` or `navigator.onLine`")}}}]),e}(),le=(new Date).getTime(),ue=function(){function e(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;switch(c(this,e),this.command=n,this.requestId=r,arguments.length){case 1:if(!n||n.length<=4)this.command="NOOP",this.payload="{}";else if(this.decode(n),this.isRequestIdCommand){var i=this.getJsonElement();i&&(this.requestId=i.req_id||"")}break;case 2:case 3:!this.requestId&&this.isRequestIdCommand&&(this.requestId=e.generateRequestId()),t.req_id=this.requestId||"",this.payload=JSON.stringify(t)}}return h(e,[{key:"isRequestIdCommand",get:function(){return this.isAckRequired||"EROR"===this.command}},{key:"isAckRequired",get:function(){return"MESG"===this.command||"FILE"===this.command||"ENTR"===this.command||"EXIT"===this.command||"READ"===this.command||"MEDI"===this.command||"FEDI"===this.command}},{key:"encode",value:function(){return this.command+this.payload+"\n"}},{key:"decode",value:function(e){e=e.trim(),this.command=e.substring(0,4),this.payload=e.substring(4)}},{key:"getJsonElement",value:function(){return JSON.parse(this.payload)}}],[{key:"bSessionRefresh",value:function(e){return new this("LOGI",{token:e.token},e.requestId)}},{key:"bPing",value:function(){return new this("PING",{id:(new Date).getTime(),active:1})}},{key:"bMessage",value:function(e){var n=e.channelUrl,t=e.message,r=e.data,i=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,g=e.rootMessageId,y=void 0===g?null:g,_=e.parentMessageId,m=void 0===_?null:_,v=D.get(this._iid),C=v.UserMessageParams,E=v.BaseMessageParams,U={};return U.channel_url=n,U.message=t,U.data=r,a&&a.length>0&&(U.metaarray=a.map((function(e){return e.encode()}))),s&&(U.mention_type=s),U.mentioned_user_ids=[],s===E.MentionType.CHANNEL?U.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(U.mentioned_user_ids=o),i&&(U.custom_type=i),l&&l.length>0&&(U.target_langs=l),u&&u!==C.PushNotificationDeliveryOption.DEFAULT&&(U.push_option=u),c&&(U.apple_critical_alert_options=c.serialize()),f&&(U.silent=f),y&&(U.root_message_id=y),m&&(U.parent_message_id=m),new this("MESG",U,h)}},{key:"bFile",value:function(e){var n=e.channelUrl,t=e.url,r=e.name,i=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,g=e.requestId,y=void 0===g?null:g,_=e.silent,m=void 0!==_&&_,v=e.rootMessageId,C=void 0===v?null:v,E=e.parentMessageId,U=void 0===E?null:E,b=D.get(this._iid),A=b.BaseMessageParams,S=b.FileMessageParams,I={};return I.channel_url=n,I.url=t,I.name=r||"",I.type=i||"",I.size=a||0,I.custom=s,o&&(I.custom_type=o),l&&(I.thumbnails=l),u&&(I.require_auth=u),c&&c.length>0&&(I.metaarray=c.map((function(e){return e.encode()}))),d&&(I.mention_type=d),I.mentioned_user_ids=[],d===A.MentionType.CHANNEL?I.mentioned_user_ids=[]:Array.isArray(h)&&h.length>0&&(I.mentioned_user_ids=h),p&&p!==S.PushNotificationDeliveryOption.DEFAULT&&(I.push_option=p),f&&(I.apple_critical_alert_options=f.serialize()),m&&(I.silent=m),C&&(I.root_message_id=C),U&&(I.parent_message_id=U),new this("FILE",I,y)}},{key:"bUpdateUserMessage",value:function(e){var n=e.channelUrl,t=e.messageId,r=e.appleCriticalAlertOptions,i=e.message,a=void 0===i?null:i,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,g=void 0===f?null:f,y=D.get(this._iid).BaseMessageParams,_={};return _.channel_url=n,_.msg_id=t,null!=a&&void 0!==a&&(_.message=a),null!=o&&void 0!==o&&(_.data=o),null!=u&&void 0!==u&&(_.custom_type=u),d&&(_.mention_type=d),d===y.MentionType.CHANNEL?_.mentioned_user_ids=[]:Array.isArray(p)&&p.length>0&&(_.mentioned_user_ids=p),g&&(_.metaarray=g),r&&(_.apple_critical_alert_options=r.serialize()),new this("MEDI",_)}},{key:"bUpdateFileMessage",value:function(e){var n=e.channelUrl,t=e.messageId,r=e.appleCriticalAlertOptions,i=e.data,a=void 0===i?null:i,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,g={};return g.channel_url=n,g.msg_id=t,null!=a&&void 0!==a&&(g.data=a),null!=o&&void 0!==o&&(g.custom_type=o),u&&(g.mention_type=u),u===f.MentionType.CHANNEL?g.mentioned_user_ids=[]:Array.isArray(d)&&d.length>0&&(g.mentioned_user_ids=d),p&&(g.metaarray=p),r&&(g.apple_critical_alert_options=r.serialize()),new this("FEDI",g)}},{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,r={};return r.channel_url=n,r.msg_id=t,new this("MACK",r)}},{key:"bTypeStart",value:function(e){var n=e.channelUrl,t=e.time,r={};return r.channel_url=n,r.time=t,new this("TPST",r)}},{key:"bTypeEnd",value:function(e){var n=e.channelUrl,t=e.time,r={};return r.channel_url=n,r.time=t,new this("TPEN",r)}},{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 r=n.premium_feature_list;t.push.apply(t,S(r))}catch(e){}var i=[];if(n.hasOwnProperty("application_attributes")&&Array.isArray(n.application_attributes))try{var a=n.application_attributes;i.push.apply(i,S(a))}catch(e){}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,applicationAttributes:i,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}}]),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,r=e.operation,i=e.reaction,a=e.updated_at;if(n&&"string"==typeof t&&"string"==typeof r&&["add","delete"].indexOf(r.toLowerCase())>=0&&"string"==typeof i&&i&&"number"==typeof a){var s=new this;return s.messageId=n,s.userId=t,s.key=i,s.operation=r.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 ge=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}(),ye=function(e,n,t){return new Promise((function(r,i){n((function(n,a){t&&"function"==typeof t&&(M.get(e).container.isErrorFirstInCallback?t(n,a):t(a,n));n?i(n):r(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.ogMetaData=null,this.isOperatorMessage=!1,this.appleCriticalAlertOptions=null,n&&this.__update(n)}return h(e,[{key:"serialize",value:function(){return ge.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=$n.getInstance(this._iid),r=D.get(this._iid),i=r.User,a=r.BaseChannel,s=r.BaseMessageParams,o=r.Reaction,l=r.MessageMetaArray,u=r.ThreadInfo,c=r.OGMetaData,d=r.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 h=e.hasOwnProperty("metaarray")?e.metaarray:{},p=e.hasOwnProperty("metaarray_key_order")?e.metaarray_key_order:Object.keys(h).sort((function(e,n){return e.localeCompare(n)}));this.metaArrays=[];for(var f=0;f0?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)),e.hasOwnProperty("parent_message_text")&&(this.parentMessageText=e.parent_message_text),this.threadInfo=new u(e.thread_info),e.hasOwnProperty("og_tag")&&(this.ogMetaData=new c(e.og_tag)),this.isOperatorMessage=!!e.hasOwnProperty("is_op_msg")&&e.is_op_msg,e.hasOwnProperty("apple_critical_alert_options")&&(this.appleCriticalAlertOptions=new d(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=[];for(var r in e)t.push(new n(r,e[r]));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),r=t.Reaction,i=null,a=re.parse(arguments,[new re({type:pe,constraint:function(e){return parseInt(e.messageId)===parseInt(n.messageId)}})]),s=A(a,2);if(i=s[0],e=s[1],!i){var o=!1;for(var l in this.reactions)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 r(e.key,[e.userId],e.updatedAt))}}},{key:"_getThreadedMessageList",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.ThreadedMessageListParams,o=null,u=re.parse(arguments,[new re({type:"number"}),new re({type:"string",constraint:function(e){return Object.values(_e).includes(e)}}),new re({type:s,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),c=A(u,5);return o=c[0],e=c[1],n=c[2],t=c[3],r=c[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=D.get(i._iid),s=a.GroupChannel,u=a.OpenChannel;i.isGroupChannel()?s.getChannel(i.channelUrl,R.INTERNAL_CALL,(function(a,s){if($n.getInstance(i._iid).getErrorFirstCallback()){var o=[a,s];s=o[0],a=o[1]}s?r(s,null):M.get(i._iid).container.apiClient.getMessageList(l(l({channel:a,token:e,tokenType:n},t),{},{shouldReverse:t.reverse,rootMessageId:i.messageId,includeReplies:!0,includeThreadInfo:!0}),(function(e,n){if(e)r(e,null);else{var t=D.get(i._iid).BaseChannel,a=n.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e})),s=a.filter((function(e){return e.messageId===i.messageId}))[0],o=a.filter((function(e){return e.parentMessageId===i.messageId}));r(null,{parentMessage:s,threadedReplies:o})}}))})):i.isOpenChannel()&&u.getChannel(i.channelUrl,R.INTERNAL_CALL,(function(a,s){if($n.getInstance(i._iid).getErrorFirstCallback()){var o=[a,s];s=o[0],a=o[1]}s?r(s,null):M.get(i._iid).container.apiClient.getMessageList(l(l({channel:a,token:e,tokenType:n},t),{},{shouldReverse:t.reverse,rootMessageId:i.messageId,includeReplies:!0,includeThreadInfo:!0}),(function(e,n){if(e)r(e,null);else{var t=D.get(i._iid).BaseChannel,a=n.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e})),s=a.filter((function(e){return e.messageId===i.messageId}))[0],o=a.filter((function(e){return e.parentMessageId===i.messageId}));r(null,{parentMessage:s,threadedReplies:o})}}))}))}}),r)}},{key:"getThreadedMessagesByTimestamp",value:function(e,n,t){return this._getThreadedMessageList(e,_e.TIMESTAMP,n,t)}},{key:"applyThreadInfoUpdateEvent",value:function(e){var n=D.get(this._iid),t=n.ThreadInfo,r=n.ThreadInfoUpdateEvent,i=me.get(this),a=null,s=re.parse(arguments,[new re({type:r,constraint:function(e){return parseInt(e.targetMessageId)===parseInt(i)}})]),o=A(s,2);if(a=o[0],e=o[1],!a){var l=e,u=l.threadInfo;return this.threadInfo=new t(u),!0}return!1}}],[{key:"MESSAGE_TYPE_BASE",get:function(){return"base"}},{key:"MESSAGE_TYPE_ADMIN",get:function(){return"admin"}},{key:"MESSAGE_TYPE_USER",get:function(){return"user"}},{key:"MESSAGE_TYPE_FILE",get:function(){return"file"}},{key:"SendingStatus",get:function(){return{NONE:"none",PENDING:"pending",FAILED:"failed",CANCELED:"canceled",SUCCEEDED:"succeeded"}}},{key:"getMessage",value:function(e,n){var t=this,r=D.get(this._iid),i=r.BaseChannel,a=r.MessageRetrievalParams,s=null,o=re.parse(arguments,[new re({type:a,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),u=A(o,3);return s=u[0],e=u[1],n=u[2],ye(this._iid,(function(n){if(s)n(s,null);else{var r=D.get(t._iid),a=r.GroupChannel,o=r.OpenChannel;switch(e.channelType){case i.CHANNEL_TYPE_GROUP:a.getChannel(e.channelUrl,R.INTERNAL_CALL,(function(r,a){if($n.getInstance(t._iid).getErrorFirstCallback()){var s=[r,a];a=s[0],r=s[1]}a?n(a,null):M.get(t._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,t){if(e)n(e,null);else{var a=i.buildMessage(t,r);n(null,a)}}))}));break;case i.CHANNEL_TYPE_OPEN:o.getChannel(e.channelUrl,R.INTERNAL_CALL,(function(r,a){if($n.getInstance(t._iid).getErrorFirstCallback()){var s=[r,a];a=s[0],r=s[1]}a?n(a,null):M.get(t._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,t){if(e)n(e,null);else{var a=i.buildMessage(t,r);n(null,a)}}))}))}}}),n)}}]),e}(),Ce=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=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=D.get(this._iid),r=t.GroupChannel;for(var i in e)n?delete this.metaData[i]:this.metaData[i]=e[i];for(var a in r.cachedChannels)if(r.cachedChannels.hasOwnProperty(a)){var s=r.cachedChannels[a];if(s.memberMap.hasOwnProperty(this.userId)){var o=s.memberMap[this.userId];o.metaData=this.metaData}}}},{key:"serialize",value:function(){return ge.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,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.createUserMetaData({metaData:e},(function(e,r){e||t._updateMetaData(r),n(e,r)}))}),n)}},{key:"updateMetaData",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({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 re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateUserMetaData({metaData:e,upsert:n},(function(e,n){e||r._updateMetaData(n),t(e,n)}))}),t)}},{key:"deleteMetaData",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i={};i[e]="",M.get(t._iid).container.apiClient.deleteUserMetaData({metaDataKey:e},(function(e,r){e||t._updateMetaData(i,!0),n(e,r)}))}}),n)}},{key:"deleteAllMetaData",value:function(e){var n=this;return ye(this._iid,(function(e){var t=n.metaData;M.get(n._iid).container.apiClient.deleteAllUserMetaData({},(function(r,i){r||n._updateMetaData(t,!0),e(r,i)}))}),e)}}],[{key:"objectify",value:function(e){var n=e.userId,t=void 0===n?null:n,r=e.nickname,i=void 0===r?"":r,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,g=e.friendDiscoveryKey,y=void 0===g?null:g,_=e.friendName,m=void 0===_?null:_,v=e.preferredLanguages,C=void 0===v?null:v,E=e.requireAuth;return{user_id:t,nickname:i,profile_url:s,is_online:l,last_seen_at:c,metadata:h,is_active:f,friend_discovery_key:y,friend_name:m,preferred_languages:C,require_auth_for_profile_image:void 0!==E&&E}}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c){return this.objectify({userId:e,nickname:n,plainProfileUrl:t,connectionStatus:r,lastSeenAt:i,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=ge.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}(),Ee={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Ue=new WeakMap,be=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,Ue.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 Ce(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=Ue.get(this);Object.keys(e).forEach((function(r){var i=t[r],a=e[r];i?n>i.updatedAt&&(i.value=a,i.updatedAt=n,i.isRemoved=!1):t[r]={value:a,updatedAt:n,isRemoved:!1}}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,n){var t=Ue.get(this);e.forEach((function(e){var r=t[e];r?n>r.updatedAt&&(r.isRemoved=!0,r.updatedAt=n):t[e]={value:null,updatedAt:n,isRemoved:!0}}))}},{key:"_refreshMetaData",value:function(e,n){var t={};Object.keys(e).forEach((function(r){t[r]={value:e[r],updatedAt:n,isRemoved:!1}})),Ue.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:"serialize",value:function(){return ge.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,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:e,token:null,isOpenChannel:i.isOpenChannel(),includeMetaArray:n,includeReactions:t},(function(e,n){var t=null;if(!e){var a=D.get(i._iid).BaseChannel;t={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}}r(e,t)}))}),r)}},{key:"getMessageChangeLogsByToken",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:null,token:e,isOpenChannel:i.isOpenChannel(),includeMetaArray:n,includeReactions:t},(function(e,n){var t=null;if(!e){var a=D.get(i._iid).BaseChannel;t={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}}r(e,t)}))}),r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.BaseChannel,s=i.MessageChangeLogsParams,o=null,u=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:s}),new re({type:"callback"})]),c=A(u,4);return o=c[0],e=c[1],n=c[2],t=c[3],ye(this._iid,(function(t){o?t(o,null):M.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,ts:null,token:e,isOpenChannel:r.isOpenChannel()},n),(function(e,n){var i=null;e||(i={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}),t(e,i)}))}),t)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.BaseChannel,s=i.MessageChangeLogsParams,o=null,u=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:s}),new re({type:"callback"})]),c=A(u,4);return o=c[0],e=c[1],n=c[2],t=c[3],ye(this._iid,(function(t){o?t(o,null):M.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,timestamp:e,token:null,isOpenChannel:r.isOpenChannel()},n),(function(e,n){var i=null;e||(i={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}),t(e,i)}))}),t)}},{key:"getMyMutedInfo",value:function(e){var n=this;return ye(this._iid,(function(e){var t=$n.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 r=null;n||(r={isMuted:t.is_muted,startAt:t.start_at,endAt:t.end_at,remainingDuration:t.remaining_duration,description:t.description}),e(n,r)}))}),e)}},{key:"_parseMessageListParams",value:function(e){for(var n=D.get(this._iid),t=n.MessageListParams,r=new t,i=null,a=!1,s=0,o=0,l=!1,u="",c="",d=null,h=!1,p=!1,f=null,g=arguments.length,y=new Array(g>1?g-1:0),_=1;_=0}}),new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"array"})]),8);i.error=a[0],i.file=a[1],i.name=a[2],i.type=a[3],i.size=a[4],i.data=a[5],i.customType=a[6],i.thumbnailSizes=a[7]}else i.error=re.error;return X.isFile(i.file)&&(i.name=i.name||i.file.name,i.type=i.type||i.file.type,i.size=i.size||i.file.size),i}},{key:"_createTempFileMessage",value:function(e){try{var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.Command,i=t.FileMessage,a=i.objectify(l(l({},e),{},{messageId:0,reqId:r.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 i(a)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this._parseFileMessageArguments(re.toArray(arguments)),n=D.get(this._iid),t=n.Command,r=null,i=t.generateRequestId();e.error||((r=this._createTempFileMessage(e)).requestedMentionUserIds=e.mentionedUserIds,i=r.reqId);var a=$n.getInstance(this._iid);a&&a.currentUser||(e.error=new L("Connection should be made first.",L.CONNECTION_REQUIRED));var s=D.get(this._iid),o=s.FileMessageQueue,l=o.create(this);return l.addJob(new o.Job({fileInfo:e,pendingMessage:r,requestId:i,error:e.error,response:null})),r}},{key:"sendFileMessages",value:function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.progress?t.progress:function(){},i=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,r,(function(n,t){i(n,t),o===e.length-1&&a(null)})))})),s}return a(re.error),null}},{key:"resendFileMessage",value:function(e,n,t){var r=this,i=D.get(this._iid),a=i.FileMessage,s=i.FileMessageParams,o=null,l=re.parse(arguments,[new re({type:a,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===r.url&&"string"==typeof e.data&&"string"==typeof e.customType&&Array.isArray(e.thumbnails)}}),new re({type:"file",optionalIf:function(e){return!!e[0].url},defaultValue:null}),new re({type:"callback"})]),u=A(l,4);return o=u[0],e=u[1],n=u[2],t=u[3],ye(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 i=new s;e.url?i.fileUrl=e.url:i.file=n,i.fileName=e.name,i.fileSize=e.size,i.mimeType=e.type,i.data=e.data,i.customType=e.customType,i.mentionType=e.mentionType,i.mentionedUserIds=e.requestedMentionUserIds,i.metaArrays=e.metaArrays,i.thumbnailSizes=e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),i.appleCriticalAlertOptions=e.appleCriticalAlertOptions,r.sendFileMessage(i,t)}}),t)}},{key:"updateFileMessage",value:function(e,n,t,r){var i=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=re.parse(c,[new re({type:"number"}),new re({type:u}),new re({type:"callback"})]),f=A(p,4);d=f[0],e=f[1],h=f[2],r=f[3],h&&(h._isUpdate=!0);break;case 4:h=new u;var g=re.parse(c,[new re({type:"number"}),new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"callback"})]),y=A(g,5);d=y[0],e=y[1],n=y[2],t=y[3],r=y[4],h.data=n,h.customType=t,h._isUpdate=!0}return ye(this._iid,(function(n){if(!d&&h&&h._validate()){var t=s.bUpdateFileMessage(l(l({channelUrl:i.url,messageId:e},h),{},{mentionType:h._mentionType,mentionedUserIds:h._mentionedUserIds})),r=$n.getInstance(i._iid);r.sendCommand(t,(function(e,t){if(r.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}var a=null;t||(a=new o(e.getJsonElement())),n(t,a)}))}else n(re.error,null)}),r)}},{key:"cancelUploadingFileMessage",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:["number","string"]}),new re({type:"callback"})]),i=A(r,3);t=i[0],e=i[1],n=i[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 r=this,i=$n.getInstance(this._iid),a=D.get(this._iid),s=a.ReactionEvent,o=null,u=re.parse(arguments,[new re({type:ve}),new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),c=A(u,4);return o=c[0],e=c[1],n=c[2],t=c[3],ye(this._iid,(function(t){o?t(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?M.get(r._iid).container.apiClient.addReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:n},(function(n,r){var i=null;n||(i=s.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),t(n,i)})):t(new L("Cannot add reaction to a non-succeeded message.",L.REQUEST_FAILED),null)}),t)}},{key:"deleteReaction",value:function(e,n,t){var r=this,i=$n.getInstance(this._iid),a=D.get(this._iid),s=a.ReactionEvent,o=null,u=re.parse(arguments,[new re({type:ve}),new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),c=A(u,4);return o=c[0],e=c[1],n=c[2],t=c[3],ye(this._iid,(function(t){o?t(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?M.get(r._iid).container.apiClient.deleteReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:n},(function(n,r){var i=null;n||(i=s.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),t(n,i)})):t(new L("Cannot remove reaction to a non-succeeded message.",L.REQUEST_FAILED),null)}),t)}},{key:"deleteMessage",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r){var i=D.get(this._iid);i.Command;var a=i.UserMessage,s=i.BaseMessageParams,o=null,u=re.parse(arguments,[new re({type:e}),new re({type:a}),new re({type:"callback"})]),c=A(u,4);o=c[0],n=c[1],t=c[2],r=c[3];var d=M.get(this._iid),h=d.container.isErrorFirstInCallback;if(o)return h?r(re.error,null):r(null,re.error),null;if(this.url!==t.channelUrl){var p=new L("The message does not belong to this channel",L.INVALID_PARAMETER);return h?r(p,null):r(null,p),null}var f={},g=Object.keys(t.translations);g.forEach((function(e){return f[e]=""}));var y=s.PushNotificationDeliveryOption.DEFAULT;return n._sendUserMessage(l(l({},t),{},{reqId:null,pushNotificationDeliveryOption:y,translationTargetLanguages:g,rootMessageId:null,parentMessageId:null,parentMessageText:null,callback:r}))}},{key:"copyFileMessage",value:function(n,t,r){var i=D.get(this._iid),a=i.Command;i.GroupChannel;var s=i.FileMessage,o=i.BaseMessageParams;i.FileMessageParams;var l=i.User,u=null,c=re.parse(arguments,[new re({type:e}),new re({type:s}),new re({type:"callback"})]),d=A(c,4);u=d[0],n=d[1],t=d[2],r=d[3];var h=M.get(this._iid),p=h.container.isErrorFirstInCallback;if(u)return p?r(re.error,null):r(null,re.error),null;if(this.url!==t.channelUrl){var f=new L("The message does not belong to this channel");return p?r(f,null):r(null,f),null}var g=$n.getInstance(this._iid),y=t,_=y.url,m=y.name,v=y.type,C=y.size,E=y.data,U=y.customType,b=y.mentionType,S=y.mentionedUserIds,I=y.mentionedUsers,N=y.metaArrays,k=y.thumbnails,R=y.requireAuth,O=y.messageSurvivalSeconds,T=y.silent,P=y.appleCriticalAlertOptions,w=a.generateRequestId(),H=g.currentUser||{},F=n.url,G=n.isOpenChannel(),B=I.filter((function(e){return new l(l.objectify(e))})),j=o.PushNotificationDeliveryOption.DEFAULT,x=s.objectify({messageId:0,reqId:w,user:H,channel:n,plainUrl:_,name:m,type:v,size:C,data:E,customType:U,mentionType:b,mentionedUserIds:S,mentionedUsers:B,requestedMentionUserIds:S,metaArrays:N,thumbnails:k,requireAuth:R,messageSurvivalSeconds:O,silent:T,createdAt:(new Date).getTime(),appleCriticalAlertOptions:P}),q=new s(x);if(q.requestState=g.MessageRequestState.PENDING,q.sendingStatus=g.MessageSendingStatus.PENDING,!g.currentUser){var z=new L("Connection should be made first.",L.CONNECTION_REQUIRED),Q=new s(x);return Q.requestState=g.MessageRequestState.FAILED,Q.sendingStatus=g.MessageSendingStatus.FAILED,Q.errorCode=z.code,p?r(z,Q):r(Q,z),q}var Y=a.bFile({requestId:w,channelUrl:F,url:_,name:m,type:v,size:C,data:E,customType:U,metaArrays:N,mentionType:b,mentionedUserIds:S,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:j,silent:T,appleCriticalAlertOptions:P});return g.getConnectionState()===g.ConnectionState.OPEN||g.connecting||g.reconnecting?g.sendCommand(Y,(function(e,t){if(g.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[1]}if(t)if(t.code!==L.INVALID_PARAMETER){var a=new s(x);a.requestState=g.MessageRequestState.FAILED,a.sendingStatus=g.MessageSendingStatus.FAILED,t.code!==L.FILE_UPLOAD_CANCEL_FAILED&&t.code!==SendBridException.REQUEST_CANCELED||(a.sendingStatus=g.MessageSendingStatus.CANCELED),a.errorCode=t.code,p?r(t,a):r(a,t)}else p?r(t,null):r(null,t);else{var o=new s(e.getJsonElement()),l=o._sender;if(H&&l&&H.userId===l.userId&&(H.nickname!==l.nickname&&(H.nickname=l.nickname),H.plainProfileUrl!==l.plainProfileUrl&&(H.plainProfileUrl=l.plainProfileUrl)),n.isGroupChannel())for(var u in n.lastMessage=o,g.channelHandlers){g.channelHandlers[u].onChannelChanged(n)}p?r(null,o):r(o,null)}})):h.container.apiClient.sendFileMessage({channelUrl:F,isOpenChannel:G,fileUrl:_,fileName:m,fileType:v,fileSize:C,data:E,customType:U,metaArrays:N,mentionType:b,mentionedUserIds:S,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:j,appleCriticalAlertOptions:P},(function(e,t){if(e)if(e.code!==L.INVALID_PARAMETER){var i=new s(commnad.getJsonElement());i.requestState=g.MessageRequestState.FAILED,i.sendingStatus=g.MessageSendingStatus.FAILED,e.code!==L.FILE_UPLOAD_CANCEL_FAILED&&e.code!==SendBridException.REQUEST_CANCELED||(i.sendingStatus=g.MessageSendingStatus.CANCELED),i.errorCode=e.code,p?r(e,i):r(i,e)}else p?r(e,null):r(null,e);else{var a=new s(t),o=a._sender;if(H&&o&&H.userId===o.userId&&(H.nickname!==o.nickname&&(H.nickname=o.nickname),H.plainProfileUrl!==o.plainProfileUrl&&(H.plainProfileUrl=o.plainProfileUrl)),n.isGroupChannel())for(var l in n.lastMessage=a,g.channelHandlers){g.channelHandlers[l].onChannelChanged(n)}p?r(null,a):r(a,null)}})),q}},{key:"addOperators",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({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 re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateMetaCounters({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaCounter:e,upsert:n,mode:"set"},(function(e,n){return t(e,n)}))}),t)}},{key:"increaseMetaCounters",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.updateMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),metaCounter:e,upsert:!1,mode:"decrease"},(function(e,t){var r=null;if(!e)for(var i in r={},t)r[i]=t[i];n(e,r)}))}),n)}},{key:"deleteMetaCounter",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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=Ue.get(this),n={};return Object.keys(e).forEach((function(t){var r=e[t];r.isRemoved||(n[t]=r.value)})),n}},{key:"getMetaData",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return Object.keys(e).map((function(n){return e[n]})).every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateMetaData({channelUrl:r.url,isOpenChannel:r.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,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r){var i=this;return ye(this._iid,(function(r){var a=D.get(i._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=$n.getInstance(i._iid);d.sendCommand(c,(function(e,t){if(d.getErrorFirstCallback()){var i=[e,t];t=i[0],e=i[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()))),r(t,a)}))}else r(re.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,n,t){var r=D.get(this._iid),i=r.MessageMetaArray,a=null,s=re.parse(arguments,[new re({type:ve}),new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(this._iid,(function(e){e(a,null)}),t);var l=[];if(Array.isArray(n))for(var u=0;u0&&e.every((function(e){return e instanceof i}))||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 re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(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 r=D.get(this._iid),i=r.MessageMetaArray,a=null,s=re.parse(arguments,[new re({type:ve}),new re({type:"object",constraint:function(e){return e&&(Array.isArray(e)&&e.length>0&&e.every((function(e){return e instanceof i}))||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 re({type:"callback"})]),o=A(s,4);if(a=o[0],e=o[1],n=o[2],t=o[3],a)return ye(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 r=this,i=D.get(this._iid),a=i.BaseChannel,s=null,o=re.parse(arguments,[new re({type:a.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),l=A(o,4);return s=l[0],e=l[1],n=l[2],t=l[3],ye(this._iid,(function(t){if(s)t(s,null);else{var i=$n.getInstance(r._iid);M.get(r._iid).container.apiClient.report({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),reportCategory:e,reportingUserId:i.currentUser?i.currentUser.userId:null,reportDescription:n},(function(e,n){t(e,null)}))}}),t)}},{key:"reportUser",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:Ce}),new re({type:s.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=$n.getInstance(i._iid);M.get(i._iid).container.apiClient.reportUser({channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:n,offendingUserId:e.userId,reportingUserId:a.currentUser?a.currentUser.userId:null,reportDescription:t},(function(e,n){r(e,null)}))}}),r)}},{key:"reportMessage",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:ve}),new re({type:s.ReportCategory}),new re({type:"string"}),new re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(o)r(o,null);else{var a=$n.getInstance(i._iid);M.get(i._iid).container.apiClient.reportMessage({messageId:e.messageId,channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:n,offendingUserId:e.sender.userId,reportingUserId:a.currentUser?a.currentUser.userId:null,reportDescription:t},(function(e,n){r(e,null)}))}}),r)}}],[{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),r=t.UserMessage,i=t.FileMessage,a=t.AdminMessage;if(e)switch(e.hasOwnProperty("channel_type")||(e.channel_type=n.channelType),e.type){case"MESG":return new r(e);case"FILE":var s=e.file;return new i(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):be.CHANNEL_TYPE_GROUP)}return h(e,[{key:"isGroupChannel",value:function(){return this.channelType===be.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===be.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 Se=function e(n){c(this,e),n&&(this.category=n.hasOwnProperty("cat")?parseInt(n.cat):0)};Se.CATEGORY_USER_BLOCK=20001,Se.CATEGORY_USER_UNBLOCK=2e4,Se.CATEGORY_FRIEND_DISCOVERED=20900;var Ie=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,r=t.Command,i=t.User,a=t.Member,s=t.BaseChannel,o=t.GroupChannel,l=t.OpenChannel,c=t.UserMessage,d=t.FileMessage,h=t.AdminMessage,p=t.BaseMessageParams,f=t.ReactionEvent,g=t.ReadStatus,y=t.ThreadInfoUpdateEvent,_=M.get(this.sb._iid),m=_.container,v=m.pinger,C=m.auth,E=m.subscribedUnreadMessageCount,U=m.sessionManager,b=m.ackStateMap,A=new r(e),S=A.getJsonElement();if(S.hasOwnProperty("unread_cnt")&&"object"===u(S.unread_cnt)){var I=!1,N=S.unread_cnt.ts;if("number"==typeof N&&N>E.ts){if(E.all!==S.unread_cnt.all&&(I=!0),E.all=S.unread_cnt.all>=0?S.unread_cnt.all:0,S.unread_cnt.custom_types)for(var O in S.unread_cnt.custom_types)E.custom_types[O]!==S.unread_cnt.custom_types[O]&&(I=!0),E.custom_types[O]=S.unread_cnt.custom_types[O];I=I&&E.ts>0,E.ts=N}if(I)for(var T in this.sb.userEventHandlers)this.sb.userEventHandlers[T].onTotalUnreadMessageCountUpdated(E.all,E.custom_types)}var P=A.requestId;if(P){var w=b[P];if(w){clearTimeout(w.timer);var D=w.handler;D&&("EROR"===A.command?D(new L(S.message,S.code),null):D(null,A)),b.hasOwnProperty(P)&&delete b[P]}}else switch(v&&"LOGI"!==A.command&&v.refreshTimer(),A.command){case"LOGI":this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,S.hasOwnProperty("error")?(this.sb.isSessionOpened=!1,this.sb.loginHandler(new L(S.message,S.code),null)):(this.sb.isSessionOpened=!0,S.hasOwnProperty("key")&&(C.sessionKey=S.key),S.hasOwnProperty("ekey")&&(C.eKey=S.ekey),S.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(S)),"number"==typeof S.ping_interval&&S.ping_interval>0&&_.set("pingInterval",1e3*S.ping_interval),"number"==typeof S.pong_timeout&&S.pong_timeout>0&&_.set("pongTimeout",1e3*S.pong_timeout),"number"==typeof S.login_ts&&_.set("connectedAt",1e3*S.login_ts),"number"==typeof S.max_unread_cnt_on_super_group?_.set("maxUnreadCountOfSuperGroupChannel",S.max_unread_cnt_on_super_group):_.set("maxUnreadCountOfSuperGroupChannel",R.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),S.profile_image_encryption&&_.set("profileImageEncryption",!0),v&&v.start(),S.hasOwnProperty("file_upload_size_limit")&&S.hasOwnProperty("premium_feature_list")&&S.hasOwnProperty("emoji_hash")&&_.set("appInfo",new he(S)),this.sb.loginHandler(null,this.sb.currentUser)),this.sb.connecting=!1,this.sb.reconnecting=!1);break;case"EXPR":S.hasOwnProperty("expires_in")&&"number"==typeof S.expires_in&&S.expires_in>0&&U.refresh((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var H=null;if("MESG"===A.command?H=new c(S):"FILE"===A.command?H=new d(S):"BRDM"!==A.command&&"ADMM"!==A.command||(H=new h(S)),H){var F=this.sb.currentUser?this.sb.currentUser.userId:null,G=H.silent,B=!!S.force_update_last_message,j=H._sender&&H._sender.userId===F;if(H.isGroupChannel()){var x=r.bMessageAck({channelUrl:H.channelUrl,messageId:H.messageId});this.sb.sendCommand(x);var q=o.cachedChannels.hasOwnProperty(H.channelUrl);o.getChannel(H.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t){if(e.isHidden=!1,e.hiddenState=o.HiddenState.UNHIDDEN,o.cachedChannels[e.url]=e,H._sender&&e.memberMap.hasOwnProperty(H._sender.userId)){var i=e.memberMap[H._sender.userId];i.nickname!==H._sender.nickname&&(i.nickname=H._sender.nickname),i.plainProfileUrl!==H._sender.plainProfileUrl&&(i.plainProfileUrl=H._sender.plainProfileUrl),X.deepEqual(i.metaData,H._sender.metaData)||(i.metaData=H._sender.metaData),i.isBlockedByMe!==H._sender.isBlockedByMe&&(i.isBlockedByMe=H._sender.isBlockedByMe)}var a=n.sb.currentUser;a&&j&&(a.nickname!==H._sender.nickname&&(a.nickname=H._sender.nickname),a.plainProfileUrl!==H._sender.plainProfileUrl&&(a.plainProfileUrl=H._sender.plainProfileUrl),X.deepEqual(a.metaData,H._sender.metaData)||(a.metaData=H._sender.metaData));var s=!1;if(H.mentionType===p.MentionType.CHANNEL)j||(s=!0);else if(H.mentionType===p.MentionType.USERS)for(var l=0;l=z.createAt,s=n.sb.currentUser;s&&W&&(s.nickname!==z._sender.nickname&&(s.nickname=z._sender.nickname),s.plainProfileUrl!==z._sender.plainProfileUrl&&(s.plainProfileUrl=z._sender.plainProfileUrl),X.deepEqual(s.metaData,z._sender.metaData)||(s.metaData=z._sender.metaData));var o=!1,l=!1;if(!W&&!a&&S&&S.hasOwnProperty("old_values")){var u=S.old_values.mention_type||z.mentionType,c=S.old_values.mentioned_user_ids||z.mentionedUsers.map((function(e){return e.userId}));if(u===p.MentionType.USERS&&z.mentionType===p.MentionType.USERS){for(var d=!1,h=!1,f=0;f0||e.unreadMentionCount>0)for(var i in e._setGroupChannelUnreadCount(0,0),n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelChanged(e)}}else if(0===e.unreadMessageCount||0===e.unreadMentionCount)for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelChanged(e)}}else for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onReadReceiptUpdated(e)}}));break;case"MRCT":var te=String(S.channel_type),re=String(S.channel_url),ie=f.createFromJson(S);switch(te){case s.CHANNEL_TYPE_GROUP:o.getChannel(re,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"));else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onReactionUpdated(e,ie)}}));break;case s.CHANNEL_TYPE_OPEN:l.getChannel(re,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"));else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onReactionUpdated(e,ie)}}))}break;case"DLVR":var ae=String(S.channel_url),se=S.hasOwnProperty("updated")?S.updated:null,oe=o.cachedChannels.hasOwnProperty(ae);o.getChannel(ae,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t){var i=!1;for(var a in se)n.sb.currentUser&&a===n.sb.currentUser.userId&&(i=!0),oe&&e.updateDeliveryReceipt(a,parseInt(se[a]));if(o.cachedChannels[e.url]=e,!i||1!==Object.keys(se).length)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onDeliveryReceiptUpdated(e)}}}));break;case"MTHD":var le=String(S.channel_url),ue=String(S.channel_type),ce=y.createFromJson(S);switch(ue){case s.CHANNEL_TYPE_GROUP:o.getChannel(le,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onThreadInfoUpdated(e,ce)}}));break;case s.CHANNEL_TYPE_OPEN:l.getChannel(le,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(!t)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onThreadInfoUpdated(e,ce)}}))}break;case"MCNT":if(S.hasOwnProperty("group_channels")&&Array.isArray(S.group_channels)){var de,pe=[],fe=k(S.group_channels);try{for(fe.s();!(de=fe.n()).done;){var ge=de.value;if(ge){ge.hasOwnProperty("joined_member_count")&&ge.joined_member_count,ge.hasOwnProperty("member_count")&&ge.member_count;var ye=o.cachedChannels[ge.channel_url];if(ye&&ye.isBroadcast)ye.setLatestMemberCount(ge.member_count,ge.joined_member_count,ge.ts)&&pe.push(ye)}}}catch(e){fe.e(e)}finally{fe.f()}if(pe.length>0)for(var _e in this.sb.channelHandlers){this.sb.channelHandlers[_e].onChannelMemberCountChanged(pe)}}if(S.hasOwnProperty("open_channels")&&Array.isArray(S.open_channels)){var me,ve=[],Ce=k(S.open_channels);try{for(Ce.s();!(me=Ce.n()).done;){var Ee=me.value;if(Ee){Ee.hasOwnProperty("participant_count")&&Ee.participant_count;var Ue=l.cachedChannels[Ee.channel_url];if(Ue)Ue.setLatestParticipantCount(Ee.participant_count,Ee.ts)&&ve.push(Ue)}}}catch(e){Ce.e(e)}finally{Ce.f()}if(ve.length>0)for(var be in this.sb.channelHandlers){this.sb.channelHandlers[be].onChannelParticipantCountChanged(ve)}}break;case"SYEV":var Ie=new Ae(S),Ne=S.ts;switch(Ie.category){case Ae.CATEGORY_CHANNEL_JOIN:case Ae.CATEGORY_CHANNEL_LEAVE:o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var s=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,l=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null,u=!1;if(Ie.category===Ae.CATEGORY_CHANNEL_JOIN){(Ie.data.hasOwnProperty("users")?Ie.data.users:[Ie.data]).forEach((function(t){e.isSuper||e.isBroadcast?u=e.setLatestMemberCount(s,l,S.ts):(t.state=a.JOINED,e.addMember(new a(t),Ne),e.updateJoinedMemberCount());var r=new i(t);for(var c in n.sb.currentUser&&r.userId===n.sb.currentUser.userId&&(e.myMemberState="joined",o.cachedChannels[e.url]=e),n.sb.channelHandlers){var d=n.sb.channelHandlers[c];d.onUserJoined(e,r),e.isBroadcast&&u&&d.onChannelMemberCountChanged([e])}}))}else{var c=new i(Ie.data);for(var d in n.sb.currentUser&&c.userId===n.sb.currentUser.userId?(e.isPublic||o.removeCachedChannel(Ie.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)):o.cachedChannels[e.url]=e,e.isSuper||e.isBroadcast?u=e.setLatestMemberCount(s,l,S.ts):(e.removeMember(c),e.updateJoinedMemberCount()),n.sb.channelHandlers){var h=n.sb.channelHandlers[d];h.onUserLeft(e,c),e.isBroadcast&&u&&h.onChannelMemberCountChanged([e])}}}}));break;case Ae.CATEGORY_CHANNEL_OPERATOR_UPDATE:Ie.isGroupChannel()?o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=Ie.data.operators.map((function(e){return new i(e)})),s=a.map((function(e){return e.userId}));for(var l in e.members)e.members[l].role=s.indexOf(e.members[l].userId)>=0?o.Role.OPERATOR:o.Role.NONE;for(var u in e.myRole=n.sb.currentUser&&s.indexOf(n.sb.currentUser.userId)>=0?o.Role.OPERATOR:o.Role.NONE,n.sb.channelHandlers){n.sb.channelHandlers[u].onOperatorUpdated(e,a)}}})):Ie.isOpenChannel()&&l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else for(var a in e.operators=Ie.data.operators.map((function(e){return new i(e)})),n.sb.channelHandlers){n.sb.channelHandlers[a].onOperatorUpdated(e,e.operators)}}));break;case Ae.CATEGORY_CHANNEL_INVITE:o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var s=null;Ie.data&&Ie.data.inviter&&Object.keys(Ie.data.inviter).length>0&&(s=new i(Ie.data.inviter));for(var l=[],u=0;u0&&(a=new i(Ie.data.inviter));var s=new i(Ie.data.invitee);if(n.sb.currentUser&&s.userId===n.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||o.removeCachedChannel(Ie.channelUrl)),e.isSuper||e.isBroadcast){var l=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,u=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null;e.setLatestMemberCount(l,u,S.ts)}else e.removeMember(s);for(var c in n.sb.currentUser&&s.userId!==n.sb.currentUser.userId&&(o.cachedChannels[e.url]=e),n.sb.channelHandlers){n.sb.channelHandlers[c].onUserDeclinedInvitation(e,a,s)}}}));break;case Ae.CATEGORY_TYPING_START:case Ae.CATEGORY_TYPING_END:o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);for(var s in Ie.category===Ae.CATEGORY_TYPING_START?e.updateTypingStatus(a,!0):e.updateTypingStatus(a,!1),n.sb.channelHandlers){n.sb.channelHandlers[s].onTypingStatusUpdated(e)}}}));break;case Ae.CATEGORY_CHANNEL_ENTER:case Ae.CATEGORY_CHANNEL_EXIT:l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=Ie.data.hasOwnProperty("participant_count")?Ie.data.participant_count:null,s=e.setLatestParticipantCount(a,S.ts),o=new i(Ie.data);if(Ie.category===Ae.CATEGORY_CHANNEL_ENTER)for(var l in n.sb.channelHandlers){var u=n.sb.channelHandlers[l];u.onUserEntered(e,o),s&&u.onChannelParticipantCountChanged([e])}else for(var c in n.sb.channelHandlers){var d=n.sb.channelHandlers[c];d.onUserExited(e,o),s&&d.onChannelParticipantCountChanged([e])}}}));break;case Ae.CATEGORY_USER_CHANNEL_MUTE:case Ae.CATEGORY_USER_CHANNEL_UNMUTE:Ie.isOpenChannel()?l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserMuted(e,a)}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnmuted(e,a)}}})):o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId&&(e.myMutedState=Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE?"muted":"unmuted"),Array.isArray(e.members)&&e.members.forEach((function(e){e&&e.userId===a.userId&&(e.isMuted=Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)})),Ie.category===Ae.CATEGORY_USER_CHANNEL_MUTE)for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserMuted(e,a)}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnmuted(e,a)}}}));break;case Ae.CATEGORY_USER_CHANNEL_BAN:case Ae.CATEGORY_USER_CHANNEL_UNBAN:Ie.isOpenChannel()?l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_BAN){if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId)delete l.enteredChannels[Ie.channelUrl],n.cls.FileMessageQueue.delete(Ie.channelUrl);for(var s in n.sb.channelHandlers){n.sb.channelHandlers[s].onUserBanned(e,a)}}else for(var o in n.sb.channelHandlers){n.sb.channelHandlers[o].onUserUnbanned(e,a)}}})):o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var a=new i(Ie.data);if(Ie.category===Ae.CATEGORY_USER_CHANNEL_BAN){if(n.sb.currentUser&&a.userId===n.sb.currentUser.userId&&(e.isPublic||o.removeCachedChannel(Ie.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var s=Ie.data.hasOwnProperty("member_count")?Ie.data.member_count:null,l=Ie.data.hasOwnProperty("joined_member_count")?Ie.data.joined_member_count:null;e.setLatestMemberCount(s,l,S.ts)}else e.removeMember(a),e.updateJoinedMemberCount();for(var u in n.sb.channelHandlers){n.sb.channelHandlers[u].onUserBanned(e,a)}}else for(var c in n.sb.channelHandlers){n.sb.channelHandlers[c].onUserUnbanned(e,a)}}}));break;case Ae.CATEGORY_CHANNEL_FREEZE:case Ae.CATEGORY_CHANNEL_UNFREEZE:Ie.isOpenChannel()?l.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(e.isFrozen=Ie.data.freeze,l.cachedChannels[e.url]=e,Ie.category===Ae.CATEGORY_CHANNEL_FREEZE)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelFrozen(e)}else for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelUnfrozen(e)}})):o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(e.isFrozen=Ie.data.freeze,o.cachedChannels[e.url]=e,Ie.category===Ae.CATEGORY_CHANNEL_FREEZE)for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelFrozen(e)}else for(var a in n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelUnfrozen(e)}}));break;case Ae.CATEGORY_CHANNEL_DELETED:for(var ke in Ie.isGroupChannel()?o.removeCachedChannel(Ie.channelUrl):l.removeCachedChannel(Ie.channelUrl),this.sb.channelHandlers){this.sb.channelHandlers[ke].onChannelDeleted(Ie.channelUrl,Ie.isGroupChannel()?"group":"open")}break;case Ae.CATEGORY_CHANNEL_PROP_CHANGED:Ie.isOpenChannel()?l.getChannelWithoutCache(Ie.channelUrl,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else for(var i in n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelChanged(e)}})):o.getChannelWithoutCache(Ie.channelUrl,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else{var i=e.unreadMessageCount,a=e.unreadMentionCount;for(var s in e.myCountPreference!==o.CountPreference.ALL&&(e.myCountPreference===o.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?a=0:e.myCountPreference===o.CountPreference.UNREAD_MENTION_COUNT_ONLY?i=0:(i=0,a=0)),e._setGroupChannelUnreadCount(i,a),n.sb.channelHandlers){n.sb.channelHandlers[s].onChannelChanged(e)}}}));break;case Ae.CATEGORY_CHANNEL_META_DATA_CHANGED:case Ae.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var Re=Ie.data.hasOwnProperty("created"),Oe=Ie.data.hasOwnProperty("updated"),Te=Ie.data.hasOwnProperty("deleted");(Ie.isOpenChannel()?l.getChannel(Ie.channelUrl,R.INTERNAL_CALL):o.getChannel(Ie.channelUrl,R.INTERNAL_CALL)).then((function(e){var t=Ie.data.created,r=Ie.data.updated,i=Ie.data.deleted,a=S.ts;for(var s in Re&&e._addOrUpdateCachedMetaData(t,a),Oe&&e._addOrUpdateCachedMetaData(r,a),Te&&e._markAsDeletedCachedMetaData(i,a),n.sb.channelHandlers){var o=n.sb.channelHandlers[s];Ie.category===Ae.CATEGORY_CHANNEL_META_DATA_CHANGED?(Re&&o.onMetaDataCreated(e,t),Oe&&o.onMetaDataUpdated(e,r),Te&&o.onMetaDataDeleted(e,i)):(Re&&o.onMetaCountersCreated(e,t),Oe&&o.onMetaCountersUpdated(e,r),Te&&o.onMetaCountersDeleted(e,i))}})).catch((function(e){return Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category)}));break;case Ae.CATEGORY_CHANNEL_HIDE:case Ae.CATEGORY_CHANNEL_UNHIDE:o.getChannel(Ie.channelUrl,R.INTERNAL_CALL,(function(e,t){if(n.sb.getErrorFirstCallback()){var r=[e,t];t=r[0],e=r[1]}if(t)Y.debug("Discard command:","`".concat(A.command,"`"),Ie.category);else if(Ie.category===Ae.CATEGORY_CHANNEL_HIDE)for(var i in e.isHidden=!0,Ie.data&&(Ie.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=Ie.data.allow_auto_unhide?o.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:o.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),Ie.data.hasOwnProperty("hide_previous_messages")&&Ie.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),S.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=S.ts_message_offset),o.cachedChannels[e.url]=e,n.sb.channelHandlers){n.sb.channelHandlers[i].onChannelHidden(e)}else for(var a in e.isHidden=!1,e.hiddenState=o.HiddenState.UNHIDDEN,o.cachedChannels[e.url]=e,n.sb.channelHandlers){n.sb.channelHandlers[a].onChannelChanged(e)}}))}break;case"USEV":var Me=new Ae(S);switch(Me.category){case Se.CATEGORY_USER_BLOCK:case Se.CATEGORY_USER_UNBLOCK:var Le=Me.data.blocker.user_id,Pe=Me.data.blockee.user_id;Object.keys(o.cachedChannels).forEach((function(e){var t=o.cachedChannels[e];try{n.sb.currentUser&&(n.sb.currentUser.userId===Le?t.memberMap[Pe].isBlockedByMe=Me.category===Se.CATEGORY_USER_BLOCK:n.sb.currentUser.userId===Pe&&(t.memberMap[Le].isBlockingMe=Me.category===Se.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Se.CATEGORY_FRIEND_DISCOVERED:var we=Me.data.friend_discoveries.map((function(e){return new i(e)}));for(var De in this.sb.userEventHandlers){this.sb.userEventHandlers[De].onFriendsDiscovered(we)}}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:Y.debug("Discard command:","`".concat(A.command,"`"))}}}]),e}(),Ne={},ke={},Re=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(Y.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,r=this.messageQueue[0];if(r)if(r.state===t.State.UPLOADED){if(r&&r.state===t.State.UPLOADED){for(r.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(r,(function(e,i){r.state=t.State.SENT,r.error=e||null,r.response=i||null,n._handleMessageQueueUpdated("update")}))}}else r.state===t.State.SENT&&this._finalizeMessage()}}}},{key:"_handleUploadQueueUpdated",value:function(e,n){var t=this;switch(Y.debug("`fileMessageQueue` upload queue updated:",this.uploadQueue),e){case"add":var r=D.get(this._iid).FileMessageQueue;if(n.state=r.State.UPLOADING,n.error)this.messageQueue.map((function(e){return e.requestId})).indexOf(n.requestId)>-1&&(n.state=r.State.SENT,this._handleMessageQueueUpdated("update")),this._finalizeUpload(n.requestId);else this._uploadFile(n,(function(e){n.error&&n.state===r.State.SENT||(n.state=r.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),r=t.Command,i=t.FileMessage,a=e.fileInfo,s=r.bFile(l(l({},a),{},{requestId:e.requestId,channelUrl:this.channel.url,url:a.file,metaArrays:a.metaArrays})),o=$n.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 r=[e,t];t=r[0],e=r[1]}if(t){var l=new i(s.getJsonElement());l.requestedMentionUserIds=a.mentionedUserIds,n(t,l)}else{var u=new i(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 r=new i(e?s.getJsonElement():t);e&&(r.requestedMentionUserIds=a.mentionedUserIds),n(e,r)}))}},{key:"_uploadFile",value:function(e,n){var t=e.fileInfo,r=e.pendingMessage;if("string"!=typeof t.file&&t.file){var i=D.get(this._iid).FileMessageQueue;M.get(this._iid).container.apiClient.uploadFile(l(l({},t),{},{fileType:t.type,channelUrl:this.channel.url,reqId:r?r.reqId:null}),(function(r,a){if(r)e.state=i.State.SENT,e.error=r,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=M.get(this._iid).container.isErrorFirstInCallback,n=$n.getInstance(this._iid),t=D.get(this._iid).FileMessageQueue,r=this.messageQueue[0];if(r&&r.state===t.State.SENT){r.state=t.State.DONE;var i=r.response,a=r.error,s=r.fileInfo.callback;if(i&&!a){var o=n.currentUser;if(o&&i._sender&&o.userId===i._sender.userId&&(o.nickname!==i._sender.nickname&&(o.nickname=i._sender.nickname),o.plainProfileUrl!==i._sender.plainProfileUrl&&(o.plainProfileUrl=i._sender.plainProfileUrl)),this.channel.isGroupChannel())for(var l in this.channel.lastMessage=i,n.channelHandlers){n.channelHandlers[l].onChannelChanged(this.channel)}return e?s(null,i):s(i,null),this.messageQueue.shift(),void this._handleMessageQueueUpdated("remove")}a&&(i=r.pendingMessage)&&(a.code!==L.INVALID_PARAMETER?(i.requestState=n.MessageRequestState.FAILED,i.sendingStatus=n.MessageSendingStatus.FAILED,a.code!==L.FILE_UPLOAD_CANCEL_FAILED&&a.code!==L.REQUEST_CANCELED||(i.sendingStatus=n.MessageSendingStatus.CANCELED),i.requestedMentionUserIds=r.fileInfo.mentionedUserIds,i.errorCode=a.code):i=null),e?s(a,i):s(i,a),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 r=D.get(this._iid).FileMessageQueue,i=this.messageQueue[t];!i||i.state!==r.State.UPLOADING&&i.state!==r.State.PENDING||(i.state=r.State.SENT,i.response=null,i.error=new L("Uploading has been completed or canceled.",L.FILE_UPLOAD_CANCEL_FAILED),this._handleMessageQueueUpdated("update"));var a=r.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 L("Uploading has been completed or canceled.",L.FILE_UPLOAD_CANCEL_FAILED),!1)}else n(new L("Uploading has been completed or canceled.",L.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(){ke[this._iid]={}}},{key:"queueMap",get:function(){return ke[this._iid]||(ke[this._iid]={}),ke[this._iid]}},{key:"uploadRequest",get:function(){return Ne[this._iid]||(Ne[this._iid]={}),Ne[this._iid]}}]),e}();Re.Job=function(){return function e(n){var t=n.fileInfo,r=n.requestId,i=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=r,this.pendingMessage=i,this.state=a||Re.State.PENDING,this.error=o,this.response=u}}();var Oe=function(){function e(){c(this,e)}return h(e,null,[{key:"create",value:function(){return"".concat(parseInt(1e5*Math.random()),"-").concat((new Date).getTime())}}]),e}(),Te={},Me={},Le=new WeakMap,Pe=new WeakMap,we=new WeakMap,De=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).channelType=be.CHANNEL_TYPE_GROUP,r.isDistinct=!1,r.isSuper=!1,r.isBroadcast=!1,r.isPublic=!1,r.unreadMessageCount=0,r.inviter=null,r.members=[],r.memberMap={},r.lastMessage=null,r.memberCount=0,r.joinedMemberCount=0,r.cachedReadReceiptStatus={},r.cachedDeliveryReceiptStatus=null,r.myPushTriggerOption=t.PushTriggerOption.DEFAULT,r.isPushEnabled,r.isHidden=!1,r.hiddenState=t.HiddenState.UNHIDDEN,r.isDiscoverable=!0,r.myLastRead=0,r.messageSurvivalSeconds=-1,r.invitedAt=0,r.joinedAt=0,r._messageOffsetTimestamp=0,r._cachedLastDeliveredReceipt={sentAt:0,timeout:null},Le.set(C(r),{}),Pe.set(C(r),{start:0,end:0}),we.set(C(r),0),e&&r._update(e),r}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=D.get(this._iid),t=n.BaseChannel,r=n.GroupChannel,i=n.User,a=n.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"))for(var s in this.cachedReadReceiptStatus={},e.read_receipt){var o=e.read_receipt[s];this.updateReadReceipt(s,parseInt(o))}if(e.hasOwnProperty("delivery_receipt")&&"object"===u(e.delivery_receipt)&&null!==e.delivery_receipt)for(var l in this.cachedDeliveryReceiptStatus||(this.cachedDeliveryReceiptStatus={}),e.delivery_receipt){var c=e.delivery_receipt[l];this.updateDeliveryReceipt(l,parseInt(c))}if(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 d=0;d0?this.inviter=new i(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),r=t.Member,i=this.removeMember(e);i&&i.state===r.JOINED&&(e.state=r.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;t0&&e.every((function(e){return!!e.userId&&"string"==typeof e.userId}))}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){return e(re.error,null)}),n):this.inviteWithUserIds(e.map((function(e){return e.userId})),n)}},{key:"inviteWithUserIds",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.inviteToGroupChannel({channelUrl:t.url,userIds:e},(function(e,r){var i=null;e||(i=D.get(t._iid).GroupChannel.upsert(r));n(e,i)}))}),n)}},{key:"acceptInvitation",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.acceptInvitation({channelUrl:t.url,accessCode:e},(function(e,r){var i=null;e||((i=D.get(t._iid).GroupChannel.upsert(r)).myMemberState="joined");n(e,i)}))}),n)}},{key:"declineInvitation",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.declineInvitation({channelUrl:n.url},(function(t,r){var i=null;if(!t){var a=D.get(n._iid).GroupChannel;(i=a.upsert(r)).myMemberState="none",n.isPublic||a.removeCachedChannel(n.url)}e(t,i)}))}),e)}},{key:"join",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.joinGroupChannel({channelUrl:t.url,accessCode:e},(function(e,r){var i=null;e||((i=D.get(t._iid).GroupChannel.upsert(r)).myMemberState="joined");n(e,i)}))}),n)}},{key:"leave",value:function(e){var n=this;return ye(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,r){return this.muteUserWithUserId(e?e.userId:null,n,t,r)}},{key:"muteUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string",optional:!0,defaultValue:""}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!0},(function(e,n){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,n){return this.unmuteUserWithUserId(e?e.userId:null,n)}},{key:"unmuteUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r){return this.banUserWithUserId(e?e.userId:null,n,t,r)}},{key:"banUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string"}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.banUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!0},(function(e,n){r(e,null)}))}),r)}},{key:"unbanUser",value:function(e,n){return this.unbanUserWithUserId(e?e.userId:null,n)}},{key:"unbanUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=!1;return"number"==typeof e&&"number"==typeof n&&"number"==typeof t&&t>=we.get(this)&&(we.set(this,t),r=n!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=n),r}},{key:"hide",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"boolean",optional:!0,defaultValue:!1}),new re({type:"boolean",optional:!0,defaultValue:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.hideGroupChannel({channelUrl:r.url,hidePreviousMessages:e,allowAutoUnhide:n},(function(i,a){if(!i){var s=D.get(r._iid).GroupChannel;r.isHidden=!0,r.hiddenState=n?s.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:s.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,e&&r._setGroupChannelUnreadCount(0,0),a.hasOwnProperty("ts_message_offset")&&(r._messageOffsetTimestamp=a.ts_message_offset),s.cachedChannels[r.url]=r}t(i,a)}))}),t)}},{key:"unhide",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.unhideGroupChannel({channelUrl:n.url},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isHidden=!1,n.hiddenState=i.HiddenState.UNHIDDEN,i.cachedChannels[n.url]=n}e(t,r)}))}),e)}},{key:"freeze",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.freeze({channelUrl:n.url,isGroupChannel:!0,freezing:!0},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isFrozen=!0,i.cachedChannels[n.url]=n}e(t,null)}))}),e)}},{key:"unfreeze",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.freeze({channelUrl:n.url,isGroupChannel:!0,freezing:!1},(function(t,r){if(!t){var i=D.get(n._iid).GroupChannel;n.isFrozen=!1,i.cachedChannels[n.url]=n}e(t,null)}))}),e)}},{key:"delete",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.deleteGroupChannel({channelUrl:n.url},(function(t,r){t||D.get(n._iid).GroupChannel.removeCachedChannel(n.url);e(t,r)}))}),e)}},{key:"markAsRead",value:function(){var e=this,n=D.get(this._iid).Command,t=$n.getInstance(this._iid),r=n.bRead({channelUrl:this.url});t.sendCommand(r,(function(n,r){if(t.getErrorFirstCallback()){var i=[n,r];r=i[0],n=i[1]}if(!r&&t.currentUser&&(e.updateReadReceipt(t.currentUser.userId,n.getJsonElement().ts),e.unreadMessageCount>0||e.unreadMentionCount>0))for(var a in e._setGroupChannelUnreadCount(0,0),t.channelHandlers){t.channelHandlers[a].onChannelChanged(e)}}))}},{key:"getUnreadMemberCount",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid).Member;if(e instanceof ve&&!e.isAdminMessage()&&n.currentUser&&!this.isSuper&&!this.isBroadcast){for(var r=0,i=e.createdAt,a=this.members,s=0;s1&&void 0!==arguments[1]&&arguments[1],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof ve&&!e.isAdminMessage()){for(var r=[],i=0;i=e.createdAt&&r.push(a)}}return r}return[]}},{key:"getUnreadMembers",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof ve&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],t=$n.getInstance(this._iid);if(t.currentUser&&!this.isSuper&&!this.isBroadcast){var r={},i=function(i){if(!n&&i===t.currentUser.userId)return"continue";var a=e.cachedReadReceiptStatus[i],s=e.members.filter((function(e){return e.userId===i}));r[i]={user:s.length>0?s[0]:null,last_seen_at:parseInt(a)}};for(var a in this.cachedReadReceiptStatus)i(a);return r}return{}}},{key:"updateReadReceipt",value:function(e,n){var t=this.cachedReadReceiptStatus[e];if(!t||t9e3)&&(t=1e3);var r=Pe.get(this);if(n-r.start>=t){r.end=0,r.start=n;var i=D.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=$n.getInstance(this._iid),n=(new Date).getTime(),t=e.Options.typingIndicatorThrottle;("number"!=typeof t||t<1e3||t>9e3)&&(t=1e3);var r=Pe.get(this);if(n-r.end>=t){r.start=0,r.end=n;var i=D.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=Le.get(this),n=(new Date).getTime(),t=!1;for(var r in e){n-e[r].ts>=1e4&&(delete e[r],t=!0)}return t}},{key:"getTypingMembers",value:function(){var e=Le.get(this),n=[];for(var t in e){var r=this.memberMap[t];r&&n.push(r)}return n}},{key:"getTypingUsers",value:function(){var e=Le.get(this),n=[];for(var t in e){var r=e[t].user;n.push(r)}return n}},{key:"updateTypingStatus",value:function(e,n){var t=Le.get(this);n?t[e.userId]={user:e,ts:(new Date).getTime()}:delete t[e.userId]}},{key:"isTyping",value:function(){var e=Le.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var t=this,r=D.get(this._iid),i=r.ScheduledUserMessage,a=r.ScheduledUserMessageParams,s=null,o=re.parse(arguments,[new re({type:a,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new re({type:"callback"})]),l=A(o,3);return s=l[0],e=l[1],n=l[2],ye(this._iid,(function(n){s?n(s,null):M.get(t._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:t.url,isOpenChannel:!1},(function(e,r){var a=null;if(!e){a=new i(r);var s=$n.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 ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getMyPushTriggerOption({channelUrl:n.url},(function(t,r){var i=null;if(!t){try{i=r.enable}catch(e){i=!1}n.isPushEnabled=i}e&&e(t,i)}))}),e)}},{key:"setPushPreference",value:function(e,n){var t=this;return ye(this._iid,(function(n){var r=D.get(t._iid).GroupChannel;M.get(t._iid).container.apiClient.setMyPushTriggerOption({channelUrl:t.url,enable:e},(function(e,i){e||(t.isPushEnabled=i.enable,t.isPushEnabled||(t.myPushTriggerOption=r.PushTriggerOption.OFF)),n(e,i)}))}),n)}},{key:"getMyPushTriggerOption",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getMyPushTriggerOption({channelUrl:n.url},(function(r,i){var a=null;if(!r){try{a=i.push_trigger_option||t.PushTriggerOption.DEFAULT}catch(e){Y.debug(e)}n.myPushTriggerOption=a}e(r,a)}))}),e)}},{key:"setMyPushTriggerOption",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.PushTriggerOption}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.setMyPushTriggerOption({channelUrl:t.url,pushTriggerOption:e},(function(e,r){var i=null;if(!e){try{i=r.push_trigger_option}catch(e){Y.debug(e)}t.myPushTriggerOption=i}n(e,i)}))}),n)}},{key:"setMyCountPreference",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.CountPreference}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.setMyCountPreference({channelUrl:t.url,countPreference:e},(function(e,r){var a=null;e||(a=t.myCountPreference=r.count_preference,t._setGroupChannelUnreadCount(t.unreadMessageCount,t.unreadMentionCount),i.cachedChannels[t.url]=t),n(e,a)}))}),n)}},{key:"resetMyHistory",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.resetMyHistory({channelUrl:n.url},(function(t,r){if(!t&&r.hasOwnProperty("ts_message_offset")){var i=D.get(n._iid).GroupChannel;n._messageOffsetTimestamp=r.ts_message_offset,i.cachedChannels[n.url]=n}e(t,r)}))}),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"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return Te[this._iid]||(Te[this._iid]={}),Te[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid),t=n.User,r=n.Member,i=n.GroupChannel,a=n.BaseMessage,s=n.UserMessage,o=n.FileMessage,c=n.AdminMessage,d=ge.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 i({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 r.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 r=n.cachedChannels[t.url];e.last_message=r.lastMessage,e.unread_message_count=r.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,r=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){Te[this._iid]={},D.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,n){var t=null,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,4);if(t=a[0],e=a[1],r=a[2],n=a[3],t)return ye(this._iid,(function(e){e(t,null)}),n);var s=D.get(this._iid),o=s.GroupChannel;return o.cachedChannels[e]?ye(this._iid,(function(n){n(null,o.cachedChannels[e])}),n):o.getChannelWithoutCache(e,r,n)}},{key:"getChannelWithoutCache",value:function(e,n){var t=this,r=null,i=null,a=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),s=A(a,4);return r=s[0],e=s[1],i=s[2],n=s[3],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},(function(e,r){var i=null;e||(i=t.upsert(r)),n(e,i)}))}),n)}},{key:"createDistinctChannelIfNotExist",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannelParams,a=null,s=re.parse(arguments,[new re({type:i,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(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,r){var i=null;if(!e){var a=D.get(t._iid).GroupChannel;i={channel:new a(r),isCreated:r.is_created},a.cachedChannels[i.channel.url]=i.channel}n(e,i)})))}),n)}},{key:"createChannel",value:function(){var e=this,n=re.toArray(arguments),t=void 0;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.GroupChannel,a=r.GroupChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];(r.isPublic||(r.accessCode=null),r._validate())?M.get(e._iid).container.apiClient.createGroupChannel(r,(function(e,n){var r=null;e||(r=new i(n),i.cachedChannels[r.url]=r),t(e,r)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}return t?i.createChannel(s,t):i.createChannel(s)}return ye(this._iid,(function(e){return e(re.error,null)}),t)}},{key:"createChannelWithUserIds",value:function(){var e=re.toArray(arguments),n=void 0;"function"==typeof e[e.length-1]&&(n=e.pop());var t=D.get(this._iid),r=t.GroupChannel,i=t.GroupChannelParams,a=new i;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 ye(this._iid,(function(e){return e(re.error,null)}),n)}return r.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 $n.getInstance(this._iid).getGroupChannelCount(e,n)}},{key:"getUnreadItemCount",value:function(e,n){return $n.getInstance(this._iid).getUnreadItemCount(e,n)}},{key:"getTotalUnreadMessageCount",value:function(){var e=re.toArray(arguments),n="function"==typeof e[e.length-1]?e.pop():null,t=$n.getInstance(this._iid);return t.getTotalUnreadMessageCount.apply(t,S(e).concat([n]))}},{key:"getTotalUnreadChannelCount",value:function(e){return $n.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),t}(be),He=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).state="",r.role="",r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,e&&r._update(e),r}return h(t,[{key:"_update",value:function(e){this.state=e.state,this.role=e.role||De.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me)}},{key:"parse",value:function(e){this._update(e)}}],[{key:"objectify",value:function(e){var n=D.get(this._iid).User,t=e.user,r=e.state,i=e.role,a=void 0===i?"":i,s=e.isMuted,o=void 0!==s&&s,l=e.isBlockedByMe,u=void 0!==l&&l,c=e.isBlockingMe,d=void 0!==c&&c,h=n.objectify(t);return h.state=r,h.role=a,h.is_muted=o,h.is_blocked_by_me=u,h.is_blocking_me=d,h}},{key:"build",value:function(e,n,t,r,i,a){var s=D.get(this._iid).User;return this.objectify({user:new s(e),state:n,role:t,isMuted:r,isBlockedByMe:i,isBlockingMe:a})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).Member,t=ge.deserialize(e);return new n(n.objectify(l({user:t},t)))}},{key:"JOINED",get:function(){return"joined"}},{key:"INVITED",get:function(){return"invited"}}]),t}(Ce),Fe=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).role="",r.isBlockedByMe=!1,e&&r._update(e),r}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,r=e.role,i=void 0===r?"":r,a=e.isBlockedByMe,s=void 0!==a&&a,o=n.objectify(t);return o.role=i,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=ge.deserialize(e);return new n(n.objectify(l({user:t},t)))}}]),t}(Ce),Ge=function(){function e(n){c(this,e),this.emojiHash=null,this.emojiCategories=null,n&&this._update(n)}return h(e,[{key:"_update",value:function(e){var n=D.get(this._iid).EmojiCategory;this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new n(e)})):[]}}]),e}(),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}(),je=function(){function e(n){c(this,e),this.key=null,this.url=null,n&&this._update(n)}return h(e,[{key:"_update",value:function(e){this.key=e.key,this.url=e.url}}]),e}(),xe={},qe={},ze=new WeakMap,Qe=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).channelType=be.CHANNEL_TYPE_OPEN,r.participantCount=0,ze.set(C(r),0),r.operators=[],e&&r._update(e),r}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 ye(this._iid,(function(e){var t=D.get(n._iid).Command.bEnter({channelUrl:n.url}),r=$n.getInstance(n._iid);r.sendCommand(t,(function(t,i){if(r.getErrorFirstCallback()){var a=[t,i];i=a[0],t=a[1]}i?(i=i?new L(i.message,i.code):null,e(i,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 ye(this._iid,(function(e){var t=D.get(n._iid),r=t.Command,i=t.FileMessageQueue,a=r.bExit({channelUrl:n.url}),s=$n.getInstance(n._iid);s.sendCommand(a,(function(t,r){if(s.getErrorFirstCallback()){var a=[t,r];r=a[0],t=a[1]}r?(r=r?new L(r.message,r.code):null,e(r,null)):(delete D.get(n._iid).OpenChannel.enteredChannels[n.url],i.delete(n.url),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,n=re.toArray(arguments),t=null;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.OpenChannel,a=r.OpenChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];(r.channelUrl=e.url,r._validate())?M.get(e._iid).container.apiClient.updateOpenChannel(r,(function(e,n){var r=null;e||(r=i.upsert(n)),t(e,r)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=re.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,S(e).concat([n]));default:return ye(this._iid,(function(e){return e(re.error,null)}),n)}}},{key:"muteUser",value:function(e,n,t,r){return this.muteUserWithUserId(e?e.userId:null,n,t,r)}},{key:"muteUserWithUserId",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"string",optional:!0,defaultValue:""}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:t,seconds:n,isGroupChannel:!1},(function(e,n){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,n){return this.unmuteUserWithUserId(e?e.userId:null,n)}},{key:"unmuteUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 r=this,i=null,a=re.parse(arguments,[new re({type:"string"}),new re({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.banUser({channelUrl:r.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,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.unbanUser({channelUrl:t.url,userId:e,isGroupChannel:!1},(function(e,t){n(e,null)}))}),n)}},{key:"setLatestParticipantCount",value:function(e,n){var t=!1;return"number"==typeof e&&"number"==typeof n&&n>=ze.get(this)&&(ze.set(this,n),t=e!==this.participantCount,this.participantCount=e),t}},{key:"delete",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.deleteOpenChannel({channelUrl:n.url},(function(t,r){t||(delete D.get(n._iid).OpenChannel.cachedChannels[n.url],D.get(n._iid).FileMessageQueue.delete(n.url));e(t,r)}))}),e)}}],[{key:"cachedChannels",get:function(){return xe[this._iid]||(xe[this._iid]={}),xe[this._iid]}},{key:"enteredChannels",get:function(){return qe[this._iid]||(qe[this._iid]={}),qe[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid),t=n.User,r=n.OpenChannel,i=ge.deserialize(e);return new r({channel_url:i.url,name:i.name,cover_url:i.coverUrl,data:i.data,custom_type:i.customType,created_at:i.createdAt/1e3,freeze:i.isFrozen,is_ephemeral:i.isEphemeral,participant_count:i.participantCount,operators:i.operators.map((function(e){return t.objectify(e)}))})}},{key:"getChannel",value:function(e,n){var t=null,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,4);if(t=a[0],e=a[1],r=a[2],n=a[3],t)return ye(this._iid,(function(e){e(t,null)}),n);var s=D.get(this._iid),o=s.OpenChannel;return o.cachedChannels[e]?ye(this._iid,(function(n){n(null,o.cachedChannels[e])}),n):o.getChannelWithoutCache(e,r,n)}},{key:"getChannelWithoutCache",value:function(e,n){var t=this,r=null,i=null,a=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",optional:!0,nullable:!0,defaultValue:null}),new re({type:"callback"})]),s=A(a,4);return r=s[0],e=s[1],i=s[2],n=s[3],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getOpenChannel({channelUrl:e,internalCall:i},(function(e,r){var i=null;e||(i=D.get(t._iid).OpenChannel.upsert(r));n(e,i)}))}),n)}},{key:"createChannel",value:function(){var e=this,n=re.toArray(arguments),t=null;"function"==typeof n[n.length-1]&&(t=n.pop());var r=D.get(this._iid),i=r.OpenChannel,a=r.OpenChannelParams;if(n[0]instanceof a&&1===n.length)return ye(this._iid,(function(t){var r=n[0];r._validate()?M.get(e._iid).container.apiClient.createOpenChannel(r,(function(n,r){var i=null;n||(i=D.get(e._iid).OpenChannel.upsert(r));t(n,i)})):t(re.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 ye(this._iid,(function(e){return e(re.error,null)}),t)}return t?i.createChannel(s,t):i.createChannel(s)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=re.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,S(e).concat([n]));default:return ye(this._iid,(function(e){return e(re.error,null)}),n)}}},{key:"upsert",value:function(e){var n=new(0,D.get(this._iid).OpenChannel)(e);return this.cachedChannels.hasOwnProperty(n.url)?this.cachedChannels[n.url].update(e):this.cachedChannels[n.url]=n,this.cachedChannels[n.url]}},{key:"removeCachedChannel",value:function(e){this.cachedChannels[e]&&delete this.cachedChannels[e],D.get(this._iid).FileMessageQueue.delete(e)}},{key:"clearCache",value:function(){xe[this._iid]={},D.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){qe[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,D.get(this._iid).OpenChannelListQuery)}}]),t}(be),Ye=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_USER,r.message=null,r._sender=null,r.reqId="",r.translations={},r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r.plugins=[],e&&r._update(e),r}return h(t,[{key:"_update",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.Sender,i=t.Plugin;this.message=String(e.message),this._sender=new r(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 i(e)})))}},{key:"sender",get:function(){var e=$n.getInstance(this._iid),n=D.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var t=n.cachedChannels[this.channelUrl];if(t){var r=t.memberMap[this._sender.userId];r&&(this._sender.nickname!==r.nickname&&(this._sender.nickname=r.nickname),this._sender.plainProfileUrl!==r.plainProfileUrl&&(this._sender.plainProfileUrl=r.plainProfileUrl),X.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"isResendable",value:function(){var e=$n.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.BaseChannel,i=t.BaseMessageParams,a=t.Sender,s=t.User,o=t.ThreadInfo,l=t.OGMetaData,u=t.Plugin,c=e.messageId,d=e.reqId,h=void 0===d?"":d,p=e.user,f=e.channel,g=e.message,y=e.data,_=void 0===y?"":y,m=e.customType,v=void 0===m?"":m,C=e.appleCriticalAlertOptions,E=e.mentionType,U=void 0===E?i.MentionType.USERS:E,b=e.mentionedUsers,A=void 0===b?[]:b,S=e.mentionedUserIds,I=void 0===S?[]:S,N=e.requestedMentionUserIds,k=void 0===N?[]:N,R=e.reactions,O=void 0===R?[]:R,T=e.metaArrays,M=void 0===T?[]:T,L=e.rootMessageId,P=void 0===L?0:L,w=e.parentMessageId,H=void 0===w?0:w,F=e.parentMessageText,G=void 0===F?"":F,B=e.threadInfo,j=void 0===B?null:B,x=e.translations,q=void 0===x?{}:x,z=e.sendingStatus,Q=e.errorCode,Y=void 0===Q?0:Q,K=e.silent,W=void 0!==K&&K,V=e.isGlobalBlocked,J=void 0!==V&&V,X=e.messageSurvivalSeconds,Z=void 0===X?-1:X,$=e.ogMetaData,ee=void 0===$?null:$,ne=e.isOperatorMessage,te=void 0!==ne&&ne,re=e.plugins,ie=void 0===re?[]:re,ae=e.createdAt,se=e.updatedAt,oe=void 0===se?0:se,le={};for(var ue in le.req_id=h,le.msg_id=c,le.user=a.objectify({user:p,role:n.currentUser&&n.currentUser.userId===p.userId?f.myRole:p.role,isBlockedByMe:p.isBlockedByMe}),le.channel_url=f.url,le.channel_type=f.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,le.message=g,le.data=_,le.custom_type=v,C&&(le.apple_critical_alert_options=C.serialize()),le.translations=q,le.is_global_block=!!J,le.ts=ae,le.updated_at=oe,le.mention_type=U,le.mentioned_users=A.map((function(e){return s.objectify(e)})),le.mentioned_user_ids=I,le.requested_mention_user_ids=k,le.reactions=O.map((function(e){return e.serialize()})),le.metaarray={},M){var ce=M[ue].key;le.metaarray[ce]=M[ue].value}return le.metaarray_key_order=M.map((function(e){return e.key})),le.root_message_id=P,le.parent_message_id=H,le.parent_message_text=G,j&&(le.thread_info=o.objectify(j)),le.sending_status=c>0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,z&&(le.sending_status=z),le.silent=!!W,le.error_code=Y,le.message_survival_seconds=Z,ee&&(le.og_tag=l.objectify(ee)),le.is_op_msg=!!te,le.plugins=ie.map((function(e){return u.objectify(e)})),le}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c,d,h,p,f,g,y,_,m,v,C,E,U,b,A,S,I,N){return this.objectify({messageId:n,reqId:e,user:t,channel:r,message:i,data:a,customType:s,appleCriticalAlertOptions:o,mentionType:f,mentionedUsers:g,mentionedUserIds:C,requestedMentionUserIds:U,reactions:p,metaArrays:h,rootMessageId:y,parentMessageId:_,parentMessageText:m,threadInfo:v,translations:l,sendingStatus:E,errorCode:b,isGlobalBlocked:u,messageSurvivalSeconds:A,ogMetaData:S,isOperatorMessage:I,plugins:N,createdAt:c,updatedAt:d})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).UserMessage,t=ge.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=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_FILE,r.plainUrl=null,r.name="File",r.size=0,r.type=null,r.thumbnails=[],r._sender=null,r.reqId="",r.requireAuth=null,r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,e&&r._update(e),r}return h(t,[{key:"_update",value:function(e){var n=$n.getInstance(this._iid),t=M.get(this._iid).container.auth,r=D.get(this._iid).Sender;if(this._sender=new r(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 i in this.thumbnails)this.thumbnails[i].plainUrl=String(this.thumbnails[i].url).split("?auth=")[0],this.thumbnails[i].url=this.requireAuth?"".concat(this.thumbnails[i].plainUrl,"?auth=").concat(t.eKey):this.thumbnails[i].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=$n.getInstance(this._iid),n=D.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var t=n.cachedChannels[this.channelUrl];if(t){var r=t.memberMap[this._sender.userId];r&&(this._sender.nickname!==r.nickname&&(this._sender.nickname=r.nickname),this._sender.plainProfileUrl!==r.plainProfileUrl&&(this._sender.plainProfileUrl=r.plainProfileUrl),X.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"isResendable",value:function(){var e=$n.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&X.isResendableError(this.errorCode)}}],[{key:"objectify",value:function(e){var n=$n.getInstance(this._iid),t=D.get(this._iid),r=t.BaseChannel,i=t.BaseMessageParams,a=t.Sender,s=t.User,o=t.ThreadInfo,l=t.OGMetaData,u=e.messageId,c=e.reqId,d=void 0===c?"":c,h=e.user,p=void 0===h?{}:h,f=e.channel,g=e.plainUrl,y=e.name,_=e.type,m=e.size,v=void 0===m?0:m,C=e.data,E=void 0===C?"":C,U=e.customType,b=void 0===U?"":U,A=e.appleCriticalAlertOptions,S=e.mentionType,I=void 0===S?i.MentionType.USERS:S,N=e.mentionedUsers,k=void 0===N?[]:N,R=e.mentionedUserIds,O=void 0===R?[]:R,T=e.requestedMentionUserIds,M=void 0===T?[]:T,L=e.reactions,P=void 0===L?[]:L,w=e.metaArrays,H=void 0===w?[]:w,F=e.rootMessageId,G=void 0===F?0:F,B=e.parentMessageId,j=void 0===B?0:B,x=e.parentMessageText,q=void 0===x?"":x,z=e.threadInfo,Q=void 0===z?null:z,Y=e.thumbnails,K=void 0===Y?[]:Y,W=e.requireAuth,V=void 0!==W&&W,J=e.sendingStatus,X=e.errorCode,Z=void 0===X?0:X,$=e.silent,ee=void 0!==$&&$,ne=e.isGlobalBlocked,te=void 0!==ne&&ne,re=e.messageSurvivalSeconds,ie=void 0===re?-1:re,ae=e.ogMetaData,se=void 0===ae?null:ae,oe=e.isOperatorMessage,le=void 0!==oe&&oe,ue=e.createdAt,ce=e.updatedAt,de=void 0===ce?0:ce,he={};he.req_id=d,he.msg_id=u,he.user=a.objectify({user:p,role:n.currentUser&&n.currentUser.userId===p.userId?f.myRole:p.role,isBlockedByMe:p.isBlockedByMe}),he.channel_url=f.url,he.channel_type=f.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,he.url=g,he.name=y,he.type=_,he.size=v,he.custom=E,he.custom_type=b,A&&(he.apple_critical_alert_options=A.serialize()),he.thumbnails=K,he.require_auth=V,he.is_global_block=!!te,he.ts=ue,he.updated_at=de,he.mention_type=I,he.mentioned_users=k.map((function(e){return s.objectify(e)})),he.mentioned_user_ids=O,he.requested_mention_user_ids=M,he.reactions=P.map((function(e){return e.serialize()})),he.metaarray={};for(var pe=0;pe0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,J&&(he.sending_status=J),he.silent=!!ee,he.error_code=Z,he.message_survival_seconds=ie,se&&(he.og_tag=l.objectify(se)),he.is_op_msg=!!le,he}},{key:"build",value:function(e,n,t,r,i,a,s,o,l,u,c,d,h,p,f,g,y,_,m,v,C,E,U,b,A,S,I,N,k,R,O){return this.objectify({messageId:n,reqId:e,user:t,channel:r,plainUrl:i,name:a,type:s,size:o,data:l,customType:u,appleCriticalAlertOptions:c,mentionType:m,mentionedUsers:v,mentionedUserIds:A,requestedMentionUserIds:I,reactions:_,metaArrays:y,rootMessageId:C,parentMessageId:E,parentMessageText:U,threadInfo:b,thumbnails:p,requireAuth:f,sendingStatus:S,errorCode:N,isGlobalBlocked:d,messageSurvivalSeconds:k,ogMetaData:R,isOperatorMessage:O,createdAt:h,updatedAt:g})}},{key:"buildFromSerializedData",value:function(e){var n=D.get(this._iid).FileMessage,t=ge.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=U(t);function t(e){var r;return c(this,t),(r=n.call(this,e)).messageType=ve.MESSAGE_TYPE_ADMIN,r.message="",r.translations={},e&&r._update(e),r}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,r=n.BaseMessageParams,i=n.User,a=n.ThreadInfo,s=n.OGMetaData,o=e.messageId,l=e.channel,u=e.message,c=e.data,d=void 0===c?"":c,h=e.customType,p=void 0===h?"":h,f=e.mentionType,g=void 0===f?r.MentionType.USERS:f,y=e.mentionedUsers,_=void 0===y?[]:y,m=e.reactions,v=void 0===m?[]:m,C=e.metaArrays,E=void 0===C?[]:C,U=e.rootMessageId,b=void 0===U?0:U,A=e.parentMessageId,S=void 0===A?0:A,I=e.parentMessageText,N=void 0===I?"":I,k=e.threadInfo,R=void 0===k?null:k,O=e.translations,T=void 0===O?{}:O,M=e.silent,L=void 0!==M&&M,P=e.ogMetaData,w=void 0===P?null:P,H=e.createdAt,F=e.updatedAt,G=void 0===F?0:F,B={msg_id:o,channel_url:l.url,channel_type:l.channelType===t.CHANNEL_TYPE_OPEN?t.CHANNEL_TYPE_OPEN:t.CHANNEL_TYPE_GROUP,message:u,data:d,custom_type:p,silent:L,ts:H,updated_at:G};B.translations=T,B.mention_type=g,B.mentioned_users=_.map((function(e){return i.objectify(e)})),B.reactions=v.map((function(e){return e.serialize()})),B.metaarray={};for(var j=0;j0&&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 L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadUserList(l(l({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),Ze=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 ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.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,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.banned_list.map((function(e){return new a(e.user)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),$e=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 ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0&&Array.isArray(n.userIdsFilter)?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadBlockedUserList(l(l({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),en=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 ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasMore?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadFriendList(l(l({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasMore=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),nn=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.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 ge.serialize(this,(function(e){e.isLoading=!1}))}},{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){var t=D.get(n._iid),r=t.GroupChannel,i=t.GroupChannelListQuery;!("number"==typeof n.limit&&n.limit>0&&"boolean"==typeof n.includeEmpty&&"string"==typeof n.order&&[i.ORDER_CHRONOLOGICAL,i.ORDER_LATEST_LAST_MESSAGE,i.CHANNEL_NAME_ALPHABETICAL,i.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(i.QueryType).map((function(e){return i.QueryType[e]})).indexOf(n._userIdsIncludeFilterQueryType.toUpperCase())>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(n.memberStateFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(n.superChannelFilter)>-1&&Object.keys(r.PublicChannelFilter).map((function(e){return r.PublicChannelFilter[e]})).indexOf(n.publicChannelFilter)>-1&&Object.keys(r.UnreadChannelFilter).map((function(e){return r.UnreadChannelFilter[e]})).indexOf(n.unreadChannelFilter)>-1&&Object.keys(r.HiddenChannelFilter).map((function(e){return r.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||"boolean"!=typeof n.includeFrozen||"boolean"!=typeof n.includeMetaData?e(re.error,null):n.isLoading?e(new L("Query in progress.",L.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,r){var i=null;if(!t){var a=D.get(n._iid).GroupChannel,s=String(r.next);n._token=s,n.hasNext=!!s;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),a.upsert(e)})):t=new L("Failed at loading group channels.",L.MALFORMED_DATA)}n.isLoading=!1,e(t,i)}))):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=ge.deserialize(e),r=n.createMyGroupChannelListQuery();for(var i in t)r.hasOwnProperty(i)&&(r[i]=t[i]);return r}}]),e}(),tn=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 ye(this._iid,(function(e){var t=D.get(n._iid),r=t.GroupChannel,i=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(r.MemberStateFilter).map((function(e){return r.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 L("Query in progress.",L.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,r){var a=null;if(!t){var s=String(r.next);n._token=s,n.hasNext=!!s,a=r.members.map((function(e){return new i(e)}))}n.isLoading=!1,e(t,a)}))):e(null,[]):e(re.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}(),rn=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 ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.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,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.muted_list.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),an=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 ye(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(re.error,null):n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadOpenChannelList(l(l({},n),{},{token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).OpenChannel,s=String(r.next);n._token=s,n.hasNext=!!s;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),a.upsert(e)})):t=new L("Failed at loading open channels.",L.MALFORMED_DATA)}n.isLoading=!1,e(t,i)}))):e(null,[])}),e)}}]),e}(),sn=new WeakMap,on=function(){function e(n){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",sn.set(this,n)}return h(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){if("number"==typeof n.limit&&n.limit>0)if(n.isLoading)e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else if(n.hasNext){n.isLoading=!0;var t=sn.get(n);M.get(n._iid).container.apiClient.loadOperatorList(l(l({},n),{},{token:n._token,channelUrl:t.url,isOpenChannel:t.isOpenChannel()}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.operators.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))}else e(null,[]);else e(re.error,null)}),e)}}]),e}(),ln=new WeakMap,un=function(){function e(n){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",n&&ln.set(this,n.channelUrl)}return h(e,[{key:"next",value:function(e){var n=this;return ye(this._iid,(function(e){"number"==typeof n.limit&&n.limit>0?n.isLoading?e(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,M.get(n._iid).container.apiClient.loadParticipantList(l(l({},n),{},{channelUrl:ln.get(n),token:n._token}),(function(t,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.participants.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),cn=new WeakMap,dn=function(){function e(n,t){var r=t.limit,i=void 0===r?20:r,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,g=void 0===f?null:f,y=t.messageTimestampTo,_=void 0===y?null:y,m=t.order,v=void 0===m?"score":m,C=t.advancedQuery,E=void 0!==C&&C,U=t.targetFields,b=void 0===U?null:U;c(this,e),this.isLoading=!1,this.hasNext=!0,cn.set(this,{keyword:n,limit:i,reverse:s,exactMatch:l,channelUrl:d,channelCustomType:p,messageTimestampFrom:g,messageTimestampTo:_,order:v,advancedQuery:E,targetFields:b,previousToken:"",nextToken:""})}return h(e,[{key:"key",get:function(){return cn.get(this).keyword}},{key:"limit",get:function(){return cn.get(this).limit}},{key:"reverse",get:function(){return cn.get(this).reverse}},{key:"exactMatch",get:function(){return cn.get(this).exactMatch}},{key:"channelUrl",get:function(){return cn.get(this).channelUrl}},{key:"channelCustomType",get:function(){return cn.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return cn.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return cn.get(this).messageTimestampTo}},{key:"order",get:function(){return cn.get(this).order}},{key:"next",value:function(e){var n=this,t=D.get(this._iid),r=t.BaseChannel,i=t.GroupChannel,a=t.OpenChannel;return ye(this._iid,(function(e){var t=cn.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,g=t.advancedQuery,y=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 g&&null!==g||!Array.isArray(y)&&null!==y?e(re.error,null):n.isLoading?e(new L("Query in progress.",L.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:g,targetFields:y,nextToken:_},(function(t,s){var o=null;if(!t){for(var l in o=[],s.results){var u=s.results[l];if(u.channel.hasOwnProperty("members")){var c=new i(u.channel);i.cachedChannels[c.url]=c,o.push(r.buildMessage(u,c))}else{var d=new a(u.channel);a.cachedChannels[d.url]=d,o.push(r.buildMessage(u,d))}}n.hasNext=s.has_next,cn.get(n).nextToken=s.end_cursor}n.isLoading=!1,e(t,o)}))):e(null,[])}),e)}}]),e}(),hn=new WeakMap,pn=new WeakMap,fn=function(){function e(n){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,pn.set(this,Number.MAX_SAFE_INTEGER),hn.set(this,n),this.reverse=!1,this.messageTypeFilter=null,this.customTypeFilter=null,this.customTypesFilter=[],this.senderUserIdsFilter=[],this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1}return h(e,[{key:"load",value:function(e,n,t,r){var i=this,a=D.get(this._iid),s=a.BaseChannel,o=null,l=re.parse(arguments,[new re({type:"number",optional:!0,defaultValue:this.limit}),new re({type:"boolean",optional:!0,defaultValue:this.reverse}),new re({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 re({type:"callback"})]),u=A(l,5);return o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],ye(this._iid,(function(r){if(Array.isArray(i.customTypesFilter)&&!i.customTypesFilter.some((function(e){return"string"!=typeof e&&null!==e}))&&Array.isArray(i.senderUserIdsFilter)&&!i.senderUserIdsFilter.some((function(e){return"string"!=typeof e}))||(o=re.error),o)r(o,null);else{if(i.limit=e,i.reverse=n,i.messageTypeFilter=t,"number"==typeof i.messageTypeFilter)switch(i.messageTypeFilter){case 0:i.messageTypeFilter=s.MessageTypeFilter.ALL;break;case 1:i.messageTypeFilter=s.MessageTypeFilter.USER;break;case 2:i.messageTypeFilter=s.MessageTypeFilter.FILE;break;case 3:i.messageTypeFilter=s.MessageTypeFilter.ADMIN}if(i.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else if(i.hasMore){i.isLoading=!0;var a=hn.get(i),l=M.get(i._iid);"boolean"==typeof i.includeReaction&&i.includeReaction&&(i.includeReactions=i.includeReaction),l.container.apiClient.getMessageList({channel:a,token:pn.get(i)||(new Date).getTime()+1e4,tokenType:"timestamp",isInclusive:!1,prevResultSize:e,nextResultSize:0,shouldReverse:n,messageType:i.messageTypeFilter,customType:i.customTypeFilter,customTypes:i.customTypesFilter,senderUserIds:i.senderUserIdsFilter,includeMetaArray:i.includeMetaArray,includeReactions:i.includeReactions,includeReplies:i.includeReplies,includeParentMessageText:i.includeParentMessageText,includeThreadInfo:i.includeThreadInfo,showSubchannelMessagesOnly:i.showSubchannelMessagesOnly},(function(n,t){var o=null;if(!n){(0===(o=t.messages.map((function(e){return s.buildMessage(e,a)}))).length||o.length0&&"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(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(t.superChannelFilter)>-1)||"string"!=typeof t.customTypeStartsWithFilter&&null!==t.customTypeStartsWithFilter||"string"!=typeof t.channelNameContainsFilter||"string"!=typeof t.metadataOrderKeyFilter&&null!==t.metadataOrderKeyFilter||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?n(re.error,null):t.isLoading?n(new L("Query in progress.",L.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,M.get(t._iid).container.apiClient.loadPublicGroupChannelList(l(l({},t),{},{token:t._token}),(function(e,i){var a=null;if(!e){var s=String(i.next);t._token=s,t.hasNext=!!s;var o=i.channels;o&&Array.isArray(o)?a=o.map((function(e){return"number"==typeof i.ts&&(e.ts=i.ts),r.upsert(e)})):e=new L("Failed at loading group channels.",L.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}(),yn=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,S(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,S(t))}}},{key:"addUserId",value:function(e){"string"==typeof e&&this._invitedUserIds.push(e)}}]),e}(),_n=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||null===this.channelUrl)}}]),e}(),mn=new WeakMap,vn=function(){function e(){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],mn.set(this,null),this._parentMessageId=null}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=$n.getInstance(this._iid),t=0;t-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 r||null===r)&&("number"==typeof this._parentMessageId||null===this._parentMessageId)}}],[{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),Cn=function(e){f(t,e);var n=U(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._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-1)&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof r)}}]),t}(vn),En=function(e){f(t,e);var n=U(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;n0&&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 r)}}]),t}(vn),Un=function(e){f(t,e);var n=U(t);function t(e){var r;return c(this,t),(r=n.call(this)).year=null,r.month=null,r.day=null,r.hour=null,r.min=null,r.timezone=null,r._scheduledDateTimeString=null,e&&r._update(e),r}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,r,i,a){"number"==typeof e&&4===e.toString().length&&"number"==typeof n&&n>=1&&n<=12&&"number"==typeof t&&t>=1&&t<=31&&"number"==typeof r&&r>=0&&r<=24&&"number"==typeof i&&i>=0&&i<=60&&"string"==typeof a&&a.length>0&&(this.scheduledDateTimeString=e.toString()+"-"+("0"+n.toString()).substr(-2)+"-"+("0"+t.toString()).substr(-2)+" "+("0"+r.toString()).substr(-2)+":"+("0"+i.toString()).substr(-2),this.timezone=a)}}]),t}(Cn),bn=function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=De.SuperChannelFilter.ALL},An=function(){function e(){c(this,e),this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeMetaArray=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!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.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo}}]),e}(),Sn=function(){function e(){c(this,e);var n=D.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=n.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1}return h(e,[{key:"_validate",value:function(){"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction);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&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeReplies&&"boolean"==typeof this.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo&&"boolean"==typeof this.showSubchannelMessagesOnly}}]),e}(),In=function(){function e(){c(this,e);var n=D.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=n.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeParentMessageText=!1}return h(e,[{key:"_validate",value:function(){"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction);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&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeParentMessageText}}]),e}(),Nn=function(){function e(){c(this,e),this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=!1,this.includeReplies=!1,this.includeParentMessageText=!1,this.includeThreadInfo=!1}return h(e,[{key:"_validate",value:function(){return"boolean"==typeof this.includeReaction&&this.includeReaction&&(this.includeReactions=this.includeReaction),"boolean"==typeof this.includeMetaArray&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeReplies&&"boolean"==typeof this.includeParentMessageText&&"boolean"==typeof this.includeThreadInfo}}]),e}(),kn=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}(),Rn=function e(){c(this,e),this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},On=function e(){c(this,e),this.onFriendsDiscovered=function(e){},this.onTotalUnreadMessageCountUpdated=function(e,n){}},Tn=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){}},Mn=function e(n){if(c(this,e),n){var t=D.get(this._iid),r=t.User,i=t.BaseChannel;this.reader=new r(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):i.CHANNEL_TYPE_GROUP}},Ln=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}(),Pn=new WeakMap,wn=function(){function e(n){var t=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=t,this.updatedAt=r;var i={};for(var a in this.userIds){var s=this.userIds[a];i[s]=this.updatedAt}Pn.set(this,i)}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=Pn.get(this);if(e.key===this.key&&(!n[e.userId]||n[e.userId]=0&&this.userIds.splice(t,1)}n[e.userId]=e.updatedAt}}}}],[{key:"createFromJson",value:function(e){var n=e.key,t=e.user_ids,r=e.updated_at;return"string"==typeof n&&n&&Array.isArray(t)&&t.length>0&&"number"==typeof r?new this(n,t,r):null}}]),e}(),Dn=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,r=e.mostRepliedUsers,i=e.lastRepliedAt,a=e.updatedAt,s={};return s.reply_count=t,Array.isArray(r)&&r.every((function(e){return e instanceof n}))&&(s.most_replies=r.map((function(e){return n.objectify(e)}))),s.last_replied_at=i,s.updated_at=a,s}},{key:"build",value:function(e,n,t,r){return this.objectify({replyCount:e,mostRepliedUsers:n,lastRepliedAt:t,updatedAt:r})}}]),e}(),Hn=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,r=void 0===t?null:t,i=e.url,a=void 0===i?null:i,s=e.description,o=void 0===s?null:s,l=e.defaultImage,u=void 0===l?null:l,c={};return c["og:title"]=r,c["og:url"]=a,c["og:description"]=o,u&&(c["og:image"]=n.objectify(u)),c}}]),e}(),Fn=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,r=e.secureUrl,i=void 0===r?null:r,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=i,p.type=s,p.width=l,p.height=c,p.alt=h,p}}]),e}(),Gn=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,r=e.vendor,i=void 0===r?"":r,a=e.detail,s=void 0===a?{}:a,o={};return o.type=t,o.vendor=i,o.detail=s,o}}]),e}(),Bn=function(){function e(n){c(this,e),this.name="default",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{name:this.name,volume:this.volume}}}]),e}(),jn=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 ye(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 L("Query in progress.",L.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,r){var i=null;if(!t){var a=D.get(n._iid).User,s=String(r.next);n._token=s,n.hasNext=!!s,i=r.users.map((function(e){return new a(e)}))}n.isLoading=!1,e(t,i)}))):e(null,[]):e(re.error,null)}),e)}}]),e}(),xn=new WeakMap,qn=function(){function e(n){c(this,e),this.isLoading=!1,xn.set(this,n)}return h(e,[{key:"prev",value:function(e,n,t,r){var i=arguments,a=this;return ye(this._iid,(function(r){var s,o=D.get(a._iid).BaseChannel,l=A(re.parse(i,[new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"function"})]),5);if(s=l[0],e=l[1],n=l[2],t=l[3],r=l[4],s)r(s,null);else if(a.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var u=xn.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,r(e,t)}))}}),r)}},{key:"next",value:function(e,n,t,r){var i=arguments,a=this;return ye(this._iid,(function(r){var s,o=D.get(a._iid).BaseChannel,l=A(re.parse(i,[new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"function"})]),5);if(s=l[0],e=l[1],n=l[2],t=l[3],r=l[4],s)r(s,null);else if(a.isLoading)r(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var u=xn.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,r(e,t)}))}}),r)}},{key:"load",value:function(e,n,t,r,i){var a=arguments,s=this;return ye(this._iid,(function(i){var o,l=D.get(s._iid).BaseChannel,u=A(re.parse(a,[new re({type:"number"}),new re({type:"number"}),new re({type:"number"}),new re({type:"boolean"}),new re({type:"callback"})]),6);if(o=u[0],e=u[1],n=u[2],t=u[3],r=u[4],i=u[5],o)i(o,null);else if(s.isLoading)i(new L("Query in progress.",L.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var c=xn.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:r,messageType:"",customType:""},(function(e,n){var t=null;e||(t=n.messages.map((function(e){return l.buildMessage(e,c)}))),s.isLoading=!1,i(e,t)}))}}),i)}}]),e}(),zn=0,Qn=1,Yn=2,Kn=function(){function e(n){var t=this;c(this,e),this.state=zn,this._value=null,this._reason=null;if("function"!=typeof n)throw"Promise resolver ".concat(n," is not a function");n((function(e){t.state===zn&&(t.state=Qn,t._value=e)}),(function(e){t.state===zn&&(t.state=Yn,t._reason=e)}))}return h(e,[{key:"length",get:function(){return 1}},{key:"then",value:function(n,t){var r=this,i=this;switch(this.state){case zn:setTimeout((function(){return r.then(n,t)}),100);break;case Qn:n&&"function"==typeof n&&(i=n(this._value));break;case Yn:t&&"function"==typeof t&&(i=t(this._reason))}return i instanceof e?i:this}},{key:"catch",value:function(n){var t=this,r=this;switch(this.state){case zn:setTimeout((function(){return t.catch(n)}),100);break;case Qn:break;case Yn:r=n(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(n){var t=this,r=this;switch(this.state){case zn:setTimeout((function(){return t.finally(n)}),100);break;case Qn:case Yn:r=n()}return r instanceof e?r:this}}],[{key:"all",value:function(n){return new e((function(t,r){if(Array.isArray(n)||"string"==typeof n)if(n.length>0){var i=[];for(var a in n)n[a]instanceof e?i.push(n[a]):i.push(e.resolve(n[a]));var s=new Array(i.length).fill(null),o=i.length,l=function(e,n,i){n?r(n):(o--,s[e]=i,o<=0&&t(s))};i.forEach((function(e,n){e.then((function(e){l(n,null,e)})).catch((function(e){l(n,e,null)}))}))}else t([]);else r(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}(),Wn=function(){"undefined"==typeof Promise&&("undefined"!=typeof window?window.Promise=Kn:"undefined"!=typeof global?global.Promise=Kn:"undefined"!=typeof self?self.Promise=Kn:"undefined"!=typeof globalThis&&(globalThis.Promise=Kn)),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})},Vn=3e5,Jn=null,Xn={},Zn=!1,$n=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),Wn();var t=!1;if((n.newInstance||!Jn||Jn&&n.appId!==Jn.getApplicationId()&&Jn.getConnectionState()===Jn.ConnectionState.CLOSED)&&(t=!0,Jn=this),t){try{if(!n.hasOwnProperty("appId"))return Y.warn("Must be set appId."),Jn=null,null}catch(e){return Y.warn("Must be set appId."),Jn=null,null}var r=Oe.create();Object.defineProperty(this,"_iid",{get:function(){return r}}),Xn[r]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new ie(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:be.MessageTypeFilter},this.BaseMessage={getMessage:ve.getMessage};var i={User:Ce,Member:He,GroupChannel:De,OpenChannel:Qe,UserMessage:Ye,FileMessage:Ke,AdminMessage:We,GroupChannelListQuery:nn,MemberListQuery:tn,GroupChannelParams:yn,OpenChannelParams:_n,BaseMessageParams:vn,UserMessageParams:Cn,FileMessageParams:En,ScheduledUserMessageParams:Un,GroupChannelTotalUnreadMessageCountParams:bn,MessageRetrievalParams:An,MessageListParams:Sn,ThreadedMessageListParams:In,MessageChangeLogsParams:Nn,GroupChannelChangeLogsParams:kn,MessageMetaArray:Ln,UserEventHandler:On,SessionHandler:ae,ChannelHandler:Tn,ConnectionHandler:Rn,AppleCriticalAlertOptions:Bn},a={SessionManager:se,BaseChannel:be,BaseMessage:ve,UserListQuery:jn,ApplicationUserListQuery:Xe,BannedUserListQuery:Ze,BlockedUserListQuery:$e,FriendListQuery:en,MutedUserListQuery:rn,OpenChannelListQuery:an,OperatorListQuery:on,ParticipantListQuery:un,MessageListQuery:qn,PreviousMessageListQuery:fn,MessageSearchQuery:dn,PublicGroupChannelListQuery:gn,ScheduledUserMessage:Ve,ThreadInfo:Dn,ThreadInfoUpdateEvent:Je,OGMetaData:Hn,OGImage:Fn,Plugin:Gn,Command:ue,Sender:Fe,ReadStatus:Mn,Reaction:wn,ReactionEvent:pe,Emoji:je,EmojiCategory:Be,EmojiContainer:Ge,FileMessageQueue:Re},s=new D(this._iid,l(l({},i),a));for(var o in s)i[o]&&(this[o]=s[o]);M.create(r,{appId:n.appId,pinger:new W(this),apiClient:new ee(this),wsAdapter:new te(this),commandHandler:new Ie(this),onlineDetector:new oe(this),ackStateMap:{},subscribedUnreadMessageCount:{all:0,custom_types:{},ts:0},maxUnreadCountOfSuperGroupChannel:R.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,auth:new P,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(R.SDK_VERSION,"/").concat(n,"/").concat(t)},sessionManager:new s.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<=Vn&&(this._websocketResponseTimeout=e)}}}return Jn}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 Zn}},{key:"setDebugMode",value:function(e){Zn=e,Y.mode=e?Y.Mode.DEBUG:Y.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,r,i){var a=this,s=M.get(this._iid),o=s.container,l=o.wsAdapter,u=o.onlineDetector;u&&u.start();var c=null,d=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new re({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new re({type:"callback"})]),h=A(d,6);return c=h[0],e=h[1],n=h[2],t=h[3],r=h[4],i=h[5],ye(this._iid,(function(i){c?i(c,null):(a.customApiHost=t,a.customWsHost=r,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,i(null,a.currentUser)):(a.connectionCallbacks.push(i),1===a.connectionCallbacks.length&&(l.disconnect({clearSession:!0,err:null},null),l.connect(e,n))))}),i)}},{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 L("Connection has been canceled.",L.CONNECTION_CANCELED)},null),n.reconnectCount=0,n.reconnect(this.currentUser.userId,t),!0}return!1}},{key:"disconnect",value:function(e){var n=this;return ye(this._iid,(function(e){var t=M.get(n._iid).container,r=t.wsAdapter,i=t.onlineDetector;i&&i.stop(),r.disconnect({clearSession:!0,err:new L("Connection has been canceled.",L.CONNECTION_CANCELED)},e)}),e)}},{key:"setBackgroundState",value:function(){var e=M.get(this._iid),n=e.container,t=n.wsAdapter,r=n.stateChangeEnabled;!n.isInBackground&&r&&(e.set("isInBackground",!0),this.getConnectionState()!==this.ConnectionState.CLOSED?(e.set("closedByGoingBackground",!0),t.disconnect({clearSession:!1,err:new L("Websocket connection failed.",L.WEBSOCKET_CONNECTION_FAILED)},null)):e.set("closedByGoingBackground",!1))}},{key:"setForegroundState",value:function(){var e=M.get(this._iid),n=e.container,t=n.wsAdapter,r=n.stateChangeEnabled,i=n.isInBackground,a=n.closedByGoingBackground;i&&r&&(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,r=t.extensions;t.supportedExtensionKeys.indexOf(e)>-1&&(r[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 ye(this._iid,(function(n){t.ConnectionManager.ready((function(r,i){if(r)n(r,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 L("Connection is not valid. Please reconnect.",L.WEBSOCKET_CONNECTION_CLOSED),null);if(e.isAckRequired){var l=e.requestId,u={handler:n,timer:setTimeout((function(){n(new L("Command received no ack.",L.ACK_TIMEOUT),null),delete o[l]}),t.Options.websocketResponseTimeout)};o[l]=u,s.client.send(e,(function(e){e&&(clearTimeout(u.timer),n(e,null))}))}else s.client.send(e,n)}}),!1)}),n)}},{key:"setSessionHandler",value:function(e){M.get(this._iid).container.sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,n){n instanceof D.get(this._iid).UserEventHandler&&(this.userEventHandlers[e]=n)}},{key:"removeUserEventHandler",value:function(e){delete this.userEventHandlers[e]}},{key:"removeAllUserEventHandler",value:function(){this.userEventHandlers={}}},{key:"addChannelHandler",value:function(e,n){n instanceof D.get(this._iid).ChannelHandler&&(this.channelHandlers[e]=n)}},{key:"removeChannelHandler",value:function(e){delete this.channelHandlers[e]}},{key:"removeAllChannelHandlers",value:function(){this.channelHandlers={}}},{key:"addConnectionHandler",value:function(e,n){n instanceof D.get(this._iid).ConnectionHandler&&(this.connectionHandlers[e]=n)}},{key:"removeConnectionHandler",value:function(e){delete this.connectionHandlers[e]}},{key:"removeAllConnectionHandlers",value:function(){this.connectionHandlers={}}},{key:"updateCurrentUserInfo",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"string",nullable:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:n},(function(i,a){var s=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),n&&(r.currentUser.plainProfileUrl=n)),s=r.currentUser),t(i,s)}))}),t)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,n,t){var r=this,i=null,a=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"file",nullable:!0}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:n},(function(n,i){var a=null;n||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url)),a=r.currentUser),t(n,a)}))}),t)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.updateCurrentUserInfo({preferredLanguages:e},(function(r,i){var a=null;r||(t.currentUser&&e&&(t.currentUser._preferredLanguages=e),a=t.currentUser),n(r,a)}))}),n)}},{key:"registerGCMPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,t.pushTokenRegistrationState.ERROR):t.currentUser?M.get(t._iid).container.apiClient.registerGCMPushToken({token:e},(function(e,r){var i=t.pushTokenRegistrationState.ERROR;e||(t.GCMPushToken="",i=t.pushTokenRegistrationState.SUCCESS),n(e,i)})):(t.GCMPushToken=e,n(null,t.pushTokenRegistrationState.PENDING))}),n)}},{key:"unregisterGCMPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,t.pushTokenRegistrationState.ERROR):t.currentUser?M.get(t._iid).container.apiClient.registerAPNSPushToken({token:e},(function(e,r){var i=t.pushTokenRegistrationState.ERROR;e||(t.APNSPushToken="",i=t.pushTokenRegistrationState.SUCCESS),n(e,i)})):(t.APNSPushToken=e,n(null,t.pushTokenRegistrationState.PENDING))}),n)}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e.length>0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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 ye(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,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:"array",optional:!0,nullable:!0,defaultValue:null}),new re({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new re({type:"callback"})]),o=A(s,5);a=o[0],e=o[1],n=o[2],t=o[3],r=o[4];var u=D.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(a){var h=re.parse(arguments,[new re({type:"string",nullable:!0}),new re({type:c,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),p=A(h,4);a=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=n,d.includeEmpty=t,d.includeFrozen=!0;return ye(this._iid,(function(n){a?n(a,null):M.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:null,token:e},d),(function(e,t){if(e)n(e,null);else{var r=D.get(i._iid).GroupChannel,a=t.updated.map((function(e){return new r(e)})),s=t.deleted,o=t.has_more,l=t.next;n(null,{updatedChannels:a,deletedChannelUrls:s,hasMore:o,token:l})}}))}),r)}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"array",optional:!0,nullable:!0,defaultValue:null}),new re({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new re({type:"callback"})]),o=A(s,5);a=o[0],e=o[1],n=o[2],t=o[3],r=o[4];var u=D.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(a){var h=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:c,constraint:function(e){return e._validate()}}),new re({type:"callback"})]),p=A(h,4);a=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=n,d.includeEmpty=t,d.includeFrozen=!0;return ye(this._iid,(function(n){a?n(a,null):M.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:e,token:null},d),(function(e,t){if(e)n(e,null);else{var r=D.get(i._iid).GroupChannel,a=t.updated.map((function(e){return new r(e)})),s=t.deleted,o=t.has_more,l=t.next;n(null,{updatedChannels:a,deletedChannelUrls:s,hasMore:o,token:l})}}))}),r)}},{key:"getChannelInvitationPreference",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getChannelInvitationPreference({},(function(n,t){var r=null;n||(r={autoAccept:t.auto_accept}),e(n,r)}))}),e)}},{key:"setChannelInvitationPreference",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"boolean"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.setChannelInvitationPreference({isAutoAccept:e},(function(e,t){var r=null;e||(r={autoAccept:t.auto_accept}),n(e,r)}))}),n)}},{key:"getDoNotDisturb",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getDoNotDisturb({},(function(n,t){var r=null;n||(r={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,r)}))}),e)}},{key:"setDoNotDisturb",value:function(e,n,t,r,i,a,s){var o=this,l=null,u=re.parse(arguments,[new re({type:"boolean"}),new re({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new re({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new re({type:"string"}),new re({type:"callback"})]),c=A(u,8);return l=c[0],e=c[1],n=c[2],t=c[3],r=c[4],i=c[5],a=c[6],s=c[7],ye(this._iid,(function(s){l?s(l,null):M.get(o._iid).container.apiClient.setDoNotDisturb({doNotDisturbOn:e,startHour:n,startMin:t,endHour:r,endMin:i,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 ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getSnoozePeriod({},(function(n,t){var r=null;n||(r={isSnoozeOn:t.snooze_enabled,startTs:t.snooze_start_ts,endTs:t.snooze_end_ts}),e(n,r)}))}),e)}},{key:"setSnoozePeriod",value:function(e,n,t,r){var i=this,a=null,s=re.parse(arguments,[new re({type:"boolean"}),new re({type:"number",constraint:function(e){return e>0}}),new re({type:"number",constraint:function(e){return e>0}}),new re({type:"callback"})]),o=A(s,5);return a=o[0],e=o[1],n=o[2],t=o[3],r=o[4],ye(this._iid,(function(r){a?r(a,null):M.get(i._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}),r(e,t)}))}),r)}},{key:"blockUser",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.blockUserWithUserId(e.userId,n)}},{key:"blockUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e&&(!t.currentUser||e!==t.currentUser.userId)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.blockUser({blockedUserId:e},(function(e,t){var r=null;e||(r=new Ce(t)),n(e,r)}))}),n)}},{key:"unblockUser",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.unblockUserWithUserId(e.userId,n)}},{key:"unblockUserWithUserId",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",constraint:function(e){return e&&(!t.currentUser||e!==t.currentUser.userId)}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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 ye(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 ye(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(re.error,null)}),n)}},{key:"getGroupChannelCount",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=null,s=re.parse(arguments,[new re({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new re({type:"callback"})]),o=A(s,3);return a=o[0],e=o[1],n=o[2],ye(this._iid,(function(n){a?n(a,null):M.get(t._iid).container.apiClient.getGroupChannelCount({memberStateFilter:e},(function(e,t){var r=null;e||(r=parseInt(t.group_channel_count)),n(e,r)}))}),n)}},{key:"getTotalUnreadChannelCount",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getTotalUnreadChannelCount({},(function(n,t){var r=null;n||(r=parseInt(t.unread_count)),e(n,r)}))}),e)}},{key:"getTotalUnreadMessageCount",value:function(e,n){var t=this,r=D.get(this._iid),i=r.GroupChannel,a=r.GroupChannelTotalUnreadMessageCountParams,s=null,o=re.parse(arguments,[new re({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 re({type:"callback"})]),l=A(o,3);return s=l[0],e=l[1],n=l[2],ye(this._iid,(function(n){if(s)n(s,null);else{var r=i.SuperChannelFilter.ALL;if(e instanceof a){var o=e;e=o.channelCustomTypesFilter,r=o.superChannelFilter}M.get(t._iid).container.apiClient.getTotalUnreadMessageCount({customTypesFilter:e,superChannelFilter:r},(function(e,t){var r=null;e||(r=parseInt(t.unread_count)),n(e,r)}))}}),n)}},{key:"getUnreadItemCount",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({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 re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i=e.filter((function(n,t){return e.indexOf(n)===t}));M.get(t._iid).container.apiClient.getUnreadItemCount({keys:i},(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;for(var t in e.custom_types)n+=e.custom_types[t];return 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 r=this,i=null,a=re.parse(arguments,[new re({type:"string"}),new re({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new re({type:"callback"})]),s=A(a,4);return i=s[0],e=s[1],n=s[2],t=s[3],ye(this._iid,(function(t){i?t(i,null):M.get(r._iid).container.apiClient.getPushTokens({ts:null,token:e,type:n},(function(e,n){if(e)t(e,null);else{var r=n.type;t(null,{deviceTokens:n.device_tokens,type:r?r.toLowerCase():"unknown",hasMore:n.has_more,token:n.token})}}))}),t)}},{key:"getPushTemplate",value:function(e){var n=this;return ye(this._iid,(function(e){M.get(n._iid).container.apiClient.getPushTemplate({},(function(n,t){var r=null;n||(r=t.name.toString()),e(n,r)}))}),e)}},{key:"setPushTemplate",value:function(e,n){var t=this;return ye(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 r=null;e||(r=t.name.toString()),n(e,r)})):n(re.error,null)}),n)}},{key:"markAsReadAll",value:function(e){var n=this;return ye(this._iid,(function(e){var t=D.get(n._iid).GroupChannel,r=(new Date).getTime();r-t.markAsReadAllLastSentAt<1e3?e(new L("MarkAsRead rate limit exceeded.",L.MARK_AS_READ_RATE_LIMIT_EXCEEDED),null):(t.markAsReadAllLastSentAt=r,M.get(n._iid).container.apiClient.markAsReadAll({channelUrls:null},(function(i,a){if(!i)for(var s in t.cachedChannels)n.currentUser&&t.cachedChannels[s].updateReadReceipt(n.currentUser.userId,r),t.cachedChannels[s]._setGroupChannelUnreadCount(0,0);e(i,null)})))}),e)}},{key:"markAsReadWithChannelUrls",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){if(r)n(r,null);else{var i=(new Date).getTime();M.get(t._iid).container.apiClient.markAsReadAll({channelUrls:e},(function(r,a){if(!r)for(var s in e){var o=e[s];De.cachedChannels[o]&&(t.currentUser&&De.cachedChannels[o].updateReadReceipt(t.currentUser.userId,i),De.cachedChannels[o]._setGroupChannelUnreadCount(0,0))}n(r,null)}))}}),n)}},{key:"markAsDelivered",value:function(e){"string"==typeof e&&D.get(this._iid).GroupChannel.getChannel(e,R.INTERNAL_CALL,(function(e,n){e||n.markAsDelivered()}))}},{key:"getFriendChangeLogsByToken",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string",optional:!0,defaultValue:null}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getFriendChangeLogsByToken({token:e},(function(e,r){var i=null;if(!e){var a=D.get(t._iid).User;i={updatedUsers:r.updated.map((function(e){return new a(e)})),deletedUserIds:r.deleted,hasMore:r.has_more,token:r.next}}n(e,i)}))}),n)}},{key:"uploadFriendDiscoveries",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.deleteFriendDiscoveries([e],n)}},{key:"deleteFriendDiscoveries",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.addFriends({userIds:e},(function(e,r){var i=null;if(!e){var a=D.get(t._iid).User;i=r.users.map((function(e){return new a(e)}))}n(e,i)}))}),n)}},{key:"deleteFriend",value:function(e,n){var t=null,r=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),i=A(r,3);return t=i[0],e=i[1],n=i[2],t?ye(this._iid,(function(e){e(t,null)}),n):this.deleteFriends([e],n)}},{key:"deleteFriends",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,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,r=re.parse(arguments,[new re({type:"callback"})]),i=A(r,2);return t=i[0],e=i[1],ye(this._iid,(function(e){t?e(t,null):M.get(n._iid).container.apiClient.getAllEmoji((function(t,r){if(t)e(t,null);else{var i=new(0,D.get(n._iid).EmojiContainer)(r);e(null,i)}}))}),e)}},{key:"getEmojiCategory",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"number",constraint:function(e){return e>=0}}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getEmojiCategory({categoryId:e},(function(e,r){if(e)n(e,null);else{var i=new(0,D.get(t._iid).EmojiCategory)(r);n(null,i)}}))}),n)}},{key:"getEmoji",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"string"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.getEmoji({emojiKey:e},(function(e,r){if(e)n(e,null);else{var i=new(0,D.get(t._iid).Emoji)(r);n(null,i)}}))}),n)}},{key:"getAllowFriendDiscovery",value:function(e){var n=this,t=null,r=re.parse(arguments,[new re({type:"callback"})]),i=A(r,2);return t=i[0],e=i[1],ye(this._iid,(function(e){t?e(t,null):M.get(n._iid).container.apiClient.getAllowFriendDiscovery((function(n,t){var r=t.allow_friend_discovery;n||e(null,r)}))}),e)}},{key:"setAllowFriendDiscovery",value:function(e,n){var t=this,r=null,i=re.parse(arguments,[new re({type:"boolean"}),new re({type:"callback"})]),a=A(i,3);return r=a[0],e=a[1],n=a[2],ye(this._iid,(function(n){r?n(r,null):M.get(t._iid).container.apiClient.setAllowFriendDiscovery({allowFriendDiscovery:e},(function(t,r){t||n(null,e)}))}),n)}}],[{key:"version",get:function(){return R.SDK_VERSION}},{key:"LogLevel",get:function(){return Y.supportedLogLevels}},{key:"getInstance",value:function(e){return e?Xn[e]:Jn}},{key:"getLogLevel",value:function(){return Y.logLevel}},{key:"setLogLevel",value:function(e){var n=Object.values(Y.supportedLogLevels);if(n.includes(e))Y.logLevel=e;else{Y.logLevel=Y.defaultLogLevel;var t=n.map((function(e){return"'".concat(e,"'")})).join(", ");Y.warn("`logLevel` parameter should be one of","".concat(t,","),"not `'".concat(e,"'`."),"Set to default log level","`".concat(Y.defaultLogLevel,"`."))}}}]),e}();return $n})); \ No newline at end of file diff --git a/bower.json b/bower.json index 9a1dc39..c1e578d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.0.151", + "version": "3.0.152", "authors": [ "Sendbird " ], diff --git a/package.json b/package.json index f2fc4f5..a775961 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.0.151", + "version": "3.0.152", "description": "Sendbird JavaScript SDK", "main": "SendBird.min.js", "dependencies": {