From 103abf8c698c4d3e8d6ba9c705ba946ba34755c0 Mon Sep 17 00:00:00 2001 From: Liam Cho Date: Wed, 1 Dec 2021 21:42:50 +0900 Subject: [PATCH] v3.1.2 --- CHANGELOG.md | 5 +++++ README.md | 6 ++++-- SendBird.d.ts | 10 +++++++++- SendBird.min.js | 4 ++-- bower.json | 2 +- package.json | 2 +- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1baffac..433fdfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v3.1.2 (DEC 01, 2021) +- Fixed TypeScript interface in `PreviousMessageListQuery`. +- Deprecated `includeReplies` and `includeParentMessageText`. +- Added `replyType` and `includeParentMessageInfo`. + ## v3.1.1 (NOV 24, 2021) - `dns` dependency removed. diff --git a/README.md b/README.md index 252d741..652514d 100644 --- a/README.md +++ b/README.md @@ -341,8 +341,10 @@ Additionally, migration guide for clients currently using SyncManager will be av ## Changelogs -### v3.1.1 (NOV 24, 2021) +### v3.1.2 (DEC 01, 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). -- `dns` dependency removed. +- Fixed TypeScript interface in `PreviousMessageListQuery`. +- Deprecated `includeReplies` and `includeParentMessageText`. +- Added `replyType` and `includeParentMessageInfo`. diff --git a/SendBird.d.ts b/SendBird.d.ts index b74ddeb..c8b5c44 100644 --- a/SendBird.d.ts +++ b/SendBird.d.ts @@ -1,5 +1,5 @@ /** - * Type Definitions for Sendbird SDK v3.1.1 + * Type Definitions for Sendbird SDK v3.1.2 * homepage: https://sendbird.com/ * git: https://github.com/sendbird/Sendbird-SDK-JavaScript */ @@ -1644,10 +1644,18 @@ declare namespace SendBird { */ includeReaction: boolean; includeReactions: boolean; + /** + * @deprecated since version v3.0.159, please use {@link replyType} instead + */ includeReplies: boolean; + /** + * @deprecated since version v3.0.159, please use {@link includeParentMessageInfo} instead + */ includeParentMessageText: boolean; includeThreadInfo: boolean; showSubchannelMessagesOnly: boolean; + replyType: ReplyType[keyof ReplyType]; + includeParentMessageInfo: boolean; includePollDetails: boolean; load(limit: number, reverse: boolean, messageType?: number | string, callback?: messageListCallback): Array; diff --git a/SendBird.min.js b/SendBird.min.js index 008925e..0e325c9 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.1.1 + * Sendbird JavaScript SDK v3.1.2 */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("axios"),require("form-data"),require("ws")):"function"==typeof define&&define.amd?define(["axios","form-data","ws"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).SendBird=t(e.axios,e.FormData,e.WebSocket)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e),s=r(t),a=r(n);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=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 s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}var T=function(){function e(){}return Object.defineProperty(e,"OS_VERSION",{get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SDK_VERSION",{get:function(){return"3.1.1"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SDK_MAJOR_VERSION",{get:function(){return e.SDK_VERSION.split(".")[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",{get:function(){return 100},enumerable:!1,configurable:!0}),Object.defineProperty(e,"INTERNAL_CALL",{get:function(){return"ic"},enumerable:!1,configurable:!0}),e}(),O={},U=function(){function e(e){this._container=e}return e.create=function(t,n){return O[t]=new e(n),O[t]},e.get=function(e){return e||(e=Ri.getInstance()._iid),O[e]},Object.defineProperty(e.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),e.prototype.get=function(e){return this._container[e]},e.prototype.set=function(e,t){this._container[e]=t},e.prototype.remove=function(e){this._container.hasOwnProperty(e)&&delete this._container[e]},e}(),k=function(e,t){return(k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}k(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var M=function(){return(M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]1?o-1:0),u=1;u-1&&(K=t)}},{key:"supportedLogLevels",get:function(){return q}},{key:"logLevel",get:function(){return z[Q]},set:function(e){z.includes(e)||(e=Y),Q=z.indexOf(e)}},{key:"defaultLogLevel",get:function(){return Y}},{key:"isDisplayableLogLevel",value:function(e){var t=z.indexOf(e);return 0<=t&&t<=Q}},{key:"log",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i0){var e=this._queue.shift();this.lock(e)}}}]),e}(),Z=function(){function e(t){c(this,e),this.sb=t,this.mutex=new X,this.pingTimer=null,this.pingTimeoutTimer=null}return h(e,[{key:"ping",value:function(){var e=this,t=x.get(this.sb._iid).Command.bPing(),n=U.get(this.sb._iid).container,r=n.wsAdapter,i=n.pongTimeout;r.client.send(t),J.debug("`PING`"),this.pingTimeoutTimer=setTimeout((function(){J.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,t=U.get(this.sb._iid).container.pingInterval;this.mutex.lock((function(n){e.stop(),e.pingTimer=setInterval((function(){e.ping()}),t),n()}))}},{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(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ee=function(){return"undefined"==typeof window&&"undefined"!=typeof process&&("node"===process.title||void 0!==process.versions&&process.versions.node||"[object process]"===String(process))},te=[H.CONNECTION_REQUIRED,H.NETWORK_ERROR,H.ACK_TIMEOUT,H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED,H.FILE_UPLOAD_CANCEL_FAILED,H.REQUEST_CANCELED,500901,500910,900200],ne=[H.SESSION_TOKEN_EXPIRED,H.SESSION_TOKEN_REVOKED,H.USER_DEACTIVATED,H.NON_EXISTING_USER],re=[H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED],ie=function(){function e(){}return e.deepEqual=function(e,t){if(e!==t){var n=M({},e),r=M({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},e.isResendableError=function(e){return e>0&&te.indexOf(e)>=0},e.isAutoResendableError=function(e){return e>0&&re.indexOf(e)>=0},e.isNonAutoReconnectableError=function(e){return e>0&&ne.indexOf(e)>=0},e.isFile=function(e){var t="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t)if(ee()){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 t},e}();!function(e){e.FILE="file",e.BLOB="blob"}(D||(D={}));var se=function(){function e(){}var t;return t=e,e.convertFileToDataUrl=function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){return t(r.result)},r.onerror=function(e){return n(r.error)},r.readAsDataURL(e)}))},e.convertFileToArrayBuffer=function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){return t(r.result)},r.onerror=function(e){return n(r.error)},r.readAsArrayBuffer(e)}))},e.convertDataUrlToByteArray=function(e){for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],r=atob(t[1]),i=r.length,s=new Uint8Array(i);i--;)s[i]=r.charCodeAt(i);return[s,n]},e.convertDataURLtoFile=function(e,n){var r=t.convertDataUrlToByteArray(e),i=r[0],s=r[1];return new File([i],n,{type:s})},e.convertDataURLtoBlob=function(e){var n=t.convertDataUrlToByteArray(e),r=n[0],i=n[1];return new Blob([r],{type:i})},e.convertArrayBufferToFile=function(e,t){return new File([e],t)},e.isFile=function(e){return"File"in window&&e instanceof File},e.isBlob=function(e){return"Blob"in window&&e instanceof Blob},e.convertBlobToBuffer=function(n){return P(void 0,void 0,void 0,(function(){var r;return L(t,(function(t){switch(t.label){case 0:return[4,e.convertFileToArrayBuffer(n)];case 1:return r=t.sent(),[2,Buffer.from(r)]}}))}))},e}(),ae=function(){function e(e){var t=this;this.fields={},e&&Object.keys(e).forEach((function(n){t.fields[n]={value:e[n]},ie.isFile(e[n])&&(t.fields[n].filename=e[n].name)})),this.options={},this.internal=!1,this.upload={reqId:null,deleteRequest:null,progressHandler:null}}return e.prototype.add=function(e,t,n){void 0===n&&(n=null),this.fields[e]={value:t,filename:n}},e.prototype.remove=function(e){this.fields.hasOwnProperty(e)&&delete this.fields[e]},e.prototype.yield=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,l,u,c,d,h,p=this;return L(this,(function(f){switch(f.label){case 0:for(e=!1,t=Object.keys(this.fields),n=0,r=t;n0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.noSessionKey,r=void 0!==n&&n,i=t.accessToken,a=void 0===i?null:i,o=e instanceof s.default&&"function"==typeof e.getHeaders?e.getHeaders():{},l=U.get(this.sb._iid),u=l.container,c=u.appId,d=u.auth,h=u.extensions,p=u.getUserAgentWithExtensions;return o.SendBird="JS,".concat(T.OS_VERSION,",").concat(T.SDK_VERSION,",").concat(c),o["SB-User-Agent"]=encodeURIComponent(p(h)),!r&&d.sessionKey&&(o["Session-Key"]=d.sessionKey),a&&(o["App-Id"]=c,o["Access-Token"]=a),o["Request-Sent-Timestamp"]=(new Date).getTime().toString(),o}},{key:"_createQuery",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{var n=[];return Object.keys(t).forEach((function(e){var r=t[e];if(null!=r){var i="";i="object"===u(r)?Array.isArray(r)?r.map((function(e){return encodeURIComponent("string"==typeof e?e.trim():e)})).join(","):encodeURIComponent(JSON.stringify(r)):encodeURIComponent(r),n.push("".concat(e,"=").concat(i))}})),n.length>0?"".concat(e,"?").concat(n.join("&")):e}catch(t){return J.debug("createWithEncodedGetParams is failed. - ",t),e}}},{key:"_request",value:function(e,t,n,r){var a=this;this.checkRouting((function(o,l){if(o)r(new H("Request failed.",H.REQUEST_FAILED),null);else{var u=a._buildUrl({apiHost:l.apiHost,url:t,params:n});(n?n.yield():Promise.resolve({})).then((function(o){var l=a._createHeader(o,n?n.options:{}),c=[{level:J.supportedLogLevels.DEBUG,messages:["url:",t]},{level:J.supportedLogLevels.DEBUG,messages:["data:",o]}],d=null;switch(e){case"GET":d=a._createQuery(u,o);break;case"POST":case"PUT":d=u;break;case"DELETE":d=a._createQuery(u,o)}var h=null;if("undefined"==typeof ServiceWorker||"undefined"==typeof ServiceWorkerRegistration||"undefined"!=typeof ServiceWorkerContainer||ee()||"function"!=typeof fetch)switch(e){case"GET":h=i.default.get(d,{headers:l,validateStatus:a._validateStatus});break;case"POST":var p=null;if(o instanceof s.default){var f=i.default.CancelToken.source();p=f.token;var _=a.cls.FileMessageQueue,y=n.upload.reqId;y&&(c.push({level:J.supportedLogLevels.DEBUG,messages:["request id:",y]}),_.uploadRequest[y]=f)}h=i.default.post(d,"function"==typeof o.getBuffer?o.getBuffer():o,{headers:l,validateStatus:a._validateStatus,cancelToken:p,onUploadProgress:function(e){n.upload.progressHandler&&n.upload.progressHandler(e,n.upload.reqId)}});break;case"PUT":h=i.default.put(d,o,{headers:l,validateStatus:a._validateStatus});break;case"DELETE":h=i.default.delete(d,{headers:l,validateStatus:a._validateStatus})}else{var g={method:e,headers:l};switch(e){case"GET":break;case"POST":if(o instanceof s.default){if("function"==typeof AbortController){var m=new AbortController,E=m.signal;g.signal=E;var v=a.cls.FileMessageQueue,C=n.upload.reqId;C&&(c.push({level:J.supportedLogLevels.DEBUG,messages:["request id:",C]}),v.uploadRequest[C]=m)}g.body="function"==typeof o.getBuffer?o.getBuffer():o}else l["Content-Type"]="application/json; charset=utf-8",g.body=JSON.stringify(o);break;case"PUT":o instanceof s.default?g.body="function"==typeof o.getBuffer?o.getBuffer():o:(l["Content-Type"]="application/json; charset=utf-8",g.body=JSON.stringify(o))}h=fetch(d,g).then((function(e){return e.json().then((function(t){if(!a._validateStatus(e.status))throw{request:{isAbort:!1},response:{data:t}};return Promise.resolve({data:t})}))}))}J.group("".concat(e," request"),c),c=[],h.then((function(t){try{var i=t.data;"POST"===e&&"function"==typeof n.upload.deleteRequest&&n.upload.deleteRequest(),c.push({level:J.supportedLogLevels.DEBUG,messages:["data:",i]}),r(null,i)}catch(e){throw{code:le,rawError:e}}})).catch((function(i){if(i.code===le)throw i.rawError;"POST"===e&&"function"==typeof n.upload.deleteRequest&&n.upload.deleteRequest();var s=a._handleError(i);if(c.push({level:J.supportedLogLevels.DEBUG,messages:["error:",s]}),t&&n)if(n.options&&n.options.isSessionRefresh)r(s,null);else{var o=U.get(a.sb._iid).container.sessionManager;o.isSessionError(s)?o.refreshSessionIfExpiredError(s).then((function(){return r(new H("Session is refreshed successfully.",H.SESSION_REFRESH_SUCCESS),null)})).catch((function(e){return r(new H("Session refresh failed.",H.SESSION_REFRESH_FAILED),null)})):r(s,null)}else r(s,null)})).finally((function(){return J.group("".concat(e," response"),c)}))}))}}))}},{key:"_validateStatus",value:function(e){return e>=200&&e<400}},{key:"_handleError",value:function(e){var t=e.request,n=e.response;if(t){if(t.isAbort||t.aborted)return new H("Request has been canceled.",H.REQUEST_CANCELED);if(n){var r=n.data,i=r?r.message:"Request failed.",s=r?r.code:H.REQUEST_FAILED;return new H(i,s)}return new H("Request failed.",H.REQUEST_FAILED)}return new H("There was a network error.",H.NETWORK_ERROR)}},{key:"get",value:function(e,t,n){this._request("GET",e,t,n)}},{key:"dummyCall",value:function(e){this._request("GET",null,null,e)}},{key:"post",value:function(e,t,n){this._request("POST",e,t,n)}},{key:"put",value:function(e,t,n){this._request("PUT",e,t,n)}},{key:"delete",value:function(e,t,n){this._request("DELETE",e,t,n)}},{key:"refreshSessionKey",value:function(t,n){var r=this,i=t.accessToken;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_SESSION_KEY.replace("%s",encodeURIComponent(s.userId)),o=new ae;o.options.isSessionRefresh=!0,o.options.noSessionKey=!0,o.options.accessToken=i,r.post(a,o,n)}}))}},{key:"updateCurrentUserInfo",value:function(t,n){var r=this,i=t.nickname,s=t.profileUrl,a=t.profileImage,o=t.preferredLanguages;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=e.Path.USERS_USERID.replace("%s",encodeURIComponent(l.userId)),c=new ae;i&&c.add("nickname",i),s&&c.add("profile_url",s),a&&c.add("profile_file",a,a.name),o&&c.add("preferred_languages",o),r.put(u,c,n)}}))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.ts,s=t.token,a=t.customTypes,o=t.includeEmpty,l=t.includeFrozen;r.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.USERS_USERID_MY_GROUP_CHANNEL_CHANGELOGS.replace("%s",encodeURIComponent(u.userId)),d=new ae({show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0});s&&d.add("token",s),i&&d.add("change_ts",i),a&&a.length>0&&d.add("custom_types",a),"boolean"==typeof o&&d.add("show_empty",o),"boolean"==typeof l&&d.add("show_frozen",l),r.get(c,d,n)}}))}),n)}},{key:"getChannelInvitationPreference",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"getGroupChannelCount",value:function(t,n){var r=this,i=t.memberStateFilter;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=r.cls.GroupChannel,o=e.Path.USERS_USERID_GROUP_CHANNEL_COUNT.replace("%s",encodeURIComponent(s.userId)),l="";switch(i){case a.MemberStateFilter.JOINED:l="joined";break;case a.MemberStateFilter.INVITED:l="invited";break;case a.MemberStateFilter.INVITED_BY_FRIEND:l="invited_by_friend";break;case a.MemberStateFilter.INVITED_BY_NON_FRIEND:l="invited_by_non_friend";break;default:l="all"}var u=new ae({state:l});r.get(o,u,n)}}))}},{key:"getUnreadItemCount",value:function(t,n){var r=this,i=t.keys;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_UNREAD_ITEM_COUNT.replace("%s",encodeURIComponent(s.userId)),o=new ae({item_keys:i});r.get(a,o,n)}}))}},{key:"getTotalUnreadMessageCount",value:function(t,n){var r=this,i=t.customTypesFilter,s=t.superChannelFilter;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_USERID_UNREAD_MESSAGE_COUNT.replace("%s",encodeURIComponent(a.userId)),l=new ae({super_mode:s});null!==i&&i.length>0&&l.add("custom_types",i),r.get(o,l,n)}}))}},{key:"getTotalUnreadChannelCount",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_UNREAD_CHANNEL_COUNT.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"searchMessages",value:function(t,n){var r=this,i=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,l=t.channelUrl,u=t.channelCustomType,c=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.order,p=t.nextToken,f=t.advancedQuery,_=t.targetFields;this.sb.ConnectionManager.ready((function(t,y){if(t)n(t,null);else{var g=e.Path.SEARCH_MESSAGE,m=new ae({limit:s,reverse:a,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),_&&Array.isArray(_)&&m.add("target_fields",_),r.get(g,m,n)}}))}},{key:"markAsReadAll",value:function(t,n){var r=this,i=t.channelUrls;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_MARKASREADALL.replace("%s",encodeURIComponent(s.userId)),o=new ae;i&&o.add("channel_urls",i),r.put(a,o,n)}}))}},{key:"markAsDelivered",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASDELIVERED.replace("%s",encodeURIComponent(i)),l=new ae;s&&l.add("user_id",s),r.put(o,l,n)}}))}},{key:"setChannelInvitationPreference",value:function(t,n){var r=this,i=t.isAutoAccept;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(s.userId)),o=new ae({auto_accept:i});r.put(a,o,n)}}))}},{key:"blockUser",value:function(t,n){var r=this,i=t.blockedUserId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_BLOCK.replace("%s",encodeURIComponent(s.userId)),o=new ae({target_id:i});r.post(a,o,n)}}))}},{key:"unblockUser",value:function(t,n){var r=this,i=t.unblockedUserId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_BLOCK_TARGETID.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"getPushTriggerOption",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setPushTriggerOption",value:function(t,n){var r=this,i=t.pushTriggerOption;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(s.userId)),o=new ae({push_trigger_option:i});r.put(a,o,n)}}))}},{key:"getPushTokens",value:function(t,n){var r=this,i=t.ts,s=t.token,a=t.type;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSH_DEVICE_TOKENS.replace("%s",encodeURIComponent(o.userId)).replace("%s",encodeURIComponent(a)),u=new ae;s&&u.add("token",s),i&&u.add("created_ts",i),r.get(l,u,n)}}))}},{key:"getPushTemplate",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setPushTemplate",value:function(t,n){var r=this,i=t.templateName;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(s.userId)),o=new ae({name:i});r.put(a,o,n)}}))}},{key:"getDoNotDisturb",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setDoNotDisturb",value:function(t,n){var r=this,i=t.doNotDisturbOn,s=t.startHour,a=t.startMin,o=t.endHour,l=t.endMin,u=t.timezone;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(c.userId)),h=new ae({do_not_disturb:i,start_hour:s,start_min:a,end_hour:o,end_min:l,timezone:u});r.put(d,h,n)}}))}},{key:"getSnoozePeriod",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setSnoozePeriod",value:function(t,n){var r=this,i=t.snoozeOn,s=t.startTs,a=t.endTs;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(o.userId)),u=new ae({snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:a});r.put(l,u,n)}}))}},{key:"registerGCMPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(s.userId)),o=new ae({gcm_reg_token:i,always_push:!0});r.post(a,o,n)}}))}},{key:"unregisterGCMPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_GCM_TOKEN.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"unregisterAllGCMPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"registerAPNSPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(s.userId)),o=new ae({apns_device_token:i,always_push:!0});r.post(a,o,n)}}))}},{key:"unregisterAPNSPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_APNS_TOKEN.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"unregisterAllAPNSPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"unregisterAllPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"loadFriendList",value:function(t,n){var r=this,i=t.token,s=t.limit;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.FRIENDS.replace("%s",encodeURIComponent(a.userId)),l=new ae({limit:s,token:i});r.get(o,l,n)}}))}},{key:"getFriendChangeLogsByToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_CHANGE_LOGS.replace("%s",encodeURIComponent(s.userId)),o=new ae;i&&o.add("token",i),r.get(a,o,n)}}))}},{key:"addFriends",value:function(t,n){var r=this,i=t.userIds;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS.replace("%s",encodeURIComponent(s.userId)),o=new ae({user_ids:i});r.post(a,o,n)}}))}},{key:"deleteFriends",value:function(t,n){var r=this,i=t.userIds;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS.replace("%s",encodeURIComponent(s.userId)),o=new ae({user_ids:i});r.delete(a,o,n)}}))}},{key:"uploadFriendDiscoveries",value:function(t,n){var r=this,i=t.discoveries;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_DISCOVERIES.replace("%s",encodeURIComponent(s.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 ae({friend_discoveries:o});r.put(a,l,n)}}))}},{key:"deleteFriendDiscoveries",value:function(t,n){var r=this,i=t.discoveryKeys;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_DISCOVERIES.replace("%s",encodeURIComponent(s.userId)),o=new ae({friend_discovery_keys:i});r.delete(a,o,n)}}))}},{key:"loadUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.userIdsFilter,o=t.metaDataKeyFilter,l=t.metaDataValuesFilter,u=t.nicknameStartsWithFilter;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.USERS,h=new ae({token:i,limit:s});a&&a.length>0&&h.add("user_ids",a),o&&l&&l.length>0&&(h.add("metadatakey",o),h.add("metadatavalues_in",l)),u&&h.add("nickname_startswith",u),r.get(d,h,n)}}))}},{key:"loadBlockedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.userIdsFilter;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_BLOCK.replace("%s",encodeURIComponent(o.userId)),u=new ae({token:i,limit:s});a&&a.length>0&&u.add("user_ids",a),r.get(l,u,n)}}))}},{key:"createUserMetaData",value:function(t,n){var r=this,i=t.metaData;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(s.userId)),o=new ae({metadata:i});r.post(a,o,n)}}))}},{key:"updateUserMetaData",value:function(t,n){var r=this,i=t.metaData,s=t.upsert;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(a.userId)),l=new ae({metadata:i,upsert:s});r.put(o,l,n)}}))}},{key:"deleteUserMetaData",value:function(t,n){var r=this,i=t.metaDataKey;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_METADATA_KEY.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"deleteAllUserMetaData",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"getMessageChangeLogs",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channelUrl,s=t.ts,a=t.timestamp,o=t.token,l=t.isOpenChannel,u=t.includeMetaArray,c=t.includeReaction,d=t.includeReactions,h=t.includeReplies,p=t.includeParentMessageText,f=t.includeThreadInfo,_=t.replyType,y=t.includeParentMessageInfo,g=t.includePollDetails;r.sb.ConnectionManager.ready((function(t,m){if(t)n(t,null);else{var E=l?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)),v=new ae;o&&v.add("token",o),s&&v.add("change_ts",s),a&&v.add("change_ts",a),"boolean"==typeof u&&v.add("with_sorted_meta_array",u),"boolean"==typeof d?v.add("include_reactions",d):v.add("include_reactions","boolean"==typeof c&&c),"boolean"==typeof f&&v.add("include_thread_info",f),"string"==typeof _?v.add("include_reply_type",_):v.add("include_reply_type","boolean"==typeof h&&h?r.cls.BaseMessage.ReplyType.ALL:r.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof y?v.add("include_parent_message_info",y):v.add("include_parent_message_info","boolean"==typeof p&&p),"boolean"==typeof g&&v.add("include_poll_details",g),r.get(E,v,n)}}))}),n)}},{key:"getMyMutedInfo",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.get(l,null,n)}}))}},{key:"loadBannedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl,o=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=o?e.Path.OPENCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(a)),c=new ae({token:i,limit:s});r.get(u,c,n)}}))}},{key:"loadMutedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl,o=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=o?e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(a)),c=new ae({token:i,limit:s});r.get(u,c,n)}}))}},{key:"getMessageList",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channel,s=t.token,a=t.tokenType,o=t.isInclusive,l=t.prevResultSize,u=void 0===l?0:l,c=t.nextResultSize,d=void 0===c?0:c,h=t.shouldReverse,p=t.messageType,f=t.customType,_=t.customTypes,y=t.senderUserIds,g=t.includeMetaArray,m=t.includeReaction,E=t.includeReactions,v=t.includeReplies,C=t.includeParentMessageText,b=t.includeThreadInfo,A=t.replyType,N=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,I=t.includePollDetails,T=t.rootMessageId,O=t.parentMessageId;r.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var c=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url),U=new ae({is_sdk:String(!0),prev_limit:String(u),next_limit:String(d),include:String(o),reverse:String(h)});"timestamp"===a?U.add("message_ts",s):"messageId"===a&&U.add("message_id",String(s)),p&&U.add("message_type",String(p)),Array.isArray(_)&&(0===_.length&&("string"==typeof f?_.push(f):_.push("*")),U.add("custom_types",_)),Array.isArray(y)&&y.length>0&&U.add("sender_ids",y),"boolean"==typeof g&&U.add("with_sorted_meta_array",g),"boolean"==typeof E?U.add("include_reactions",E):U.add("include_reactions","boolean"==typeof m&&m),"boolean"==typeof b&&U.add("include_thread_info",b),"string"==typeof A?U.add("include_reply_type",A):U.add("include_reply_type","boolean"==typeof v&&v?r.cls.BaseMessage.ReplyType.ALL:r.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof N?U.add("include_parent_message_info",N):U.add("include_parent_message_info","boolean"==typeof C&&C),"boolean"==typeof S&&i.isOpenChannel()&&U.add("show_subchannel_messages_only",S),"boolean"==typeof I&&U.add("include_poll_details",I),T&&U.add("root_message_id",T),O&&U.add("parent_message_id",O),r.get(c,U,n)}}))}),n)}},{key:"checkMessageHugeGap",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channelUrl;t.channelType;var s=t.messageType,a=void 0===s?"":s,o=t.customTypes,l=void 0===o?["*"]:o,u=t.senderUserIds,c=void 0===u?[]:u,d=t.includeReactions,h=void 0===d||d,p=t.includeMetaArray,f=void 0!==p&&p,_=t.showSubchannelMessagesOnly,y=void 0!==_&&_,g=t.threshold,m=t.previous,E=t.next,v="".concat(e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_GAP.replace("%s",encodeURIComponent(i))),C=new ae({huge_gap_threshold:g,prev_start_ts:m.from,prev_end_ts:m.to,prev_cache_count:m.cachedCount,next_start_ts:E.from,next_end_ts:E.to,next_cache_count:E.cachedCount,reverse:!0,custom_types:l,message_type:a,include_reactions:h,with_sorted_meta_array:f,show_subchannel_messages_only:y});Array.isArray(c)&&c.length>0&&C.add("sender_ids",c),r.get(v,C,n)}),n)}},{key:"translateUserMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId,o=t.translationTargetLanguages;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",a),c=new ae({target_langs:o});r.post(u,c,n)}}))}},{key:"getMessage",value:function(t,n){var r=this,i=t.channel,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,l=t.includeParentMessageText,u=t.includeThreadInfo,c=t.includeParentMessageInfo,d=t.includePollDetails;this.sb.ConnectionManager.ready((function(t,h){if(t)n(t,null);else{var p=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(s)),f=new ae({is_sdk:String(!0)});"boolean"==typeof a&&f.add("with_sorted_meta_array",a),"boolean"==typeof o&&f.add("include_reactions",o),"boolean"==typeof u&&f.add("include_thread_info",u),"boolean"==typeof c?f.add("include_parent_message_info",c):f.add("include_parent_message_info","boolean"==typeof l&&l),"boolean"==typeof d&&f.add("include_poll_details",d),r.get(p,f,n)}}))}},{key:"deleteMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,n)}}))}},{key:"muteUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.description,o=t.seconds,l=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,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 ae({user_id:s});o&&(o>0||-1!==o)&&d.add("seconds",o),a&&d.add("description",a),r.post(c,d,n)}}))}},{key:"unmuteUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,n)}}))}},{key:"banUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.description,o=t.seconds,l=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,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 ae({user_id:s});a&&d.add("description",a),d.add("seconds",String(o)),r.post(c,d,n)}}))}},{key:"unbanUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,n)}}))}},{key:"getMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.keys;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new ae({keys:a});r.get(l,u,n)}}))}},{key:"createMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaCounter;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new ae({metacounter:a});r.post(l,u,n)}}))}},{key:"updateMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaCounter,o=t.upsert,l=t.mode;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),d=new ae({metacounter:a,upsert:o,mode:l});r.put(c,d,n)}}))}},{key:"deleteMetaCounter",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.key;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a);r.delete(l,null,n)}}))}},{key:"deleteAllMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i));r.delete(o,null,n)}}))}},{key:"getMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.keys;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new ae({keys:a,include_ts:!0});r.get(l,u,n)}}))}},{key:"createMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaData;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new ae({metadata:a,include_ts:!0});r.post(l,u,n)}}))}},{key:"updateMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaData,o=t.upsert;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),c=new ae({metadata:a,upsert:o,include_ts:!0});r.put(u,c,n)}}))}},{key:"deleteMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.key;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a),u=new ae({include_ts:!0});r.delete(l,u,n)}}))}},{key:"deleteAllMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),l=new ae({include_ts:!0});r.delete(o,l,n)}}))}},{key:"loadOperatorList",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.token,o=t.limit;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)),c=new ae({token:a,limit:o});r.get(u,c,n)}}))}},{key:"getOpenChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.internalCall;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),l=new ae({});l.internal=s===T.INTERNAL_CALL,r.get(o,l,n)}}))}},{key:"loadOpenChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.nameKeyword,o=t.urlKeyword,l=t.customTypes,u=t.includeFrozen,c=t.includeMetaData;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.OPENCHANNELS,p=new ae({token:i,limit:s});a&&p.add("name_contains",a),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,n)}}))}},{key:"loadParticipantList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.OPENCHANNELS_CHANNELURL_PARTICIPANTS.replace("%s",encodeURIComponent(a)),u=new ae({token:i,limit:s});r.get(l,u,n)}}))}},{key:"createOpenChannel",value:function(t,n){var r=this,i=t.name,s=t.coverUrlOrImage,a=t.data,o=t.operatorUserIds,l=t.customType,u=t.channelUrl;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.OPENCHANNELS,h=new ae;"string"==typeof s&&h.add("cover_url",s),ie.isFile(s)&&h.add("cover_file",s),null!==u&&"string"==typeof u&&h.add("channel_url",u),null!==i&&"string"==typeof i&&h.add("name",i),a&&h.add("data",a),o&&(Array.isArray(o)?h.add("operators",o):h.add("operators",[o])),l&&h.add("custom_type",l),r.post(d,h,n)}}))}},{key:"updateOpenChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.name,a=t.coverUrlOrImage,o=t.data,l=t.operatorUserIds,u=t.customType;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),h=new ae;"string"==typeof a&&h.add("cover_url",a),ie.isFile(a)&&h.add("cover_file",a,a.name),null!==s&&"string"==typeof s&&h.add("name",s),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,n)}}))}},{key:"deleteOpenChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"getGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.showMember,a=t.internalCall;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),u=new ae({show_member:s,show_read_receipt:!0,show_delivery_receipt:!0});u.internal=a===T.INTERNAL_CALL,r.get(l,u,n)}}))}},{key:"loadGroupChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.includeEmpty,o=t.order,l=t.userIdsFilter,u=t.nicknameContainsFilter,c=t.channelNameContainsFilter,d=t.channelUrlsFilter,h=t.customTypesFilter,p=t.customTypeStartsWithFilter,f=t.memberStateFilter,_=t.superChannelFilter,y=t.publicChannelFilter,g=t.unreadChannelFilter,m=t.metadataOrderKeyFilter,E=t.metadataKey,v=t.metadataValues,C=t.metadataValueStartsWith,b=t.hiddenChannelFilter,A=t.searchFilter,N=t.includeFrozen,S=t.includeMetaData;return oe(this.sb._iid,(function(t){r.sb.ConnectionManager.ready((function(n,I){if(n)t(n,null);else{var T=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(I.userId)),O=new ae({token:i,limit:s,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(a),member_state_filter:f});h&&h.length>0&&O.add("custom_types",h),u&&O.add("members_nickname_contains",u),c&&O.add("name_contains",c),A&&A.hasOwnProperty("search_query")&&A.hasOwnProperty("search_fields")&&(O.add("search_query",A.search_query),O.add("search_fields",A.search_fields)),l&&l.userIds&&l.userIds.length>0&&(l.includeMode?(O.add("members_include_in",l.userIds),O.add("query_type",l.queryType.toUpperCase())):O.add("members_exactly_in",l.userIds)),d&&d.length>0&&O.add("channel_urls",d),O.add("super_mode",_),O.add("public_mode",y),O.add("unread_filter",g),m&&O.add("metadata_order_key",m),E&&O.add("metadata_key",E),v&&v.length>0&&O.add("metadata_values",v),C&&O.add("metadata_value_startswith",C),p&&O.add("custom_type_startswith",p),b&&O.add("hidden_mode",b),"boolean"==typeof N&&O.add("show_frozen",N),"boolean"==typeof S&&O.add("show_metadata",S),r.get(T,O,t)}}))}),n)}},{key:"loadPublicGroupChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.includeEmpty,o=t.order,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,d=t.customTypeStartsWithFilter,h=t.superChannelFilter,p=t.membershipFilter,f=t.metadataOrderKeyFilter,_=t.metadataKey,y=t.metadataValues,g=t.metadataValueStartsWith,m=t.includeFrozen,E=t.includeMetaData;this.sb.ConnectionManager.ready((function(t,v){if(t)n(t,null);else{var C=r.cls.GroupChannel,b=e.Path.GROUPCHANNELS,A=new ae({token:i,limit:s,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(a),public_mode:C.PublicChannelFilter.PUBLIC,public_membership_mode:p});c&&c.length>0&&A.add("custom_types",c),l&&A.add("name_contains",l),u&&u.length>0&&A.add("channel_urls",u),A.add("super_mode",h),f&&A.add("metadata_order_key",f),_&&A.add("metadata_key",_),y&&y.length>0&&A.add("metadata_values",y),g&&A.add("metadata_value_startswith",g),d&&A.add("custom_type_startswith",d),"boolean"==typeof m&&A.add("show_frozen",m),"boolean"==typeof E&&A.add("show_metadata",E),r.get(b,A,n)}}))}},{key:"createGroupChannel",value:function(t,n){var r=this,i=t.isDistinct,s=t.isSuper,a=t.isBroadcast,o=t.isPublic,l=t.channelUrl,u=t.isDiscoverable,c=t.isStrict,d=t.name,h=t.data,p=t.customType,f=t.coverUrl,_=t.coverImage,y=t.accessCode,g=t.isEphemeral,m=t._invitedUserIds,E=void 0===m?[]:m,v=t.operatorUserIds,C=t.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(t,m){if(t)n(t,null);else{var b=e.Path.GROUPCHANNELS,N=new ae({user_ids:[m.userId].concat(A(E)).filter((function(e,t,n){return t===n.indexOf(e)}))});null!==f&&"string"==typeof f&&N.add("cover_url",f),ie.isFile(_)&&N.add("cover_file",_,_.name),null!==l&&N.add("channel_url",l),null!==i&&N.add("is_distinct",i),null!==s&&N.add("is_super",s),null!==a&&N.add("is_broadcast",a),null!==o&&N.add("is_public",o),null!==u&&N.add("is_discoverable",u),null!==c&&N.add("strict",c),null!==g&&N.add("is_ephemeral",g),y&&N.add("access_code",y),null!==d&&"string"==typeof d&&N.add("name",d),h&&N.add("data",h),p&&N.add("custom_type",p),Array.isArray(v)&&v.length>0&&N.add("operator_ids",v),null!==C&&C>-1&&N.add("message_survival_seconds",C),r.post(b,N,n)}}))}},{key:"updateGroupChannel",value:function(t,n){var r=this,i=t.isDistinct,s=t.isPublic,a=t.channelUrl,o=t.isDiscoverable,l=t.name,u=t.data,c=t.customType,d=t.coverUrl,h=t.coverImage,p=t.accessCode,f=t.operatorUserIds,_=t.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(t,y){if(t)n(t,null);else{var g=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(a)),m=new ae;null!==i&&m.add("is_distinct",i),null!==s&&m.add("is_public",s),null!==o&&m.add("is_discoverable",o),null!==p&&m.add("access_code",p),null!==d&&"string"==typeof d&&m.add("cover_url",d),ie.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!==_&&_>-1&&m.add("message_survival_seconds",_),r.put(g,m,n)}}))}},{key:"addOperators",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=void 0!==s&&s,o=t.operatorUserIds;this.sb.ConnectionManager.ready((function(t,s){if(!t){var l=(a?e.Path.OPENCHANNELS_CHANNELURL_OPERATORS:e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS).replace("%s",encodeURIComponent(i)),u=new ae({operator_ids:o});r.post(l,u,n)}}))}},{key:"removeOperators",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=void 0!==s&&s,o=t.operatorUserIds;this.sb.ConnectionManager.ready((function(t,s){if(!t){var l=(a?e.Path.OPENCHANNELS_CHANNELURL_OPERATORS:e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS).replace("%s",encodeURIComponent(i)),u=new ae({operator_ids:o});r.delete(l,u,n)}}))}},{key:"inviteToGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.userIds;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_INVITE.replace("%s",encodeURIComponent(i)),l=new ae({user_ids:s});r.post(o,l,n)}}))}},{key:"acceptInvitation",value:function(t,n){var r=this,i=t.channelUrl,s=t.accessCode;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION.replace("%s",encodeURIComponent(i)),l=new ae({user_id:a.userId});s&&l.add("access_code",s),r.put(o,l,n)}}))}},{key:"declineInvitation",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION.replace("%s",encodeURIComponent(i)),o=new ae({user_id:s.userId});r.put(a,o,n)}}))}},{key:"joinGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.accessCode;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_JOIN.replace("%s",encodeURIComponent(i)),l=new ae({user_id:a.userId});s&&l.add("access_code",s),r.put(o,l,n)}}))}},{key:"leaveGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_LEAVE.replace("%s",encodeURIComponent(i)),o=new ae({user_id:s.userId});r.put(a,o,n)}}))}},{key:"hideGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.hidePreviousMessages,a=t.allowAutoUnhide;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace("%s",encodeURIComponent(i)),u=new ae({user_id:o.userId,hide_previous_messages:s,allow_auto_unhide:a});r.put(l,u,n)}}))}},{key:"unhideGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"freeze",value:function(t,n){var r=this,i=t.channelUrl,s=t.isGroupChannel,a=t.freezing;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.GROUPCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)):e.Path.OPENCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)),u=new ae({freeze:a});r.put(l,u,n)}}))}},{key:"deleteGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"loadMemberList",value:function(t,n){var r=this,i=t.channelUrl,s=t.token,a=t.limit,o=t.mutedMemberFilter,l=t.order,u=t.memberStateFilter,c=t.nicknameStartsWithFilter;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.GROUPCHANNELS_MEMBERS.replace("%s",encodeURIComponent(i)),p=new ae({token:s,limit:a,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,n)}}))}},{key:"report",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.reportCategory,o=t.reportingUserId,l=t.reportDescription;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.REPORT_CHANNELS.replace("%s",encodeURIComponent(s?"open_channels":"group_channels")).replace("%s",encodeURIComponent(i)),d=new ae({report_category:a});null!=o&&d.add("reporting_user_id",o),null!=l&&d.add("report_description",l),r.post(c,d,n)}}))}},{key:"reportUser",value:function(t,n){var r=this,i=t.offendingUserId,s=t.channelUrl,a=t.isOpenChannel,o=t.reportCategory,l=t.reportingUserId,u=t.reportDescription;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.REPORT_USERS.replace("%s",encodeURIComponent(i)),h=new ae({channel_url:s,channel_type:a?"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,n)}}))}},{key:"reportMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId,o=t.reportCategory,l=t.reportingUserId,u=t.reportDescription,c=t.offendingUserId;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.REPORT_MESSAGES.replace("%s",encodeURIComponent(s?"open_channels":"group_channels")).replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a)),p=new ae({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,n)}}))}},{key:"sendUserMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.message,o=t.data,l=t.customType,u=t.translationTargetLanguages,c=t.metaArrays,d=t.mentionType,h=t.mentionedUserIds,p=t.pushNotificationDeliveryOption,f=t.rootMessageId,_=t.parentMessageId,y=t.appleCriticalAlertOptions,g=t.pollId,m=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,E){if(t)n(t,null);else{var v=r.cls.FileMessageParams,C=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),b=new ae({message_type:"MESG",user_id:E.userId,message:a,mention_type:d,mentioned_user_ids:[]});null!=o&&b.add("data",o),null!=l&&b.add("custom_type",l),u&&b.add("translation_target_langs",u),c&&c.length>0&&b.add("sorted_metaarray",c.map((function(e){return e.encode()}))),d===r.cls.BaseMessageParams.MentionType.CHANNEL?b.add("mentioned_user_ids",[]):Array.isArray(h)&&h.length>0&&b.add("mentioned_user_ids",h),p&&p!==v.PushNotificationDeliveryOption.DEFAULT&&b.add("push_option",p),f&&b.add("root_message_id",f),_&&b.add("parent_message_id",_),y&&b.add("apple_critical_alert_options",y.serialize()),"number"==typeof g?b.add("poll_id",g):null===g&&b.add("poll_id",-1),m&&b.add("reply_to_channel",m),r.post(C,b,n)}}))}},{key:"sendFileMessage",value:function(t,n){var r=this,i=t.reqId,s=t.channelUrl,a=t.isOpenChannel,o=t.fileUrl,l=t.fileName,u=t.fileSize,c=t.fileType,d=t.data,h=t.customType,p=t.thumbnailSizes,f=t.requireAuth,_=t.metaArrays,y=t.mentionType,g=t.mentionedUserIds,m=t.pushNotificationDeliveryOption,E=t.rootMessageId,v=t.parentMessageId,C=t.appleCriticalAlertOptions,b=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,A){if(t)n(t,null);else{var N=r.cls.FileMessageParams,S=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(s)),I=new ae({message_type:"FILE",user_id:A.userId,url:o,mention_type:y,mentioned_user_ids:[],req_id:i});null!=l&&I.add("file_name",l),null!=u&&I.add("file_size",u),null!=c&&I.add("file_type",c),null!=d&&I.add("custom_field",d),null!=h&&I.add("custom_type",h),p&&I.add("thumbnails",p),f&&I.add("require_auth",f),_&&_.length>0&&I.add("sorted_metaarray",_.map((function(e){return e.encode()}))),y===r.cls.BaseMessageParams.MentionType.CHANNEL?I.add("mentioned_user_ids",[]):Array.isArray(g)&&g.length>0&&I.add("mentioned_user_ids",g),m&&m!==N.PushNotificationDeliveryOption.DEFAULT&&I.add("push_option",m),E&&I.add("root_message_id",E),v&&I.add("parent_message_id",v),C&&I.add("apple_critical_alert_options",C.serialize()),b&&I.add("reply_to_channel",b),r.post(S,I,n)}}))}},{key:"uploadFile",value:function(t,n){var r=this,i=t.file,s=t.thumbnailSizes,a=t.channelUrl,o=t.progressHandler,l=t.reqId;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=U.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 ae;if(h.add("file",i,i.name),a&&"string"==typeof a&&h.add("channel_url",a),s)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,n)}}))}},{key:"getMyPushTriggerOption",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.get(a,null,n)}}))}},{key:"setMyPushTriggerOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pushTriggerOption,a=t.enable;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s",encodeURIComponent(o.userId)).replace("%s",encodeURIComponent(i)),u=new ae;s&&u.add("push_trigger_option",s),"boolean"==typeof a&&u.add("enable",a),r.put(l,u,n)}}))}},{key:"setMyCountPreference",value:function(t,n){var r=this,i=t.channelUrl,s=t.countPreference;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_COUNT_PREFERENCE.replace("%s",encodeURIComponent(a.userId)).replace("%s",encodeURIComponent(i)),l=new ae({count_preference:s});r.put(o,l,n)}}))}},{key:"resetMyHistory",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_RESET_USER_HISTORY.replace("%s",encodeURIComponent(i));r.put(a,null,n)}}))}},{key:"addReaction",value:function(t,n){var r=this,i=t.isGroupChannel,s=t.channelUrl,a=t.messageId,o=t.key;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=i?e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)),c=new ae({reaction:o});r.post(u,c,n)}}))}},{key:"deleteReaction",value:function(t,n){var r=this,i=t.isGroupChannel,s=t.channelUrl,a=t.messageId,o=t.key;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=i?e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)),c=new ae({reaction:o});r.delete(u,c,n)}}))}},{key:"getAllEmoji",value:function(t){var n=this;this.sb.ConnectionManager.ready((function(r,i){r?t(r,null):n.get(e.Path.EMOJI_CATEGORIES,null,t)}))}},{key:"getEmojiCategory",value:function(t,n){var r=this,i=t.categoryId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.EMOJI_CATEGORIES_CATEGORYID.replace("%s",i);r.get(a,null,n)}}))}},{key:"getEmoji",value:function(t,n){var r=this,i=t.emojiKey;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.EMOJIS_EMOJIKEY.replace("%s",i);r.get(a,null,n)}}))}},{key:"getAllowFriendDiscovery",value:function(t){var n=this;this.sb.ConnectionManager.ready((function(r,i){if(r)t(r,null);else{var s=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(i.userId));n.get(s,null,t)}}))}},{key:"setAllowFriendDiscovery",value:function(t,n){var r=this,i=t.allowFriendDiscovery;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(s.userId)),o=new ae;"boolean"==typeof i&&o.add("allow_friend_discovery",i),r.put(a,o,n)}}))}},{key:"getPollList",value:function(t,n){var r=this,i=t.channelUrl,s=t.token,a=t.limit;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS,u=new ae({channel_url:i});s&&u.add("token",s),a&&u.add("limit",a),r.get(l,u,n)}}))}},{key:"getPoll",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.showPartialVoters;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID.replace("%s",s),u=new ae({channel_url:i});"boolean"==typeof a&&u.add("show_partial_voter_list",a),r.get(l,u,n)}}))}},{key:"createPoll",value:function(t,n){var r=this,i=t.title,s=t.options,a=t.data,o=t.isAnonymous,l=t.allowUserSuggestion,c=t.allowMultipleVotes,d=t.closeAt;this.sb.ConnectionManager.ready((function(t,h){if(t)n(t,null);else{var p=e.Path.POLLS,f=new ae({title:i,options:s});"object"===u(a)&&f.add("data",a),"boolean"==typeof o&&f.add("is_anonymous",o),"boolean"==typeof l&&f.add("allow_user_suggestion",l),"boolean"==typeof c&&f.add("allow_multiple_votes",c),"number"==typeof d&&f.add("close_at",d),r.post(p,f,n)}}))}},{key:"updatePoll",value:function(t,n){var r=this,i=t.pollId,s=t.title,a=t.options,o=t.data,l=t.isAnonymous,c=t.allowUserSuggestion,d=t.allowMultipleVotes,h=t.closeAt;this.sb.ConnectionManager.ready((function(t,p){if(t)n(t,null);else{var f=e.Path.POLLS_POLLID.replace("%s",i),_=new ae;"string"==typeof s&&_.add("title",s),Array.isArray(a)&&_.add("options",a),"object"===u(o)&&_.add("data",o),"boolean"==typeof l&&_.add("is_anonymous",l),"boolean"==typeof c&&_.add("allow_user_suggestion",c),"boolean"==typeof d&&_.add("allow_multiple_votes",d),"number"==typeof h&&_.add("close_at",h),r.put(f,_,n)}}))}},{key:"deletePoll",value:function(t,n){var r=this,i=t.pollId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.POLLS_POLLID.replace("%s",i);r.delete(a,null,n)}}))}},{key:"votePoll",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionIds;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_VOTE.replace("%s",s),u=new ae({channel_url:i});Array.isArray(a)&&u.add("option_ids",a),r.put(l,u,n)}}))}},{key:"closePoll",value:function(t,n){var r=this,i=t.pollId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.POLLS_POLLID_CLOSE.replace("%s",i);r.put(a,null,n)}}))}},{key:"getPollOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionId;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",s).replace("%s",a),u=new ae({channel_url:i});r.get(l,u,n)}}))}},{key:"addPollOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.text;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS.replace("%s",s),u=new ae({channel_url:i,text:a});r.post(l,u,n)}}))}},{key:"updatePollOption",value:function(t,n){var r=this,i=t.pollId,s=t.optionId,a=t.text;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",i).replace("%s",s),u=new ae({text:a});r.put(l,u,n)}}))}},{key:"deletePollOption",value:function(t,n){var r=this,i=t.pollId,s=t.optionId;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",i).replace("%s",s);r.delete(o,null,n)}}))}},{key:"getPollOptionVoterList",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionId,o=t.token,l=t.limit;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.POLLS_POLLID_OPTIONS_OPTIONID_VOTERS.replace("%s",s).replace("%s",a),d=new ae({channel_url:i});o&&d.add("token",o),l&&d.add("limit",l),r.get(c,d,n)}}))}}],[{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_MESSAGES_GAP:"/group_channels/%s/messages_gap",GROUPCHANNELS_CHANNELURL_SCHEDULED_MESSAGES:"/group_channels/%s/scheduled_messages",GROUPCHANNELS_CHANNELURL_MEMBERS:"/group_channels/%s/members",GROUPCHANNELS_CHANNELURL_METADATA:"/group_channels/%s/metadata",GROUPCHANNELS_CHANNELURL_METADATA_KEY:"/group_channels/%s/metadata/%s",GROUPCHANNELS_CHANNELURL_METACOUNTER:"/group_channels/%s/metacounter",GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY:"/group_channels/%s/metacounter/%s",GROUPCHANNELS_RESET_USER_HISTORY:"/group_channels/%s/reset_user_history",GROUPCHANNELS_OPERATORS:"/group_channels/%s/operators",GROUPCHANNELS_MEMBERS:"/group_channels/%s/members",GROUPCHANNELS_CHANNELURL_BAN:"/group_channels/%s/ban",GROUPCHANNELS_CHANNELURL_BAN_USERID:"/group_channels/%s/ban/%s",GROUPCHANNELS_CHANNELURL_MUTE:"/group_channels/%s/mute",GROUPCHANNELS_CHANNELURL_MUTE_USERID:"/group_channels/%s/mute/%s",GROUPCHANNELS_CHANNELURL_FREEZE:"/group_channels/%s/freeze",GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION:"/group_channels/%s/messages/%s/reactions",STORAGE_FILE:"/storage/file",STORAGE_PROFILE:"/storage/profile_image",FRIENDS:"/users/%s/friends",FRIENDS_CHANGE_LOGS:"/users/%s/friends/changelogs",FRIENDS_DISCOVERIES:"/users/%s/friend_discoveries",SEARCH_MESSAGE:"/search/messages",REPORT_USERS:"/report/users/%s",REPORT_CHANNELS:"/report/%s/%s",REPORT_MESSAGES:"/report/%s/%s/messages/%s",EMOJIS_EMOJIKEY:"/emojis/%s",EMOJI_CATEGORIES:"/emoji_categories",EMOJI_CATEGORIES_CATEGORYID:"/emoji_categories/%s",POLLS:"/polls",POLLS_POLLID:"/polls/%s",POLLS_POLLID_VOTE:"/polls/%s/vote",POLLS_POLLID_CLOSE:"/polls/%s/close",POLLS_POLLID_OPTIONS:"/polls/%s/options",POLLS_POLLID_OPTIONS_OPTIONID:"/polls/%s/options/%s",POLLS_POLLID_OPTIONS_OPTIONID_VOTERS:"/polls/%s/options/%s/voters"}}}]),e}(),ce=function(){function e(t,n){c(this,e),this.sb=t,this.ws=null,this.wsHost=null,this.WebSocket=null,this.handler=n||new e.ConnectionHandler,this.explicitDisconnect=!1,this.lastActiveMillis=0;try{this.WebSocket="undefined"==typeof WebSocket?a.default:WebSocket}catch(e){this.WebSocket=WebSocket}}return h(e,[{key:"connect",value:function(e,t,n){var r=this;J.debug("`WebSocketClient.connect` called.");var i=U.get(this.sb._iid).container,s=i.pinger,a=i.auth,o=i.extensions,l=i.getUserAgentWithExtensions,u=i.sessionManager;this.wsHost=n;try{var c="/?p=JS&pv="+encodeURIComponent(T.OS_VERSION)+"&sv="+encodeURIComponent(T.SDK_VERSION)+"&ai="+encodeURIComponent(this.sb.getApplicationId());if(a.sessionKey?c+="&key="+encodeURIComponent(a.sessionKey):c+="&user_id="+encodeURIComponent(e)+"&access_token="+encodeURIComponent(t),c+="&active=1",c+="&SB-User-Agent="+encodeURIComponent(l(o)),c+="&Request-Sent-Timestamp="+(new Date).getTime().toString(),c+="&include_extra_data="+encodeURIComponent(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"].join(",")),u.handler&&(c+="&expiring_session=1"),this.sb.Options.includePollDetails&&(c+="&include_poll_details=1"),c+="&use_local_cache=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){J.debug("`window` object does not exist.")}var d=!1;this.ws.onopen=function(e){J.debug("`WebSocket.onopen` called."),r.handler.onOpen(e)},this.ws.onmessage=function(e){r.active();for(var t=e.data.split("\n"),n=0;n-1&&this._observers.splice(t,1)},e}(),fe=function(){},_e={NAME_ALPHABETICAL:["name","-pk"],CHRONOLOGICAL:["-createdAt","-pk"],LATEST_LAST_MESSAGE:["-lastMessageCreatedAt","-createdAt","-pk"]},ye={LATEST:["channelUrl","-createdAt","-messageId"],LATEST_UNSENT:["channelUrl","sendingStatus","createdAt"]},ge=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,i=Math.floor((n+r)/2);n0)r=i,i=Math.floor((n+r)/2);else{if(!(s<0))return i;n=i+1,i=Math.floor((n+r)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length},me=function(e){var t=e.channel,n=e.ts,r=e.prevLimit,i=void 0===r?0:r,s=e.nextLimit,a=void 0===s?0:s,o=e.filter,l={channel:t,token:n,tokenType:"timestamp",isInclusive:!0,prevResultSize:i,nextResultSize:a,shouldReverse:!1,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeReplies:!0,includeParentMessageText:!0,showSubchannelMessagesOnly:!0};if(o){var u=o.messageType,c=o.customTypes,d=o.senderUserIds;u&&(l.messageType=u),c.length>0&&(l.customTypes=c),d.length>0&&(l.senderUserIds=d)}return l},Ee=function(e,t,n){if(n.length>0){var r=n.map((function(e){return e.createdAt}));t.includes("prev")&&(e.top=Math.min.apply(Math,w([e.top],r,!1))),t.includes("next")&&(e.bottom=Math.max.apply(Math,w([e.bottom],r,!1)))}},ve=function(e){return new Promise((function(t,n){setTimeout((function(){return t()}),e)}))},Ce={};!function(e){e.SUCCEEDED="succeeded",e.UNSENT="unsent"}(de||(de={}));var be,Ae=function(){function e(e){var t=e.iid,n=e.collections;this._iid=t,this._collections=n,Ce[t]=this}return e.of=function(e){return Ce[e]},e.prototype._serialize=function(e){return e.serialize()},e.prototype._deserialize=function(e){if(e){var t=M(M({},e),{messageId:parseInt(e.messageId)}),n=x.get(this._iid),r=n.UserMessage,i=n.FileMessage,s=n.AdminMessage;if("user"===t.messageType)return r.buildFromSerializedData(t);if("file"===t.messageType)return i.buildFromSerializedData(t);if("admin"===t.messageType)return s.buildFromSerializedData(t)}return null},e.deserialize=function(e,t){if(t){var n=M(M({},t),{messageId:parseInt(t.messageId)}),r=x.get(e),i=r.UserMessage,s=r.FileMessage,a=r.AdminMessage;if("user"===n.messageType)return i.buildFromSerializedData(n);if("file"===n.messageType)return s.buildFromSerializedData(n);if("admin"===n.messageType)return a.buildFromSerializedData(n)}return null},Object.defineProperty(e.prototype,"_localCacheEnabled",{get:function(){return U.get(this._iid).get("localCacheEnabled")},enumerable:!1,configurable:!0}),e.prototype._fetch=function(e,t,n){return P(this,void 0,void 0,(function(){var r,i,s=this;return L(this,(function(a){switch(a.label){case 0:return this._localCacheEnabled?(r={where:function(r){if(!r)return!1;if(e&&r.channelUrl!==e)return!1;if(n.backward){if(r.createdAt<=n.token)return!1}else if(r.createdAt>=n.token)return!1;return!!t.match(s._deserialize(r))},index:"UnsentMessage"===n.collection.name?ye.LATEST_UNSENT:ye.LATEST,backward:n.backward},[4,n.collection.query(r)]):[3,3];case 1:return[4,a.sent().fetch({limit:n.limit})];case 2:return i=a.sent(),[2,Promise.all(i.map((function(e){return P(s,void 0,void 0,(function(){var t,r,i;return L(this,(function(s){switch(s.label){case 0:return t=this._deserialize(e),(r=e.messageParams)&&r.file?(i=t._messageParams,[4,n.collection.getBlob(r.file)]):[3,2];case 1:i._file=s.sent(),s.label=2;case 2:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},e.fetch=function(t,n,r){return P(this,void 0,void 0,(function(){var i,s,a=this;return L(this,(function(o){switch(o.label){case 0:return i={where:function(i){if(!i)return!1;if(r.backward){if(i.createdAt<=r.token)return!1}else if(i.createdAt>=r.token)return!1;return!!n.match(e.deserialize(t,i))},index:"UnsentMessage"===r.collection.name?ye.LATEST_UNSENT:ye.LATEST,backward:r.backward},[4,r.collection.query(i)];case 1:return[4,o.sent().fetch({limit:r.limit})];case 2:return s=o.sent(),[2,Promise.all(s.map((function(n){return P(a,void 0,void 0,(function(){var i,s,a;return L(this,(function(o){switch(o.label){case 0:return i=e.deserialize(t,n),(s=n.messageParams)&&s.file?(a=i._messageParams,[4,r.collection.getBlob(s.file)]):[3,2];case 1:a.file=o.sent(),o.label=2;case 2:return[2,i]}}))}))})))]}}))}))},e.prototype.get=function(e,t){return P(this,void 0,void 0,(function(){var n,r;return L(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?(n=this.getMessageCollectionByType(t),r=this._deserialize,[4,n.getByKey(e)]):[3,2];case 1:return[2,r.apply(this,[i.sent()])];case 2:return[2,null]}}))}))},e.prototype.getMessageCollectionByType=function(e){return e?this._collections[e]:this._collections.succeeded},e.prototype.getPreviousAndNextMessages=function(e,t,n,r,i){return void 0===r&&(r=30),P(this,void 0,void 0,(function(){var s,a;return L(this,(function(o){switch(o.label){case 0:return[4,this.getPreviousMessages(e,t,n,r/2,i)];case 1:return s=o.sent(),[4,this.getNextMessages(e,t,n,r/2,i)];case 2:return a=o.sent(),[2,function(e){for(var t=[],n={},r=0,i=e;ri.createdAt||i.createdAt>r)&&t.match(a._deserialize(i)))},index:ye.LATEST},[4,this.getMessageCollectionByType(i).query(s)]):[3,3];case 1:return[4,o.sent().count()];case 2:return[2,o.sent()];case 3:return[2,0]}}))}))},e.prototype.upsert=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i=this;return L(this,(function(s){switch(s.label){case 0:return this._localCacheEnabled?(n=this.getMessageCollectionByType(t),[4,Promise.all(e.map((function(e){return P(i,void 0,void 0,(function(){var t,r;return L(this,(function(i){switch(i.label){case 0:return(t=e.serialize())?((t=M({},t)).messageParams&&(t.messageParams=M({},t.messageParams)),e.sendingStatus&&"succeeded"!==e.sendingStatus?t.messageId="unsent-".concat(e.reqId):t.messageId="".concat(e.messageId),e.isFileMessage()&&e._messageParams&&e._messageParams.file?[4,n.saveBlob(e._messageParams.file,e.reqId)]:[3,2]):[3,2];case 1:r=i.sent(),t.messageParams.file=r,i.label=2;case 2:return[2,t]}}))}))})))]):[3,3];case 1:return r=s.sent(),[4,n.upsertMany(r)];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e,t){return P(this,void 0,void 0,(function(){return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return n.sent(),[4,this.getMessageCollectionByType(t).removeIf({messageId:{"/in":e.map((function(e){return"".concat(e)}))}})];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.removeUnsentMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return t=e.channelUrl,n=e.sendingStatus,r=e.reqIds,i=[],this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return o.sent(),s=this.getMessageCollectionByType(de.UNSENT),a={channelUrl:{"=":t}},n&&(a.sendingStatus={"=":n}),r&&r.length>0&&(a.reqId={"/in":r}),[4,s.removeIf(a)];case 2:i=o.sent(),o.label=3;case 3:return[2,i]}}))}))},e.prototype.removeFailedMessages=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s;return L(this,(function(a){switch(a.label){case 0:return n=[],this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return a.sent(),r=this.getMessageCollectionByType(de.UNSENT),i=Ri.getInstance(this._iid),s={channelUrl:{"=":e},sendingStatus:{"=":i.MessageSendingStatus.FAILED}},t&&t.length>0&&(s.reqId={"/in":t}),[4,r.removeIf(s)];case 2:n=a.sent(),a.label=3;case 3:return[2,n]}}))}))},e.prototype.clearByChannelUrl=function(e){return P(this,void 0,void 0,(function(){var t=this;return L(this,(function(n){switch(n.label){case 0:return[4,Promise.all(Object.keys(de).map((function(n){var r=t.getMessageCollectionByType(de[n]),i={channelUrl:{"=":e}};return r.removeIf(i)})))];case 1:return n.sent(),[2]}}))}))},e.prototype.clear=function(e){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this.getMessageCollectionByType(e).clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAll=function(){return P(this,void 0,void 0,(function(){var e=this;return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,Promise.all(Object.keys(de).map((function(t){return e.clear(de[t])})))]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAbove=function(e,t){return P(this,void 0,void 0,(function(){return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?[4,this.getMessageCollectionByType(t).removeIf({createdAt:{"<":e}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},e}();!function(e){e[e.EVENT_CHANNEL_CHANGED=0]="EVENT_CHANNEL_CHANGED",e[e.EVENT_USER_RECEIVED_INVITATION=1]="EVENT_USER_RECEIVED_INVITATION",e[e.EVENT_USER_DECLINED_INVITATION=2]="EVENT_USER_DECLINED_INVITATION",e[e.EVENT_USER_JOINED=3]="EVENT_USER_JOINED",e[e.EVENT_USER_LEFT=4]="EVENT_USER_LEFT",e[e.EVENT_CHANNEL_ENTER=5]="EVENT_CHANNEL_ENTER",e[e.EVENT_CHANNEL_EXIT=6]="EVENT_CHANNEL_EXIT",e[e.EVENT_CHANNEL_FROZEN=7]="EVENT_CHANNEL_FROZEN",e[e.EVENT_CHANNEL_UNFROZEN=8]="EVENT_CHANNEL_UNFROZEN",e[e.EVENT_CHANNEL_HIDDEN=9]="EVENT_CHANNEL_HIDDEN",e[e.EVENT_CHANNEL_UNHIDDEN=10]="EVENT_CHANNEL_UNHIDDEN",e[e.EVENT_TYPING_STATUS_UPDATED=11]="EVENT_TYPING_STATUS_UPDATED",e[e.EVENT_OPERATOR_UPDATED=12]="EVENT_OPERATOR_UPDATED",e[e.EVENT_CHANNEL_METADATA_UPDATED=13]="EVENT_CHANNEL_METADATA_UPDATED",e[e.EVENT_CHANNEL_METADATA_DELETED=14]="EVENT_CHANNEL_METADATA_DELETED",e[e.EVENT_CHANNEL_METACOUNTER_UPDATED=15]="EVENT_CHANNEL_METACOUNTER_UPDATED",e[e.EVENT_CHANNEL_METACOUNTER_DELETED=16]="EVENT_CHANNEL_METACOUNTER_DELETED",e[e.EVENT_CHANNEL_DELETED=17]="EVENT_CHANNEL_DELETED",e[e.EVENT_USER_MUTED=18]="EVENT_USER_MUTED",e[e.EVENT_USER_UNMUTED=19]="EVENT_USER_UNMUTED",e[e.EVENT_USER_BANNED=20]="EVENT_USER_BANNED",e[e.EVENT_USER_UNBANNED=21]="EVENT_USER_UNBANNED",e[e.EVENT_MESSAGE_RECEIVED=22]="EVENT_MESSAGE_RECEIVED",e[e.EVENT_MESSAGE_SENT=23]="EVENT_MESSAGE_SENT",e[e.EVENT_MESSAGE_UPDATED=24]="EVENT_MESSAGE_UPDATED",e[e.EVENT_MESSAGE_DELETED=25]="EVENT_MESSAGE_DELETED",e[e.EVENT_READ_RECEIPT_UPDATED=26]="EVENT_READ_RECEIPT_UPDATED",e[e.EVENT_DELIVERY_RECEIPT_UPDATED=27]="EVENT_DELIVERY_RECEIPT_UPDATED",e[e.EVENT_MENTION=28]="EVENT_MENTION",e[e.EVENT_REACTION_UPDATED=29]="EVENT_REACTION_UPDATED",e[e.EVENT_THREAD_INFO_UPDATED=30]="EVENT_THREAD_INFO_UPDATED",e[e.CHANNEL_BACKGROUND=1e3]="CHANNEL_BACKGROUND",e[e.CHANNEL_CHANGELOG=1001]="CHANNEL_CHANGELOG",e[e.MESSAGE_BACKGROUND=1002]="MESSAGE_BACKGROUND",e[e.MESSAGE_FILL=1003]="MESSAGE_FILL",e[e.MESSAGE_CHANGELOG=1004]="MESSAGE_CHANGELOG",e[e.LOCAL_MESSAGE_PENDING_CREATED=2e3]="LOCAL_MESSAGE_PENDING_CREATED",e[e.LOCAL_MESSAGE_FAILED=2001]="LOCAL_MESSAGE_FAILED",e[e.LOCAL_MESSAGE_CANCELED=2002]="LOCAL_MESSAGE_CANCELED",e[e.LOCAL_MESSAGE_RESEND_STARTED=2003]="LOCAL_MESSAGE_RESEND_STARTED",e[e.MESSAGE_COLLECTION_FILTER_MISMATCH=2004]="MESSAGE_COLLECTION_FILTER_MISMATCH"}(be||(be={}));var Ne,Se={},Ie=function(){function e(){this._observers=[]}return e.of=function(t){return Se[t]||(Se[t]=new e),Se[t]},e.prototype.addObserver=function(e){this._observers.push(e)},e.prototype.removeObserver=function(e){var t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)},e.prototype.send=function(e){for(var t=0,n=this._observers;t0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=JSON.parse(window.localStorage[n._resolversKey]),t=n._localResolversData.map((function(e){return e.key})),r=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(n._resolversKey,JSON.stringify(r)),n._localAcquiredKeys.forEach((function(e){return n.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if($())return this.numLocks-Oe[this._holdersKey].length;var e=JSON.parse(window.localStorage[this._holdersKey]);return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return $()?Ue[this._resolversKey].length:JSON.parse(window.localStorage[this._resolversKey]).length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=JSON.parse(window.localStorage[this._resolversKey]);return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){return $()?ke[this._chainProcessStateKey]:JSON.parse(window.localStorage[this._chainProcessStateKey])},e.prototype._setProcessChainAcquireRunning=function(e){$()?ke[this._chainProcessStateKey]=e:window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e))},e.prototype._processChainResolve=function(){return P(this,void 0,void 0,(function(){var e;return L(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,(n=this._backOffDelay,P(void 0,void 0,void 0,(function(){return L(this,(function(e){return[2,new Promise((function(e){return setTimeout(e,n)}))]}))})))]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),$()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}var n}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=Be.BACKGROUND_SYNC_CLOSE),P(this,void 0,void 0,(function(){var t,n=this;return L(this,(function(r){return $()?[2,new Promise((function(t){var r={key:Te(),resolver:function(e){return t(e)},priority:e};switch(e){case Be.USER_CALL:case Be.FILL:case Be.BACKGROUND_SYNC_OPEN:for(var i=Ue[n._resolversKey],s=-1,a=0;ai[a].priority&&(s=a);if(s>=0){Ue[n._resolversKey].splice(s,0,r);break}case Be.BACKGROUND_SYNC_CLOSE:Ue[n._resolversKey].push(r)}n._processChainResolve()}))]:(t=JSON.parse(window.localStorage[this._resolversKey]),[2,new Promise((function(r){var i=Te(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e};switch(e){case Be.USER_CALL:case Be.FILL:case Be.BACKGROUND_SYNC_OPEN:for(var o=-1,l=0;lt[l].priority&&(o=l);if(o>=0){t.splice(o,0,s),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._localResolversData.splice(o,0,a);break}case Be.BACKGROUND_SYNC_CLOSE:t.push(s),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._localResolversData.push(a)}n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(JSON.parse(window.localStorage[this._holdersKey]),$()){if((t=Oe[this._holdersKey].indexOf(e))>=0)return Oe[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else{var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=w([],n,!0);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var i=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(i),!0}}return!1},e.prototype._tryResolve=function(){if(JSON.parse(window.localStorage[this._holdersKey]),$()){if(Oe[this._holdersKey].length=2e3},enumerable:!1,configurable:!0}),e}(),De=function(){function e(e,t){this._source=e,this._sendingStatus=t}return Object.defineProperty(e.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFromEvent",{get:function(){return this._source>=2e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendingStatus",{get:function(){return this._sendingStatus},enumerable:!1,configurable:!0}),e}(),He=function(){function e(){this.messageType="",this.customTypes=[],this.senderUserIds=[],this.sendingStatus=null}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){if(this.messageType&&this.messageType!==e.messageType)return!1;if(this.customTypes.length>0&&!this.customTypes.includes(e.customType))return!1;if(this.senderUserIds.length>0){if(!e.isUserMessage()&&!e.isFileMessage())return!1;if(!this.senderUserIds.includes(e.sender.userId))return!1}return!this.sendingStatus||this.sendingStatus===e.sendingStatus},e}(),Fe=function(){function e(e){var t=e.top,n=e.bottom;this.top=t,this.bottom=n}return e.prototype.include=function(e){return this.top<=e&&e<=this.bottom},e.prototype.overlap=function(e){return this.include(e.top)||this.include(e.bottom)},e}(),Ge={},xe=function(){function e(e){var t=this,n=e.iid,r=e.channel,i=e.limit,s=void 0===i?Ye:i;this._prevSync=null,this._nextSync=null,this._syncRange=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:-1}),this._isPrevSyncComplete=!1,this._isNextSyncComplete=!1,this._iid=n,this._channel=r,this._limit=s;var a,o,l=x.get(this._iid).BaseChannel,u=U.get(this._iid),c=u.get("currentUserId"),d=u.get("store"),h=u.get("apiClient"),p=Ae.of(this._iid),f=Ie.of(this._iid),_=(a=c,o=this._channel.url,"sendbird:".concat(a,"@channel/").concat(o,"/message/sync")),y=u.container.concurrentCallLimit,g=u.container.backOffDelay;this._prevSync=new Le(_,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,a,o,u,c=this;return L(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:null},[4,d.get(_)];case 1:return(t=y.sent())&&t.isPrevSyncComplete?[3,5]:(t&&(this._syncRange=t.range,this._isPrevSyncComplete=t.isPrevSyncComplete),n=me({channel:this._channel,ts:this._syncRange.top,prevLimit:this._limit}),[4,h.getMessageList(n)]);case 2:return i=y.sent(),s=i.messages.map((function(e){return l.buildMessage(e,c._channel)})),a=this.getMinCreatedAt(s),this._syncRange.top=Math.min(this._syncRange.top,a),this._syncRange.bottom<0&&(this._syncRange.bottom=this.getMaxCreatedAt(s)),this._isPrevSyncComplete=s.lengtht&&(t=n)})),t},e}(),je={},Ve=function(){function e(e){var t=this,n=e.iid,r=e.channel;this._token=0,this._sync=null,this._iid=n,this._channel=r;var i,s,a=x.get(this._iid).BaseChannel,o=U.get(this._iid),l=o.get("currentUserId"),u=o.get("store"),c=o.get("apiClient"),d=o.container.localCacheEnabled,h=Ae.of(this._iid),p=Ie.of(this._iid),f=(i=l,s=this._channel.url,"sendbird:".concat(i,"@channel/").concat(s,"/message/changelogs"));this._sync=new Le(f,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,l,_,y=this;return L(this,(function(g){switch(g.label){case 0:return e={hasNext:!0,nextParams:""},d?[4,u.get(f)]:[3,2];case 1:return n=g.sent(),[3,3];case 2:n=null,g.label=3;case 3:return t=n,this._token=t?t.token:o.get("firstConnectedAt")/1e3,i={channelUrl:this._channel.url,isOpenChannel:this._channel.isOpenChannel(),includeMetaArray:!1,includeReactions:!0,includeReplies:!0,includeParentMessageText:!0,includeThreadInfo:!0},"number"==typeof this._token?i.timestamp=this._token:i.token=this._token,[4,c.getMessageChangeLogs(i)];case 4:return s=g.sent(),l={updatedMessages:s.updated.map((function(e){return a.buildMessage(e,y._channel)})),deletedMessageIds:s.deleted.map((function(e){return parseInt(e.message_id)}))},e.hasNext=s.has_more,e.nextParams=this._token=s.next,d?[4,h.upsert(l.updatedMessages)]:[3,8];case 5:return g.sent(),[4,h.remove(l.deletedMessageIds)];case 6:return g.sent(),[4,u.set({key:f,value:{token:this._token},generation:1})];case 7:g.sent(),g.label=8;case 8:return _={source:be.MESSAGE_CHANGELOG,payload:M({channel:r},l)},p.send(_),[2,e]}}))}))}))}return e.of=function(t,n){return je[t]||(je[t]={}),je[t][n.url]||(je[t][n.url]=new e({iid:t,channel:n})),je[t][n.url]},e.prototype.resume=function(){this._sync.resume(null,!0)},e.prototype.pause=function(){this._sync.stop()},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(Me||(Me={}));var Be,Ke=function(){function e(){this._onCacheResult=null,this._onApiResult=null}return e.prototype.invokeCacheResult=function(e,t){this._onCacheResult(e,t)},e.prototype.invokeApiResult=function(e,t){this._onApiResult(e,t)},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),qe=function(){function e(){}return e.prototype.isNetworkConnected=function(){return!("undefined"==typeof navigator||!navigator.onLine)},e.ready=function(){return P(this,void 0,void 0,(function(){return L(this,(function(e){return"undefined"!=typeof navigator&&navigator&&"boolean"==typeof navigator.onLine?[2,navigator.onLine]:[2,new Promise((function(e,t){i.default.get("https://www.google.com").then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}();!function(e){e[e.BACKGROUND_SYNC_CLOSE=0]="BACKGROUND_SYNC_CLOSE",e[e.BACKGROUND_SYNC_OPEN=1]="BACKGROUND_SYNC_OPEN",e[e.FILL=2]="FILL",e[e.USER_CALL=3]="USER_CALL"}(Be||(Be={}));var ze,Ye=100,Qe=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:0}),We=new Map,Je=function(e){return"sendbird@message/fill/".concat(e,"/").concat(Te())},Xe=function(){function e(e){var t=this,n=e.iid,r=e.channel,i=e.startingPoint,s=e.filter,a=e.limit,o=void 0===a?100:a;this._hugeGapCheckTimer=null,this._messages=[],this._syncRange=new Fe(M({},Qe)),this._hasPrevious=!0,this._hasNext=!0,this._unsentMessages=[],this._iid=n,this._channel=r,this._startingPoint=i,this._filter=s,this._limit=o,this._syncLimit=Math.max(o,Ye),this._eventObserver={onevent:function(e){return P(t,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onMessagesAdded:fe,onMessagesUpdated:fe,onMessagesDeleted:fe,onChannelUpdated:fe,onChannelDeleted:fe,onHugeGapDetected:fe};var l=U.get(this._iid);this._localCacheEnabled=l.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=xe.of(this._iid,this._channel,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=Ve.of(this._iid,this._channel),this._connectionObserver={onConnect:function(){t._checkHugeGap(),t._localCacheEnabled&&t._backgroundSync.resume(),t._changelogSync.resume()},onDisconnect:function(){return P(t,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,qe.ready()];case 1:return e.sent()||(this._previousFillSync.stop(),this._nextFillSync.stop(),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},this._previousFillSync=new Le(Je("prev"),(function(e){return P(t,void 0,void 0,(function(){var t,n,r;return L(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages({ts:e,prevLimit:this._syncLimit})];case 1:return(t=i.sent()).length>0?(n=Math.min.apply(Math,t.map((function(e){return e.createdAt}))),this._syncRange.top=Math.min(this._syncRange.top,n),r=new De(be.MESSAGE_FILL,t[0].sendingStatus),this._addMessagesToView(t,{context:r}),[2,{hasNext:t.length=n,nextParams:this._syncRange.top}]):[2,{hasNext:!1,nextParams:0}]}}))}))})),this._nextFillSync=new Le(Je("next"),(function(e){return P(t,void 0,void 0,(function(){var t,n,r;return L(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages({ts:e,nextLimit:this._syncLimit})];case 1:return(t=i.sent()).length>0?(n=Math.max.apply(Math,t.map((function(e){return e.createdAt}))),this._syncRange.bottom=Math.max(this._syncRange.bottom,n),r=new De(be.MESSAGE_FILL,t[0].sendingStatus),this._addMessagesToView(t,{context:r}),[2,{hasNext:t.length0){this._removeUnsentMessagesFromView([o]);var u=new De(t,o[0].sendingStatus);this._addMessagesToView(o,{context:u})}if(l&&l.length>0)if((p=this._removeMessagesFromView(l,{})).length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}}break;case be.LOCAL_MESSAGE_PENDING_CREATED:case be.LOCAL_MESSAGE_RESEND_STARTED:case be.LOCAL_MESSAGE_CANCELED:var c=r,d=(a=c.channel,c.message);u=new De(t,d.sendingStatus);a.url===this._channel.url&&this._upsertUnsentMessagesToView([d],{context:u});break;case be.EVENT_MESSAGE_SENT:var h=r;a=h.channel,d=h.message;if(a.url===this._channel.url){var p=this._removeUnsentMessagesFromView([d]);if(this._hasNext){if(p.length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,a,p)}}else{this._addMessagesToView([d],{});var u=new De(t,d.sendingStatus);p.length>0?this._eventHandler.onMessagesUpdated(u,a,[d]):this._eventHandler.onMessagesAdded(u,a,[d])}}break;case be.EVENT_MESSAGE_RECEIVED:var f=r;a=f.channel,d=f.message;if(a.url===this._channel.url&&!this._hasNext){u=new De(t,d.sendingStatus);this._addMessagesToView([d],{context:u})}break;case be.LOCAL_MESSAGE_FAILED:var _=r;a=_.channel,d=_.message;if(a.url===this._channel.url&&d.sendingStatus===i.MessageSendingStatus.FAILED){u=new De(t,d.sendingStatus);this._upsertUnsentMessagesToView([d],{context:u})}break;case be.EVENT_MESSAGE_UPDATED:var y=r;a=y.channel,d=y.message;if(a.url===this._channel.url){u=new De(t,d.sendingStatus);this._addMessagesToView([d],{context:u,isUpdateOnly:!0})}break;case be.EVENT_MESSAGE_DELETED:var g=r,m=(a=g.channel,g.messageId);if(a.url===this._channel.url)if(We.delete(m),(p=this._removeMessagesFromView([m],{})).length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}break;case be.EVENT_DELIVERY_RECEIPT_UPDATED:case be.EVENT_READ_RECEIPT_UPDATED:if((a=r.channel).isGroupChannel()){o=[];for(var E=0,v=this._messages;E0?We.set(d.messageId,T):We.delete(d.messageId))}if(o.length>0){u=new De(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}break;case be.EVENT_USER_LEFT:var C=U.get(this._iid),b=r,A=(a=b.channel,b.user),N=C.get("currentUserId");if(A.userId!==N){o=[];for(var S=0,I=this._messages;S0?We.set(d.messageId,T):We.delete(d.messageId))}if(o.length>0){u=new De(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}else{u=new we(t);this._eventHandler.onChannelDeleted(u,a.url)}break;case be.EVENT_CHANNEL_CHANGED:case be.EVENT_USER_RECEIVED_INVITATION:case be.EVENT_USER_JOINED:case be.EVENT_CHANNEL_FROZEN:case be.EVENT_CHANNEL_UNFROZEN:case be.EVENT_CHANNEL_HIDDEN:case be.EVENT_CHANNEL_UNHIDDEN:case be.EVENT_USER_MUTED:case be.EVENT_USER_UNMUTED:case be.EVENT_TYPING_STATUS_UPDATED:case be.EVENT_OPERATOR_UPDATED:case be.EVENT_CHANNEL_METADATA_UPDATED:case be.EVENT_CHANNEL_METADATA_DELETED:case be.EVENT_CHANNEL_METACOUNTER_UPDATED:case be.EVENT_CHANNEL_METACOUNTER_DELETED:a=r.channel,u=new we(t);this._eventHandler.onChannelUpdated(u,a);break;case be.EVENT_CHANNEL_DELETED:a=r.channel,u=new we(t);this._eventHandler.onChannelDeleted(u,a.url)}},e.prototype._createRemoteMessageParams=function(e){var t=e.prevLimit,n=void 0===t?0:t,r=e.nextLimit,i=void 0===r?0:r,s=new(0,x.get(this._iid).MessageListParams);return s.isInclusive=!0,s.prevResultSize=n,s.nextResultSize=i,s.includeMetaArray=!0,s.includeReactions=!0,s.includeThreadInfo=!0,s.includeReplies=!0,s.includeParentMessageText=!0,s},e.prototype._getRemoteMessages=function(e){var t=e.ts,n=e.prevLimit,r=void 0===n?0:n,i=e.nextLimit,s=void 0===i?0:i;return P(this,void 0,void 0,(function(){var e,n,i,a;return L(this,(function(o){switch(o.label){case 0:return e=[],r>0?(i=this._createRemoteMessageParams({prevLimit:r,nextLimit:0}),[4,this._channel.getMessagesByTimestamp(t,i)]):[3,2];case 1:n=o.sent(),e=e.concat(n),this._hasPrevious=n.length>=r,o.label=2;case 2:return s>0?(i=this._createRemoteMessageParams({prevLimit:0,nextLimit:s}),[4,this._channel.getMessagesByTimestamp(t,i)]):[3,4];case 3:a=o.sent(),e=e.concat(a),this._hasNext=a.length>=s,o.label=4;case 4:return e.length>0?[4,this._upsertRemotelyFetchedMessages(e)]:[3,6];case 5:o.sent(),o.label=6;case 6:return[2,e]}}))}))},e.prototype._upsertRemotelyFetchedMessages=function(e,t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){var n,r,i,s;return L(this,(function(a){switch(a.label){case 0:return n=t.context,r=void 0===n?null:n,i=Ae.of(this._iid),s=e.map((function(e){return e.reqId})),[4,i.removeUnsentMessages({channelUrl:this.channel.url,reqIds:s})];case 1:return a.sent(),this._removeUnsentMessagesFromView(e,{context:r}),[4,i.upsert(e,de.SUCCEEDED)];case 2:return a.sent(),this._addMessagesToView(e,{context:r}),[2]}}))}))},e.prototype._checkHugeGap=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_=this;return L(this,(function(y){switch(y.label){case 0:return y.trys.push([0,12,,13]),e=x.get(this._iid).BaseChannel,t=U.get(this._iid),n=t.get("apiClient"),this._messages.length>0?(r=Ae.of(this._iid),i={from:this._messages[0].createdAt,to:Math.min(this._syncRange.top,this._messages[this._messages.length-1].createdAt),cachedCount:0},s=i,[4,r.countBetween(this._channel.url,this._filter,i.from,i.to)]):[3,8];case 1:return s.cachedCount=y.sent(),a={from:Math.max(this._syncRange.bottom,this._messages[0].createdAt),to:this._messages[this._messages.length-1].createdAt,cachedCount:0},o=a,[4,r.countBetween(this._channel.url,this._filter,a.from,a.to)];case 2:return o.cachedCount=y.sent(),l={iid:this._iid,channelUrl:this._channel.url,channelType:this._channel.channelType,filter:this._filter,previous:i,next:a},[4,n.checkMessageHugeGap(M(M({},l),l.filter))];case 3:return u=y.sent(),(c={isHugeGap:!!u.is_huge_gap,previousMessages:u.prev_messages.map((function(t){return e.buildMessage(t,_._channel)}))||[],previousHasMore:!!u.prev_hasmore,nextMessages:u.next_messages.map((function(t){return e.buildMessage(t,_._channel)}))||[],nextHasMore:!!u.next_hasmore}).isHugeGap?[3,6]:(h=w(w([],c.previousMessages,!0),c.nextMessages,!0)).length>0?(p=new De(be.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,5];case 4:y.sent(),this._extendSyncRange(["prev"],c.previousMessages),this._extendSyncRange(["next"],c.nextMessages),c.previousHasMore&&this._previousFillSync.run(this._syncRange.top),c.nextHasMore&&this._nextFillSync.run(this._syncRange.bottom),y.label=5;case 5:return[3,7];case 6:setTimeout((function(){return _._eventHandler.onHugeGapDetected()}),10),y.label=7;case 7:return[3,11];case 8:return d=Math.floor(this._syncLimit/2),[4,this._getRemoteMessages({ts:this._startingPoint,prevLimit:d,nextLimit:d})];case 9:return(h=y.sent()).length>0?(p=new De(be.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,11];case 10:y.sent(),this._extendSyncRange(["prev","next"],this._messages),y.label=11;case 11:return[3,13];case 12:return f=y.sent(),J.warn(f.message),this._hugeGapCheckTimer=setTimeout((function(){_._hugeGapCheckTimer=null,_._checkHugeGap()}),3e3),[3,13];case 13:return[2]}}))}))},e.prototype._extendSyncRange=function(e,t){if(t.length>0){var n=t.map((function(e){return e.createdAt}));e.includes("prev")&&(this._syncRange.top=Math.min.apply(Math,w([this._syncRange.top],n,!1))),e.includes("next")&&(this._syncRange.bottom=Math.max.apply(Math,w([this._syncRange.bottom],n,!1)))}},e.prototype._addMessagesToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=t.isUpdateOnly,s=void 0!==i&&i,a=[],o=[],l=[],u=0,c=e;u=0)o.push(d),this._messages[h]=d;else if(!s){var f=ge(this._messages,d);a.push(d),this._messages.splice(f,0,d)}}else h>=0&&(l.push(d),this._messages.splice(h,1))}r&&(a.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,a),o.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,o),l.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,l))},e.prototype._removeMessagesFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0){var u=this._messages[l];i.push(u),this._messages.splice(l,1)}}return r&&i.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,i),i},e.prototype._upsertUnsentMessagesToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=[],a=[],o=0,l=e;o=0)s.push(u),this._unsentMessages[c]=u;else{var d=ge(this._unsentMessages,u);i.push(u),this._unsentMessages.splice(d,0,u)}else c>=0&&(this._unsentMessages.splice(c,1),a.push(u))}r&&(i.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,i),s.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,s),a.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,a))},e.prototype._removeUnsentMessagesFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0){var u=this._unsentMessages[l];i.push(u),this._unsentMessages.splice(l,1)}}return r&&i.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,i),i},e.prototype._removeFailedMessagesFromView=function(e){var t=Ri.getInstance(this._iid),n=[],r=[],i=this._unsentMessages.map((function(e){return e.reqId}));if(e)for(var s=0,a=e;s=0&&this._unsentMessages[l].sendingStatus===t.MessageSendingStatus.FAILED?n.push(this._unsentMessages[l]):r.push(this._unsentMessages[l])}else for(var u=0,c=this._unsentMessages;u0){e.getIsProcessingAutoResend()||e.setIsProcessingAutoResend(!0);var n=t[0];x.get(e._iid).GroupChannel.getChannel(n.channelUrl,T.INTERNAL_CALL,(function(t,r){var i;if(e.getErrorFirstCallback()&&(r=(i=[t,r])[0],t=i[1]),r)throw r;n.isUserMessage()?t._autoResendUserMessage(n):n.isFileMessage()&&t._autoResendFileMessage(n)}))}else e.setIsProcessingAutoResend(!1)}catch(t){e.setIsProcessingAutoResend(!1),J.error(t)}},e._completeCurrentAndProcessNextAutoResend=function(e,t){if(e.isCacheEnabled&&t._isAutoResendRegistered){var n=e.getAutoResendQueue();if(t.sendingStatus===e.MessageSendingStatus.SUCCEEDED||t.sendingStatus===e.MessageSendingStatus.FAILED&&!ie.isAutoResendableError(t.errorCode))n.length>0&&t.reqId===n[0].reqId&&(n.shift(),this._processNextAutoResend(e));else if(t.sendingStatus===e.MessageSendingStatus.PENDING){if(n.length>0&&n.map((function(e){return e.reqId})).indexOf(t.reqId)>-1)return;n.push(t),!e.getIsProcessingAutoResend()&&n.length>0&&this._processNextAutoResend(e)}}},e._processPendingMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p;return L(this,(function(f){switch(f.label){case 0:return t=Ae.of(e._iid),n=Ie.of(e._iid),r=U.get(e._iid),(i=new He).sendingStatus=e.MessageSendingStatus.PENDING,s=r.container.nestdb,a=s.collection("UnsentMessage"),[4,t.getAllUnsentMessages(i,a)];case 1:o=f.sent(),l=0,u=o,f.label=2;case 2:return l0?Math.min.apply(Math,this._messages.map((function(e){return e.createdAt}))):Number.MAX_SAFE_INTEGER,[4,qe.ready()]):[3,5];case 1:return n.sent()?[3,3]:[4,Ae.of(this._iid).getPreviousMessages(this._channel.url,this._filter,e,this._limit)];case 2:return t=n.sent(),this._addMessagesToView(t),[2,t];case 3:return[4,this._getRemoteMessages({ts:e,prevLimit:this._limit})];case 4:return t=n.sent(),this._addMessagesToView(t),Ee(this._syncRange,["prev"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return P(this,void 0,void 0,(function(){var e,t;return L(this,(function(n){switch(n.label){case 0:return this._hasNext?(e=this._messages.length>0?Math.max.apply(Math,this._messages.map((function(e){return e.createdAt}))):0,[4,qe.ready()]):[3,5];case 1:return n.sent()?[3,3]:[4,Ae.of(this._iid).getNextMessages(this._channel.url,this._filter,e,this._limit)];case 2:return t=n.sent(),this._addMessagesToView(t),[2,t];case 3:return[4,this._getRemoteMessages({ts:e,nextLimit:this._limit})];case 4:return t=n.sent(),this._addMessagesToView(t),Ee(this._syncRange,["next"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.removeFailedMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i;return L(this,(function(s){switch(s.label){case 0:return t=Ri.getInstance(this._iid),n=Ae.of(this._iid),r=e.map((function(e){return e.reqId})),[4,n.removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:t.MessageSendingStatus.FAILED,reqIds:r})];case 1:return i=s.sent(),this._removeFailedMessagesFromView(e),[2,i]}}))}))},e.prototype.removeAllFailedMessages=function(){return P(this,void 0,void 0,(function(){var e;return L(this,(function(t){switch(t.label){case 0:return e=Ri.getInstance(this._iid),[4,Ae.of(this._iid).removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:e.MessageSendingStatus.FAILED})];case 1:return t.sent(),this._removeFailedMessagesFromView(),[2]}}))}))},e.prototype.dispose=function(){this._localCacheEnabled&&(this._previousFillSync.stop(),this._nextFillSync.stop(),this._backgroundSync.pause()),this._changelogSync.pause(),pe.of(this._iid).removeObserver(this._connectionObserver),this._hugeGapCheckTimer&&(clearTimeout(this._hugeGapCheckTimer),this._hugeGapCheckTimer=null),Ie.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setMessageCollectionHandler=function(e){this._eventHandler=e},e}(),Ze=1048576,$e=function(){function e(e){void 0===e&&(e={}),this._emojiHash=e.emoji_hash||"",this._uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ze:Number.MAX_VALUE,this._useReaction=!!e.use_reaction,this._applicationAttributes=e.application_attributes||[],this._premiumFeatureList=e.premium_feature_list||[],this._disableSupergroupMack=e.disable_supergroup_mack||!1}return Object.defineProperty(e.prototype,"emojiHash",{get:function(){return this._emojiHash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uploadSizeLimit",{get:function(){return this._uploadSizeLimit},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingReaction",{get:function(){return this._useReaction},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"applicationAttributes",{get:function(){return this._applicationAttributes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"premiumFeatureList",{get:function(){return this._premiumFeatureList},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSupergroupMackDisabled",{get:function(){return this._disableSupergroupMack},enumerable:!1,configurable:!0}),e.prototype._objectify=function(){var e={};return e.emoji_hash=this._emojiHash,this._uploadSizeLimit!==Number.MAX_VALUE&&(e.file_upload_size_limit=this._uploadSizeLimit/Ze),e.use_reaction=this._useReaction,e.application_attributes=this._applicationAttributes,e.premium_feature_list=this._premiumFeatureList,e.disable_supergroup_mack=this._disableSupergroupMack,e},e}(),et=function(){function e(t){c(this,e),this.sb=t,this.cls=x.get(this.sb._iid),this.client=new ce(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,t){var n=this,r=U.get(this.sb._iid).container,i=r.auth,s=r.apiClient,a=r.commandHandler;i.sessionToken=t||null;var o=this.cls.GroupChannel,l=null,u=new ce.ConnectionHandler;this.client=new ce(this.sb,u),u.onMessage=function(e){a.onRawCommandReceived(e)},this.sb.loginHandler=function(e,t){if(n.sb.connecting=!1,n.sb.reconnecting=!1,e)n.disconnect({clearSession:!0,err:e},null);else{clearInterval(n.sb.globalTimer);var r=function(){o.cachedChannels&&Object.keys(o.cachedChannels).forEach((function(e){var t=o.cachedChannels[e];t.invalidateTypingStatus()&&Object.keys(n.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onTypingStatusUpdated(t)}))}))};r(),n.sb.globalTimer=setInterval((function(){return r()}),1e3),n.flushConnectionCallbacks(null,t),n.sb.ConnectionManager.processAllReadyHandler(null)}},u.onOpen=function(){n.connectCount=0,n.sb.loginTimer=setTimeout((function(){n.sb.loginTimer=null,n.sb.onLoginTimerCancel=null,n.flushConnectionCallbacks(new H("Connection timeout.",H.LOGIN_TIMEOUT),null),n.sb.disconnect(null)}),n.sb.Options.websocketResponseTimeout),n.sb.onLoginTimerCancel=function(){n.connectCount=0,n.flushConnectionCallbacks(new H("Connection has been canceled.",H.REQUEST_FAILED),null)},n.sb.connecting=!1},u.onError=function(r){J.debug("Connect: `WebSocketClient.ConnectionHandler.onError` called.",r),i.sessionKey?(n.sb.isReconnectingOnError=!0,n.sb.ConnectionManager.errorAllReadyHandler(),n.reconnect(e,!0),n.sb.connecting=!1):n.connectCount1&&void 0!==arguments[1])||arguments[1],r=U.get(this.sb._iid),i=r.container,s=i.auth,a=i.apiClient,o=i.commandHandler,l=i.ackStateMap,u=i.sessionManager,c=this.cls.OpenChannel;if(this.sb.connecting=!1,this.sb.reconnecting=!0,this.sb.reconnectTimer)J.debug("Reconnect: still reconnecting.");else{if(this.reconnectCount+=1,this.reconnectCount<=1){if(n){Object.keys(l).forEach((function(e){var t=l[e];t&&(clearTimeout(t.timer),(0,t.handler)(new H("Command received no ack.",H.ACK_TIMEOUT),null));delete l[e]}));var d=pe.of(this.sb._iid);d.invokeDisconnect(),Object.keys(this.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].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||!s.sessionKey||this.reconnectParams.retryCount>0&&this.reconnectCount>this.reconnectParams.retryCount)return this.disconnect({clearSession:!1,err:new H("Websocket connection failed.",H.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,Object.keys(this.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].onReconnectFailed()})),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1,void this.sb.ConnectionManager.errorAllReadyHandler();this.sb.onReconnectTimerCancel=function(){t.reconnectCount=0},this.sb.reconnectTimer=setTimeout((function(){t.sb.reconnectTimer=null,t.sb.onReconnectTimerCancel=null,t.client&&t.client.disconnect(!0);var n=new ce.ConnectionHandler;t.client=new ce(t.sb,n),t.sb.loginHandler=function(n,r){n?u.isSessionError(n)?u.refreshSessionIfExpiredError(n).then((function(){clearTimeout(t.sb.reconnectTimer),t.sb.reconnectTimer=null,t.reconnectCount=0,t.reconnect(e,!1)})).catch((function(){})):(clearTimeout(t.sb.reconnectTimer),t.sb.reconnectTimer=null,t.reconnect(e,!1)):(t.reconnectCount=0,t.sb.connecting=!1,t.sb.reconnecting=!1,t.sb.isReconnectingOnError=!1,pe.of(t.sb._iid).invokeConnect(),Object.keys(t.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].onReconnectSucceeded()})),t.sb.ConnectionManager.processAllReadyHandler(null),t.sb.isReconnectingOnError&&Object.keys(t.sb.ConnectionManager.networkHandlers).forEach((function(e){t.sb.ConnectionManager.networkHandlers[e].onReconnected()})),Object.keys(c.enteredChannels).forEach((function(e){c.enteredChannels[e].enter((function(n,r){if(n){var i=t.cls.FileMessageQueue;delete c.enteredChannels[e],i.delete(e)}}))})))},n.onOpen=function(){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),t.sb.loginTimer=setTimeout((function(){J.debug("Reconnect: `loginTimer` timeout."),t.sb.loginTimer=null,t.reconnect(e,!0)}),t.sb.Options.websocketResponseTimeout),t.sb.onLoginTimerCancel=null},n.onMessage=function(e){o.onRawCommandReceived(e)},n.onError=function(n){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",n),t.sb.isReconnectingOnError=!0,t.sb.ConnectionManager.errorAllReadyHandler(),t.reconnect(e,!0)},n.onClose=function(){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),t.sb.reconnecting=!1},a.checkRouting((function(n,r){n?t.reconnect(e,!0):(t.sb.getCurrentApiHost()!==r.apiHost&&a.get("/",null,(function(){})),t.client.connect(e,null,r.wsHost))}))}),this.reconnectDelay)}}},{key:"disconnect",value:function(e,t){var n=U.get(this.sb._iid),r=n.container.ackStateMap,i=this.cls,s=i.GroupChannel,a=i.OpenChannel,o=e.clearSession,l=e.err;this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.onLoginTimerCancel&&(this.sb.onLoginTimerCancel(),this.sb.onLoginTimerCancel=null),this.sb.loginTimer=null),this.sb.reconnectTimer&&(clearTimeout(this.sb.reconnectTimer),this.sb.onReconnectTimerCancel&&(this.sb.onReconnectTimerCancel(),this.sb.onReconnectTimerCancel=null),this.sb.reconnectTimer=null),this.client&&(this.reconnectCount=0,this.client.disconnect(!0),this.client=null),o&&(a.clearEnteredChannels(),a.clearCache(),s.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),Object.keys(r).forEach((function(e){clearTimeout(r[e].timer)})),this.sb.currentUser=null,n.set("ackStateMap",{}),n.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),n.set("auth",new F)),l&&(this.flushConnectionCallbacks(l,null),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1),t&&t(null,null)}},{key:"flushConnectionCallbacks",value:function(e,t){var n=this,r=U.get(this.sb._iid).container,i=r.store,s=r.localCacheEnabled,a=this.sb.connectionCallbacks;if(this.sb.connectionCallbacks=[],e)if(s){var o=this.sb._getCurrentUserDataKey();ie.isNonAutoReconnectableError(e.code)?i.remove(o).catch((function(e){return J.debug("Sendbird connect store remove error: ",e)})).finally((function(){return a.forEach((function(t){return t(e,null)}))})):i.get(o).then((function(e){n.sb._populateVaultFromCurrentUserData(e)})).catch((function(e){J.debug("Sendbird connect store fetch error: ",e)})).finally((function(){n.sb.currentUser?a.forEach((function(t){return t(e,n.sb.currentUser)})):a.forEach((function(t){return t(e,null)}))}))}else a.forEach((function(t){return t(e,null)}));else pe.of(this.sb._iid).invokeConnect(),s?i.set({key:this.sb._getCurrentUserDataKey(),value:this._createCurrentUserData(t),generation:1}).catch((function(e){return J.debug("Sendbird connect store write error: ",e)})).finally((function(){return a.forEach((function(e){return e(null,n.sb.currentUser)}))})):a.forEach((function(e){return e(null,t)}))}},{key:"_createCurrentUserData",value:function(e){var t=U.get(this.sb._iid).container,n=t.auth,r=t.maxUnreadCountOfSuperGroupChannel,i=t.profileImageEncryption,s=t.appInfo,a=t.connectedAt,o=t.firstConnectedAt,l=t.concurrentCallLimit,u=t.backOffDelay,c={currentUser:(e||this.sb.currentUser).serialize(),maxUnreadCountOfSuperGroupChannel:T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,profileImageEncryption:!1};return n.sessionKey&&(c.sessionKey=n.sessionKey),n.eKey&&(c.eKey=n.eKey),r&&(c.maxUnreadCountOfSuperGroupChannel=r),i&&(c.profileImageEncryption=i),s&&(c.appInfo=s._objectify()),a&&o&&(c.connectedAt=a,c.firstConnectedAt=o),l&&u&&(c.concurrentCallLimit=l,c.backOffDelay=u),c}}]),e}(),tt=function(){function e(t){var n=t.type,r=t.nullable,i=void 0!==r&&r,s=t.optional,a=void 0!==s&&s,o=t.optionalIf,l=void 0===o?null:o,u=t.ignoreIf,d=void 0===u?null:u,h=t.defaultValue,p=void 0===h?null:h,f=t.constraint,_=void 0===f?null:f;c(this,e),this.type=n,this.nullable=i,this.optional=a,this.optionalIf=l,this.ignoreIf=d,this.defaultValue=p,this.constraint=_}return h(e,[{key:"isMatchingType",value:function(e){var t=function(t,n){return"string"==typeof n?u(t)===n||"array"===n&&Array.isArray(t)||"file"===n&&ie.isFile(t)||"null"===n&&null===t||"date"===n&&t instanceof Date:"function"==typeof n?t instanceof n:"object"===u(n)&&Object.keys(n).map((function(e){return n[e]})).indexOf(e)>-1};return t(e,this.type)||Array.isArray(this.type)&&this.type.some((function(n){return t(e,n)}))||this.nullable&&null===e}}],[{key:"parse",value:function(t,n){for(t=e.toArray(t);t.length>0&&void 0===t[t.length-1];)t.pop();var r=!1,i=null;"callback"===n[n.length-1].type&&("function"==typeof t[t.length-1]&&(i=t.pop()),n.pop(),r=!0);var s=[],a=null,o=0;return n.forEach((function(n){"function"==typeof n.ignoreIf&&n.ignoreIf(t)?s.push(n.hasOwnProperty("defaultValue")?n.defaultValue:null):n.isMatchingType(t[o])?(n.nullable&&null===t[o]||!n.constraint||n.constraint(t[o])||(a=e.error),s.push(t[o]),o++):n.optional||"function"==typeof n.optionalIf&&n.optionalIf(t)?s.push(n.hasOwnProperty("defaultValue")?n.defaultValue:null):(a=e.error,s.push(t[o]),o++)})),r&&i&&s.push(i),t.length!==o&&(a=e.error),[a].concat(s)}},{key:"error",get:function(){return new H("Invalid parameter.",H.INVALID_PARAMETER)}},{key:"toArray",value:function(e){for(var t=[],n=0;n1&&void 0!==arguments[1])||arguments[1],n=U.get(this.sb._iid),r=n.container,i=r.auth,s=r.isInBackground;t&&i.hasSession()?e&&(this.sb.currentUser?e(null,this.sb.currentUser):(this.addReadyHandler(e),this.errorAllReadyHandler()),this.sb.getConnectionState()!==this.sb.ConnectionState.CLOSED||s||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 t=this.sb.currentUser,n=this.readyHandlers;this.readyHandlers=[],n.forEach((function(n){n&&"function"==typeof n&&n(e,t)}))}}},{key:"errorAllReadyHandler",value:function(){var e=U.get(this.sb._iid).container.auth;this.processAllReadyHandler(e&&e.hasSession()?new H("WebSocket connection must be made first.",H.WEBSOCKET_CONNECTION_CLOSED):new H("Connection should be made first.",H.CONNECTION_REQUIRED))}},{key:"NetworkHandler",value:function(){this.onReconnected=function(){}}},{key:"addNetworkHandler",value:function(e,t){this.networkHandlers[e]=t}},{key:"removeNetworkHandler",value:function(e){delete this.networkHandlers[e]}},{key:"removeAllNetworkHandler",value:function(){this.networkHandlers={}}},{key:"authenticate",value:function(e){var t=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 n=setTimeout((function(){n=null,t.authCount--,0===t.authCount&&0===t.sb.connectionCallbacks.length&&(t.sb.connecting=!1),t.errorAllReadyHandler(),e(new H("Connection should be made first.",H.CONNECTION_REQUIRED),null)}),this.authenticateTimer);this.authInfoRequester((function(r){if(n){clearTimeout(n),n=null,t.authCount--;var i=function(n,r){t.sb.connecting=!1,e(n,null)};r&&r.hasOwnProperty("userId")?r.accessToken?r.apiHost&&r.wsHost?t.sb.connect(r.userId,r.accessToken,r.apiHost,r.wsHost,i):t.sb.connect(r.userId,r.accessToken,i):r.apiHost&&r.wsHost?t.sb.connect(r.userId,r.apiHost,r.wsHost,i):t.sb.connect(r.userId,i):e(tt.error,null)}}))}else e(tt.error,null)}}]),e}(),rt=function(){this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,t){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},it=function(){function e(){c(this,e),this.handler=null,this.resolvers=[]}return h(e,[{key:"_refreshSessionToken",value:function(){var t=this;return new Promise((function(n,r){var i=null,s=function(){i&&(clearTimeout(i),i=null)},a=function(){i&&(s(),r(e.sessionTokenRequestFailedError))};i=setTimeout((function(){return a()}),3e4),t.handler.onSessionTokenRequired((function(e){i&&(s(),n(e))}),a)}))}},{key:"_refreshSessionKey",value:function(){var t=this;return new Promise((function(n,r){var i=U.get(t._iid).container,s=i.auth,a=i.wsAdapter;s.sessionToken?a.isConnected?t._refreshSessionKeyByCommand().then((function(){return n()})).catch((function(e){e.isSessionTokenExpiredError?r(e):t._refreshSessionKeyByApi().then((function(){return n()})).catch((function(e){return r(e)}))})):t._refreshSessionKeyByApi().then((function(){return n()})).catch((function(e){return r(e)})):r(e.sessionTokenNotFoundError)}))}},{key:"_refreshSessionKeyByCommand",value:function(){var t=this;return new Promise((function(n,r){var i=Ri.getInstance(t._iid),s=U.get(t._iid).container.auth,a=x.get(t._iid).Command,o=a.bSessionRefresh({token:s.sessionToken,requestId:a.generateRequestId()});i.sendCommand(o,(function(t,a){if(!i.getErrorFirstCallback()){var o=[t,a];a=o[0],t=o[1]}t?r(t):a?a.hasOwnProperty("error")?r(e.sessionKeyRefreshFailedError):(a.hasOwnProperty("new_key")&&(s.sessionKey=a.new_key),n()):r(e.sessionKeyRefreshFailedError)}))}))}},{key:"_refreshSessionKeyByApi",value:function(){var t=this;return new Promise((function(n,r){!function i(s){if(s<3){var a=U.get(t._iid).container,o=a.auth,l=a.apiClient,u={};o.sessionToken&&(u.accessToken=o.sessionToken),l.refreshSessionKey(u,(function(e,t){if(e)e.isSessionTokenExpiredError||e.isSessionTokenRevokedError?r(e):i(s+1);else{var a=t.key;o.sessionKey=a,n()}}))}else r(e.sessionKeyRefreshFailedError)}(0)}))}},{key:"_handleSessionToken",value:function(t){var n=this;t?(U.get(this._iid).container.auth.sessionToken=t,this._refreshSessionKey().then((function(){return n._handleSessionRefreshSuccess()})).catch((function(){return n._handleSessionRefreshError(e.sessionTokenRequestFailedError)}))):this._handleSessionClosed(e.sessionTokenRequestFailedError)}},{key:"_handleSessionRefreshSuccess",value:function(){this.handler.onSessionRefreshed(),this._flushResolvers(null)}},{key:"_handleSessionRefreshError",value:function(e){this._cancelConnection(),this.handler.onSessionError(e),this._flushResolvers(e)}},{key:"_handleSessionClosed",value:function(e){this._cancelConnection(),this.handler.onSessionClosed(),this._flushResolvers(e)}},{key:"_cancelConnection",value:function(){var e=Ri.getInstance(this._iid);e.reconnecting&&(Object.keys(e.connectionHandlers).forEach((function(t){e.connectionHandlers[t].onReconnectFailed()})),e.reconnecting=!1),e.disconnect()}},{key:"_flushResolvers",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=0;n2&&void 0!==arguments[2]?arguments[2]:null;switch(c(this,e),this.command=t,this.requestId=r,arguments.length){case 1:if(!t||t.length<=4)this.command="NOOP",this.payload="{}";else if(this.decode(t),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()),n.req_id=this.requestId||"",this.payload=JSON.stringify(n)}}return h(e,[{key:"isRequestIdCommand",get:function(){return this.isAckRequired||"EROR"===this.command}},{key:"isAckRequired",get:function(){return"LOGI"===this.command||"MESG"===this.command||"FILE"===this.command||"ENTR"===this.command||"EXIT"===this.command||"READ"===this.command||"MEDI"===this.command||"FEDI"===this.command}},{key:"encode",value:function(){return this.command+this.payload+"\n"}},{key:"decode",value:function(e){e=e.trim(),this.command=e.substring(0,4),this.payload=e.substring(4)}},{key:"getJsonElement",value:function(){return JSON.parse(this.payload)}}],[{key:"bSessionRefresh",value:function(e){return new this("LOGI",{token:e.token},e.requestId)}},{key:"bPing",value:function(){return new this("PING",{id:(new Date).getTime(),active:1})}},{key:"bMessage",value:function(e){var t=e.channelUrl,n=e.message,r=e.data,i=e.customType,s=e.metaArrays,a=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,_=e.rootMessageId,y=void 0===_?null:_,g=e.parentMessageId,m=void 0===g?null:g,E=e.pollId,v=e.isReplyToChannel,C=void 0!==v&&v,b=x.get(this._iid),A=b.UserMessageParams,N=b.BaseMessageParams,S={};return S.channel_url=t,S.message=n,S.data=r,s&&s.length>0&&(S.metaarray=s.map((function(e){return e.encode()}))),a&&(S.mention_type=a),S.mentioned_user_ids=[],a===N.MentionType.CHANNEL?S.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(S.mentioned_user_ids=o),i&&(S.custom_type=i),l&&l.length>0&&(S.target_langs=l),u&&u!==A.PushNotificationDeliveryOption.DEFAULT&&(S.push_option=u),c&&(S.apple_critical_alert_options=c.serialize()),f&&(S.silent=f),y&&(S.root_message_id=y),m&&(S.parent_message_id=m),"number"==typeof E?S.poll_id=E:null===E&&(S.poll_id=-1),C&&(S.reply_to_channel=C),new this("MESG",S,h)}},{key:"bFile",value:function(e){var t=e.channelUrl,n=e.url,r=e.name,i=e.type,s=e.size,a=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,_=e.requestId,y=void 0===_?null:_,g=e.silent,m=void 0!==g&&g,E=e.rootMessageId,v=void 0===E?null:E,C=e.parentMessageId,b=void 0===C?null:C,A=e.isReplyToChannel,N=void 0!==A&&A,S=x.get(this._iid),I=S.BaseMessageParams,T=S.FileMessageParams,O={};return O.channel_url=t,O.url=n,O.name=r||"",O.type=i||"",O.size=s||0,O.custom=a,o&&(O.custom_type=o),l&&(O.thumbnails=l),u&&(O.require_auth=u),c&&c.length>0&&(O.metaarray=c.map((function(e){return e.encode()}))),d&&(O.mention_type=d),O.mentioned_user_ids=[],d===I.MentionType.CHANNEL?O.mentioned_user_ids=[]:Array.isArray(h)&&h.length>0&&(O.mentioned_user_ids=h),p&&p!==T.PushNotificationDeliveryOption.DEFAULT&&(O.push_option=p),f&&(O.apple_critical_alert_options=f.serialize()),m&&(O.silent=m),v&&(O.root_message_id=v),b&&(O.parent_message_id=b),N&&(O.reply_to_channel=N),new this("FILE",O,y)}},{key:"bUpdateUserMessage",value:function(e){var t=e.channelUrl,n=e.messageId,r=e.appleCriticalAlertOptions,i=e.message,s=void 0===i?null:i,a=e.data,o=void 0===a?null:a,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,_=void 0===f?null:f,y=e.pollId,g=x.get(this._iid).BaseMessageParams,m={};return m.channel_url=t,m.msg_id=n,null!=s&&void 0!==s&&(m.message=s),null!=o&&void 0!==o&&(m.data=o),null!=u&&void 0!==u&&(m.custom_type=u),d&&(m.mention_type=d),d===g.MentionType.CHANNEL?m.mentioned_user_ids=[]:Array.isArray(p)&&p.length>0&&(m.mentioned_user_ids=p),_&&(m.metaarray=_),r&&(m.apple_critical_alert_options=r.serialize()),"number"==typeof y?m.poll_id=y:null===y&&(m.poll_id=-1),new this("MEDI",m)}},{key:"bUpdateFileMessage",value:function(e){var t=e.channelUrl,n=e.messageId,r=e.appleCriticalAlertOptions,i=e.data,s=void 0===i?null:i,a=e.customType,o=void 0===a?null:a,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=x.get(this._iid).BaseMessageParams,_={};return _.channel_url=t,_.msg_id=n,null!=s&&void 0!==s&&(_.data=s),null!=o&&void 0!==o&&(_.custom_type=o),u&&(_.mention_type=u),u===f.MentionType.CHANNEL?_.mentioned_user_ids=[]:Array.isArray(d)&&d.length>0&&(_.mentioned_user_ids=d),p&&(_.metaarray=p),r&&(_.apple_critical_alert_options=r.serialize()),new this("FEDI",_)}},{key:"bRead",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("READ",n)}},{key:"bMessageAck",value:function(e){var t=e.channelUrl,n=e.messageId,r={};return r.channel_url=t,r.msg_id=n,new this("MACK",r)}},{key:"bTypeStart",value:function(e){var t=e.channelUrl,n=e.time,r={};return r.channel_url=t,r.time=n,new this("TPST",r)}},{key:"bTypeEnd",value:function(e){var t=e.channelUrl,n=e.time,r={};return r.channel_url=t,r.time=n,new this("TPEN",r)}},{key:"bEnter",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("ENTR",n)}},{key:"bExit",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("EXIT",n)}},{key:"generateRequestId",value:function(){return at++,String(at)}}]),e}(),lt={},ut=function(){function e(e){var t=this,n=e.iid,r=e.limit,i=void 0===r?yt:r;this._token="",this._sync=null,this._syncRange=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:0}),this._completed=!1,this._pkIndex=Date.now(),this._iid=n,this._limit=i;var s=x.get(this._iid).GroupChannel,a=U.get(this._iid),o=a.get("currentUserId"),l=a.get("apiClient"),u=a.get("store"),c=Et.of(this._iid),d=Ie.of(this._iid),h="sendbird:".concat(o,"@groupchannel/sync");this._sync=new Le(h,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,r,i,a,o=this;return L(this,(function(p){switch(p.label){case 0:return e={hasNext:!0,nextParams:""},[4,u.get(h)];case 1:return(t=p.sent())&&t.completed?[3,5]:(t&&(this._token=t.token,this._syncRange=t.range,this._pkIndex=t.primaryKeyIndex),n={token:this._token,limit:this._limit,includeEmpty:!0,order:"chronological"},[4,l.loadGroupChannelList(n)]);case 2:return r=p.sent(),i=r.channels.map((function(e){return r.ts&&(e.ts=r.ts),e.cached_primary_key=o._pkIndex--,s.upsert(e)})),this._syncRange.top=Math.min(this._syncRange.top,Math.min.apply(Math,i.map((function(e){return e.createdAt})))),this._syncRange.bottom=Math.max(this._syncRange.bottom,Math.max.apply(Math,i.map((function(e){return e.createdAt})))),e.hasNext=i.length>=this._limit,e.nextParams=this._token=r.next,this._token||(e.hasNext=!1),this._completed=!e.hasNext,[4,c.upsert(i)];case 3:return p.sent(),[4,u.set({key:h,value:{token:this._token,range:this._syncRange,completed:this._completed,primaryKeyIndex:this._pkIndex},generation:1})];case 4:return p.sent(),a={source:be.CHANNEL_BACKGROUND,payload:{channels:i}},d.send(a),[3,6];case 5:e.hasNext=!1,p.label=6;case 6:return[2,e]}}))}))}))}return e.of=function(t,n){return void 0===n&&(n=yt),lt[t]||(lt[t]=new e({iid:t,limit:n})),lt[t]},Object.defineProperty(e.prototype,"range",{get:function(){return this._syncRange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){return this._completed},enumerable:!1,configurable:!0}),e.prototype.resume=function(){this._sync.resume("")},e.prototype.pause=function(){this._sync.stop()},e}(),ct={},dt=function(){function e(e){var t=this,n=e.iid;this._token=0,this._sync=null,this._pkIndex=Date.now(),this._iid=n;var r=x.get(this._iid).GroupChannel,i=U.get(this._iid);this._token=i.get("firstConnectedAt")/1e3;var s=i.get("currentUserId"),a=i.get("store"),o=i.get("apiClient"),l=i.container.localCacheEnabled,u=Et.of(this._iid),c=Ie.of(this._iid),d="sendbird:".concat(s,"@groupchannel/changelogs");this._sync=new Le(d,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,h,p,f=this;return L(this,(function(_){switch(_.label){case 0:return e={hasNext:!0,nextParams:""},l?[4,a.get(d)]:[3,2];case 1:return n=_.sent(),[3,3];case 2:n=null,_.label=3;case 3:return(t=n)&&(this._token=t.token,this._pkIndex=t.primaryKeyIndex),i={},"number"==typeof this._token?i.ts=this._token:i.token=this._token,[4,o.getMyGroupChannelChangeLogs(i)];case 4:return s=_.sent(),h={updatedChannels:s.updated.map((function(e){return e.cached_primary_key=f._pkIndex--,new r(e)})),deletedChannelUrls:s.deleted},e.hasNext=s.has_more,e.nextParams=this._token=s.next,l?[4,u.upsert(h.updatedChannels)]:[3,8];case 5:return _.sent(),[4,u.remove(h.deletedChannelUrls)];case 6:return _.sent(),[4,a.set({key:d,value:{token:this._token,primaryKeyIndex:this._pkIndex},generation:1})];case 7:_.sent(),_.label=8;case 8:return p={source:be.CHANNEL_CHANGELOG,payload:h},c.send(p),[2,e]}}))}))}))}return e.of=function(t){return ct[t]||(ct[t]=new e({iid:t})),ct[t]},e.prototype.resume=function(){this._sync.resume(0,!0)},e.prototype.pause=function(){this._sync.stop()},e}(),ht=function(e,t){for(var n=0;n0){for(var r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(a<0))return s;r=s+1,s=Math.floor((r+i)/2)}}return _t(e[s],t,n)>0?s:s+1}return e.length},ft=function(e,t){return t-e},_t=function(e,t,n){switch(n){case ze.LATEST_LAST_MESSAGE:if(e.lastMessage&&!t.lastMessage)return-1;if(!e.lastMessage&&t.lastMessage)return 1;if(e.lastMessage&&t.lastMessage){var r=e.lastMessage.createdAt;if(0===(s=t.lastMessage.createdAt-r)){var i=e.createdAt;0===(s=t.createdAt-i)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey))}return s}r=e.createdAt;return 0===(s=t.createdAt-r)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ze.CHRONOLOGICAL:return 0===(s=t.createdAt-e.createdAt)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ze.CHANNEL_NAME_ALPHABETICAL:var s;return 0===(s=e.name.localeCompare(t.name))&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s}},yt=40;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical"}(ze||(ze={}));var gt=function(){function e(e){var t=this,n=e.iid,r=e.filter,i=e.order,s=e.limit,a=void 0===s?20:s;this._channels=[],this._token=null,this._hasMore=!0,this._iid=n,this._filter=r,this._order=i,this._limit=a,this._syncLimit=Math.max(a,yt),this._eventObserver={onevent:function(e){return P(t,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onChannelsAdded:fe,onChannelsUpdated:fe,onChannelsDeleted:fe};var o=U.get(this._iid);this._localCacheEnabled=o.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=ut.of(this._iid,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=dt.of(this._iid),Ie.of(this._iid).addObserver(this._eventObserver),this._connectionStateObserver={onConnect:function(){t._localCacheEnabled&&t._backgroundSync.resume(),t._changelogSync.resume()},onDisconnect:function(){return P(t,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,qe.ready()];case 1:return e.sent()||(this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},pe.of(this._iid).addObserver(this._connectionStateObserver)}return e.prototype._handleEvent=function(e){var t=this,n=e.source,r=e.payload,i=U.get(this._iid),s=new we(n);switch(n){case be.CHANNEL_BACKGROUND:break;case be.CHANNEL_CHANGELOG:var a=r,o=a.updatedChannels,l=a.deletedChannelUrls,u=o.filter((function(e){return t._filter.match(e)}));this._addChannelsToView(u,{context:s}),this._removeChannelsFromView(l,{context:s});break;case be.EVENT_USER_DECLINED_INVITATION:var c=i.get("currentUserId"),d=r,h=d.channel;d.invitee.userId===c?this._removeChannelsFromView([h.url],{context:s}):this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case be.EVENT_USER_LEFT:c=i.get("currentUserId");var p=r;h=p.channel;p.user.userId===c?this._removeChannelsFromView([h.url],{context:s}):this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case be.EVENT_USER_BANNED:case be.EVENT_USER_UNBANNED:break;case be.EVENT_USER_MUTED:case be.EVENT_USER_UNMUTED:case be.EVENT_TYPING_STATUS_UPDATED:case be.EVENT_OPERATOR_UPDATED:case be.EVENT_CHANNEL_METADATA_UPDATED:case be.EVENT_CHANNEL_METADATA_DELETED:case be.EVENT_CHANNEL_METACOUNTER_UPDATED:case be.EVENT_CHANNEL_METACOUNTER_DELETED:h=e.payload.channel;this._addChannelsToView([h],{context:s});break;case be.EVENT_READ_RECEIPT_UPDATED:case be.EVENT_USER_RECEIVED_INVITATION:case be.EVENT_USER_JOINED:case be.EVENT_CHANNEL_FROZEN:case be.EVENT_CHANNEL_UNFROZEN:case be.EVENT_CHANNEL_HIDDEN:case be.EVENT_CHANNEL_UNHIDDEN:case be.EVENT_CHANNEL_CHANGED:h=e.payload.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case be.EVENT_CHANNEL_DELETED:var f=r.channelUrl;this._removeChannelsFromView([f],{context:s})}},e.prototype._getRemoteChannels=function(){return P(this,void 0,void 0,(function(){var e,t,n,r;return L(this,(function(i){switch(i.label){case 0:return e=x.get(this._iid).GroupChannel,t=U.get(this._iid),[4,t.get("apiClient").loadGroupChannelList(M(M({},this._filter),{order:this._order,token:this._token,limit:this._limit,userIdsFilter:this._filter.userIdsFilter,searchFilter:(s=this._filter.searchFilter,s.searchQuery&&s.searchFields?{search_query:s.searchQuery,search_fields:s.searchFields.join(",").toLocaleLowerCase()}:{})}))];case 1:return n=i.sent(),r=n.channels.map((function(t){return"number"==typeof n.ts&&(t.ts=n.ts),e.upsert(t)})),[4,Et.of(this._iid).upsert(r)];case 2:return i.sent(),[2,[r,n.next]]}var s}))}))},e.prototype._addChannelsToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=[],a=0,o=e;a0&&this._eventHandler.onChannelsAdded(r,i),s.length>0&&this._eventHandler.onChannelsUpdated(r,s))},e.prototype._removeChannelsFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0&&(i.push(this._channels[l].url),this._channels.splice(l,1))}return r&&i.length>0&&this._eventHandler.onChannelsDeleted(r,i),i},Object.defineProperty(e.prototype,"channelList",{get:function(){return this._channels},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),e.prototype.loadMore=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i;return L(this,(function(s){switch(s.label){case 0:return this._hasMore?[4,qe.ready()]:[3,5];case 1:return s.sent()?[3,3]:(e=Et.of(this._iid),t=e.getNextContainerToken(this._order,this._channels),[4,e.getNextChannels(this._filter,this._order,t,this._limit)]);case 2:return r=s.sent(),this._addChannelsToView(r),[2,r];case 3:return[4,this._getRemoteChannels()];case 4:return n=s.sent(),r=n[0],i=n[1],this._token=i,this._token||(this._hasMore=!1),this._addChannelsToView(r),[2,r];case 5:return[2,[]]}}))}))},e.prototype.dispose=function(){pe.of(this._iid).removeObserver(this._connectionStateObserver),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause(),Ie.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setGroupChannelCollectionHandler=function(e){this._eventHandler=e},e.GroupChannelOrder=ze,e}(),mt={},Et=function(){function e(e){var t=e.iid,n=e.collection,r=void 0===n?null:n;this._collection=null,this._pkIndex=Date.now(),this._lastFetchedPrimaryKey=Date.now(),this._iid=t,this._collection=r,mt[t]=this}return e.of=function(e){return mt[e]},e.prototype._serialize=function(e){var t=this._createPk();return e.cachedPrimaryKey=t,M(M({},e.serialize()),{lastMessageCreatedAt:e.lastMessage?e.lastMessage.createdAt:e.createdAt,pk:t})},e.prototype._deserialize=function(e){return e?x.get(this._iid).GroupChannel.buildFromSerializedData(e):null},Object.defineProperty(e.prototype,"_localCacheEnabled",{get:function(){return U.get(this._iid).get("localCacheEnabled")},enumerable:!1,configurable:!0}),e.prototype._createPk=function(){return this._pkIndex--},e.prototype._fetch=function(e,t,n){return P(this,void 0,void 0,(function(){var r,i,s,a,o,l,u,c=this;return L(this,(function(d){switch(d.label){case 0:if(!this._localCacheEnabled)return[3,3];switch(r=_e.LATEST_LAST_MESSAGE,t){case ze.CHANNEL_NAME_ALPHABETICAL:r=_e.NAME_ALPHABETICAL;break;case ze.CHRONOLOGICAL:r=_e.CHRONOLOGICAL;break;case ze.LATEST_LAST_MESSAGE:r=_e.LATEST_LAST_MESSAGE}return i=n.containerToken,s=i.lastMessageCreatedAt,a=i.createdAt,o=i.name,l=i.lastFetchedPrimaryKey,u={where:function(n){switch(t){case ze.LATEST_LAST_MESSAGE:if(n.lastMessage){if(n.lastMessageCreatedAt>s)return!1;if(n.lastMessageCreatedAt===s&&ft(l,n.pk)>=0)return!1}else{if(n.createdAt>a)return!1;if(n.createdAt===a&&ft(l,n.pk)>=0)return!1}break;case ze.CHANNEL_NAME_ALPHABETICAL:var r=n.name.localeCompare(o);if(r<0)return!1;if(0===r&&ft(l,n.pk)>=0)return!1;break;case ze.CHRONOLOGICAL:if(n.createdAt>a)return!1;if(n.createdAt===a&&ft(l,n.pk)>=0)return!1}return e.match(c._deserialize(n))},index:r},[4,this._collection.query(u)];case 1:return[4,d.sent().fetch({limit:n.limit})];case 2:return[2,d.sent().map((function(e){return c._deserialize(e)}))];case 3:return[2,[]]}}))}))},e.prototype.getNextContainerToken=function(e,t){switch(e){case ze.LATEST_LAST_MESSAGE:return t.length>0?{lastMessageCreatedAt:(n=t[t.length-1]).lastMessage?n.lastMessage.createdAt:null,createdAt:n.createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{lastMessageCreatedAt:Number.MAX_SAFE_INTEGER,createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ze.CHRONOLOGICAL:return t.length>0?{createdAt:(n=t[t.length-1]).createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ze.CHANNEL_NAME_ALPHABETICAL:var n;return t.length>0?{name:(n=t[t.length-1]).name,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{name:"",lastFetchedPrimaryKey:this._lastFetchedPrimaryKey}}},e.prototype.get=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?(t=this._deserialize,[4,this._collection.getByKey(e)]):[3,2];case 1:return[2,t.apply(this,[n.sent()])];case 2:return[2,null]}}))}))},e.prototype.getNextChannels=function(e,t,n,r){return void 0===r&&(r=100),P(this,void 0,void 0,(function(){return L(this,(function(i){switch(i.label){case 0:return[4,this._fetch(e,t,{containerToken:n,limit:r})];case 1:return[2,i.sent()]}}))}))},e.prototype.upsert=function(e){return P(this,void 0,void 0,(function(){var t,n=this;return L(this,(function(r){switch(r.label){case 0:return this._localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this._collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},e.prototype.remove=function(e){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this._collection.removeIf({url:{"/in":e}})]:[3,3];case 1:return t.sent(),[4,Ri.getInstance(this._iid).clearCachedMessages(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return this._localCacheEnabled?[4,this._collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e}(),vt=function(){function e(){this.messageId=null,this.userId=null,this.key=null,this.operation="",this.updatedAt=null}return e.createFromJson=function(e){var t=parseInt(e.msg_id),n=e.user_id,r=e.operation,i=e.reaction,s=e.updated_at;if(t&&"string"==typeof n&&"string"==typeof r&&["add","delete"].indexOf(r.toLowerCase())>=0&&"string"==typeof i&&i&&"number"==typeof s){var a=new this;return a.messageId=t,a.userId=n,a.key=i,a.operation=r.toLowerCase(),a.updatedAt=s,a}return null},e}(),Ct=function(e){return Object.keys(e).forEach((function(t){e[t]&&"object"==typeof e[t]&&Ct(e[t])})),Object.freeze(e)},bt=function(){function e(){}return e.serialize=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),Ct(n)},e.serializeWithoutFreeze=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},e.deserialize=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},e}(),At={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Nt=new WeakMap,St=function(){function e(t){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.mentionedUserIds=[],this.sendingStatus=null,Nt.set(this,0),this.parentMessageId=0,this.parentMessageText=null,this.threadInfo=null,this.isReplyToChannel=!1,this.parentMessage=null,this.ogMetaData=null,this.isOperatorMessage=!1,this.appleCriticalAlertOptions=null,this.reqId="",this._isAutoResendRegistered=!1,t&&this.__update(t)}return h(e,[{key:"serialize",value:function(e){var t=this;return bt.serialize(this,(function(n){n.hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender),n.hasOwnProperty("_isAutoResendRegistered")&&(n.isAutoResendRegistered=n._isAutoResendRegistered,delete n._isAutoResendRegistered),t.appleCriticalAlertOptions&&(n.appleCriticalAlertOptions=t.appleCriticalAlertOptions.serialize()),e&&e(n)}))}},{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 ie.deepEqual(this,e)}},{key:"isOpenChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"isGroupChannel",value:function(){var e=x.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 t=this,n=Ri.getInstance(this._iid),r=x.get(this._iid),i=r.User,s=r.BaseChannel,a=r.BaseMessageParams,o=r.BaseMessage,u=r.Reaction,c=r.MessageMetaArray,d=r.ThreadInfo,h=r.OGMetaData,p=r.AppleCriticalAlertOptions;e.hasOwnProperty("msg_id")&&e.msg_id&&(this.messageId=parseInt(e.msg_id)),e.hasOwnProperty("message_id")&&e.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):"",e.hasOwnProperty("silent")&&(this.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):s.CHANNEL_TYPE_GROUP;var f=e.hasOwnProperty("metaarray")?e.metaarray:{},_=e.hasOwnProperty("metaarray_key_order")?e.metaarray_key_order:Object.keys(f).sort((function(e,t){return e.localeCompare(t)}));this.metaArrays=[];for(var y=0;y<_.length;y++){var g=_[y];this.metaArrays.push(new c(g,f[g]||[]))}if(e.hasOwnProperty("sorted_metaarray")){var m=e.sorted_metaarray;Array.isArray(m)&&(this.metaArrays=m.map((function(e){return new c(e.key,e.value)})))}if(this.reactions=[],e.hasOwnProperty("reactions")&&Array.isArray(e.reactions))for(var E=0;E0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,e.hasOwnProperty("sending_status")&&(this.sendingStatus=e.sending_status),e.hasOwnProperty("root_message_id")&&e.root_message_id&&Nt.set(this,parseInt(e.root_message_id)),e.hasOwnProperty("parent_message_id")&&e.parent_message_id&&(this.parentMessageId=parseInt(e.parent_message_id)),this.threadInfo=new d(e.thread_info),this.isReplyToChannel=!!e.hasOwnProperty("is_reply_to_channel")&&e.is_reply_to_channel,e.hasOwnProperty("parent_message_info")){var C=l({},e.parent_message_info);e.parent_message_info.hasOwnProperty("file")&&(C.require_auth=!!e.parent_message_info.file.require_auth);var b={channelType:this.channelType,channelUrl:this.channelUrl};switch(this.parentMessage=s.buildMessage(C,b),this.parentMessage.messageType){case o.MESSAGE_TYPE_USER:this.parentMessageText=this.parentMessage.message;break;case o.MESSAGE_TYPE_FILE:this.parentMessageText=this.parentMessage.name}}e.hasOwnProperty("og_tag")&&(this.ogMetaData=new h(e.og_tag)),e.hasOwnProperty("is_op_msg")&&(this.isOperatorMessage=e.is_op_msg),e.hasOwnProperty("apple_critical_alert_options")&&(this.appleCriticalAlertOptions=new p(e.apple_critical_alert_options)),e.hasOwnProperty("is_auto_resend_registered")&&(this._isAutoResendRegistered=e.is_auto_resend_registered),this.reqId=e.hasOwnProperty("req_id")?e.req_id:""}},{key:"getMetaArraysByKeys",value:function(e){return Array.isArray(e)?this.metaArrays.filter((function(t){return e.indexOf(t.key)>-1})):[]}},{key:"metaArray",get:function(){var e={};return this.metaArrays.forEach((function(t){e[t.key]=t.value})),e},set:function(e){if("object"===u(e)&&e){var t=x.get(this._iid).MessageMetaArray,n=[];Object.keys(e).forEach((function(r){n.push(new t(r,e[r]))})),this.metaArrays=n}}},{key:"sender",get:function(){var e=Ri.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"getMetaArrayByKeys",value:function(e){var t={};return this.getMetaArraysByKeys(e).forEach((function(e){t[e.key]=e.value})),t}},{key:"applyReactionEvent",value:function(e){var t=this,n=x.get(this._iid),r=n.Reaction,i=null,s=tt.parse(arguments,[new tt({type:vt,constraint:function(e){return parseInt(e.messageId)===parseInt(t.messageId)}})]),a=b(s,2);if(i=a[0],e=a[1],!i){for(var o=!1,l=0;l-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 t=this.plainProfileUrl.replace("profile_images/","");return t===this.plainProfileUrl?"":t}return""},e.prototype.createMetaData=function(e,t){var n,r=this,i=null;return n=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new tt({type:"callback"})]),i=n[0],e=n[1],t=n[2],oe(this._iid,(function(t){i?t(i,null):U.get(r._iid).container.apiClient.createUserMetaData({metaData:e},(function(e,n){e||r._updateMetaData(n),t(e,n)}))}),t)},e.prototype.updateMetaData=function(e,t,n){var r,i=this,s=null;return r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),s=r[0],e=r[1],t=r[2],n=r[3],oe(this._iid,(function(n){s?n(s,null):U.get(i._iid).container.apiClient.updateUserMetaData({metaData:e,upsert:t},(function(e,t){e||i._updateMetaData(t),n(e,t)}))}),n)},e.prototype.deleteMetaData=function(e,t){var n,r=this,i=null;return n=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),i=n[0],e=n[1],t=n[2],oe(this._iid,(function(t){if(i)t(i,null);else{var n={};n[e]="",U.get(r._iid).container.apiClient.deleteUserMetaData({metaDataKey:e},(function(e,i){e||r._updateMetaData(n,!0),t(e,i)}))}}),t)},e.prototype.deleteAllMetaData=function(e){var t=this;return oe(this._iid,(function(e){var n=t.metaData;U.get(t._iid).container.apiClient.deleteAllUserMetaData({},(function(r,i){r||t._updateMetaData(n,!0),e(r,i)}))}),e)},Object.defineProperty(e,"NON_AVAILABLE",{get:function(){return"nonavailable"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ONLINE",{get:function(){return"online"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"OFFLINE",{get:function(){return"offline"},enumerable:!1,configurable:!0}),e}(),Tt={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Ot=new WeakMap,Ut=new WeakMap,kt=function(){function e(t){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,Ot.set(this,{}),Ut.set(this,""),t&&this.__update(t)}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 It(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),e.hasOwnProperty("cached_primary_key")&&(this.cachedPrimaryKey=e.cached_primary_key)}},{key:"_addOrUpdateCachedMetaData",value:function(e,t){var n=Ot.get(this);Object.keys(e).forEach((function(r){var i=n[r],s=e[r];i?t>i.updatedAt&&(i.value=s,i.updatedAt=t,i.isRemoved=!1):n[r]={value:s,updatedAt:t,isRemoved:!1}}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var n=Ot.get(this);e.forEach((function(e){var r=n[e];r?t>r.updatedAt&&(r.isRemoved=!0,r.updatedAt=t):n[e]={value:null,updatedAt:t,isRemoved:!0}}))}},{key:"_refreshMetaData",value:function(e,t){var n={};Object.keys(e).forEach((function(r){n[r]={value:e[r],updatedAt:t,isRemoved:!1}})),Ot.set(this,n)}},{key:"cachedPrimaryKey",get:function(){return Ut.get(this)},set:function(e){Ut.set(this,e)}},{key:"isGroupChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"createOperatorListQuery",value:function(){return new(0,x.get(this._iid).OperatorListQuery)(this)}},{key:"createMessageListQuery",value:function(){return new(0,x.get(this._iid).MessageListQuery)(this)}},{key:"createPreviousMessageListQuery",value:function(){return new(0,x.get(this._iid).PreviousMessageListQuery)(this)}},{key:"createPollListQuery",value:function(){return new(0,x.get(this._iid).PollListQuery)({channelUrl:this.url})}},{key:"createPollVoterListQuery",value:function(e,t){return new(0,x.get(this._iid).PollVoterListQuery)({channelUrl:this.url,pollId:e,optionId:t})}},{key:"serialize",value:function(){var e=this;return bt.serialize(this,(function(t){if(null!==t.lastMessage&&"object"===u(t.lastMessage)){var n=t.lastMessage;n.hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender,t.lastMessage=n)}t.hasOwnProperty("_messageOffsetTimestamp")&&(t.messageOffsetTimestamp=t._messageOffsetTimestamp,delete t._messageOffsetTimestamp),e.cachedPrimaryKey&&(t.cachedPrimaryKey=e.cachedPrimaryKey)}))}},{key:"getMessageChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:e,token:null,isOpenChannel:i.isOpenChannel(),includeMetaArray:t,includeReactions:n}).then((function(e){var t=x.get(i._iid).BaseChannel,n={updatedMessages:e.updated.map((function(e){return t.buildMessage(e,i)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getMessageChangeLogsByToken",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:null,token:e,isOpenChannel:i.isOpenChannel(),includeMetaArray:t,includeReactions:n}).then((function(e){var t=x.get(i._iid).BaseChannel,n={updatedMessages:e.updated.map((function(e){return t.buildMessage(e,i)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=i.MessageChangeLogsParams,o=null,u=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=b(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,ts:null,token:e,isOpenChannel:r.isOpenChannel()},t)).then((function(e){var t={updatedMessages:e.updated.map((function(e){return s.buildMessage(e,r)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};n(null,t)})).catch((function(e){n(e,null)}))}),n)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=i.MessageChangeLogsParams,o=null,u=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=b(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,timestamp:e,token:null,isOpenChannel:r.isOpenChannel()},t)).then((function(e){var t={updatedMessages:e.updated.map((function(e){return s.buildMessage(e,r)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};n(null,t)})).catch((function(e){n(e,null)}))}),n)}},{key:"getMyMutedInfo",value:function(e){var t=this;return oe(this._iid,(function(e){var n=Ri.getInstance(t._iid);U.get(t._iid).container.apiClient.getMyMutedInfo({channelUrl:t.url,userId:n.currentUser?n.currentUser.userId:null,isGroupChannel:t.isGroupChannel()},(function(t,n){var r=null;t||(r={isMuted:n.is_muted,startAt:n.start_at,endAt:n.end_at,remainingDuration:n.remaining_duration,description:n.description}),e(t,r)}))}),e)}},{key:"_parseMessageListParams",value:function(e){for(var t=x.get(this._iid),n=t.MessageListParams,r=new n,i=null,s=!1,a=0,o=0,l=!1,u="",c="",d=null,h=!1,p=!1,f=null,_=arguments.length,y=new Array(_>1?_-1:0),g=1;g<_;g++)y[g-1]=arguments[g];switch(e){case"prev":var m=tt.parse(y,[new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),E=b(m,11);i=E[0],s=E[2],a=E[3],l=E[4],u=E[5],c=E[6],d=E[7],h=E[8],p=E[9],f=E[10];break;case"next":var v=tt.parse(y,[new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),C=b(v,11);i=C[0],s=C[2],o=C[3],l=C[4],u=C[5],c=C[6],d=C[7],h=C[8],p=C[9],f=C[10];break;case"prevnext":var A=tt.parse(y,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),N=b(A,11);i=N[0],a=N[2],o=N[3],l=N[4],u=N[5],c=N[6],d=N[7],h=N[8],p=N[9],f=N[10],s=!0}return i?[null,f]:(r.isInclusive=s,r.prevResultSize=a,r.nextResultSize=o,r.reverse=l,r.messageType=u,r.customType=c,""===r.customType&&(r.customType="*"),r.senderUserIds=d,r.includeMetaArray=h,r.includeReactions=p,[r,f])}},{key:"_getMessageList",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.MessageListParams,o=null,u=tt.parse(arguments,[new tt({type:"number"}),new tt({type:"string",constraint:function(e){return Object.values(Tt).includes(e)}}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=b(u,5);return o=c[0],e=c[1],t=c[2],n=c[3],r=c[4],oe(this._iid,(function(r){o?r(o,null):U.get(i._iid).container.apiClient.getMessageList(l(l({channel:i,token:e,tokenType:t},n),{},{shouldReverse:n.reverse})).then((function(e){var t=x.get(i._iid).BaseChannel,n=e.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e}));r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getPreviousMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getPreviousAndNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getPreviousMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getPreviousAndNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(tt.toArray(arguments)))),n=b(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getMessagesByTimestamp",value:function(e,t,n){return this._getMessageList(e,Tt.TIMESTAMP,t,n)}},{key:"getMessagesByMessageId",value:function(e,t,n){return this._getMessageList(e,Tt.MESSAGE_ID,t,n)}},{key:"_sendUserMessage",value:function(e){var t=this,n=e.reqId,r=e.message,i=e.data,s=e.customType,a=e.metaArrays,o=e.mentionType,u=e.mentionedUserIds,c=e.pushNotificationDeliveryOption,d=e.rootMessageId,h=e.parentMessageId,p=e.translationTargetLanguages,f=e.appleCriticalAlertOptions,_=e.pollId,y=e.silent,g=void 0!==y&&y,m=e.isReplyToChannel,E=e.messageParams,v=e.oldMessage,C=void 0===v?null:v,b=e.isManualResend,A=void 0!==b&&b,N=e.callback,S=x.get(this._iid),I=S.Command,T=S.UserMessage,O=Ri.getInstance(this._iid),k=Ae.of(this._iid),R=Et.of(this._iid),M=Ie.of(this._iid),P=U.get(this._iid).container.localCacheEnabled;n||(n=I.generateRequestId());var L={};Array.isArray(p)&&p.forEach((function(e){return L[e]=""}));var w=T.objectify({messageId:0,reqId:n,user:O.currentUser||{},channel:this,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,rootMessageId:d,parentMessageId:h,translations:L,silent:g,appleCriticalAlertOptions:f,isReplyToChannel:m,messageParams:E,createdAt:(new Date).getTime()}),D=new T(w);if(D.requestState=O.MessageRequestState.PENDING,D.sendingStatus=O.MessageSendingStatus.PENDING,D.requestedMentionUserIds=u,D._messageParams=E,!O.currentUser){var F=new H("Connection should be made first.",H.CONNECTION_REQUIRED),G=new T(w);return G.requestState=O.MessageRequestState.FAILED,G.sendingStatus=O.MessageSendingStatus.FAILED,G.requestedMentionUserIds=u,G.errorCode=F.code,N(F,G),D}return(!t.isGroupChannel()||C&&C._isAutoResendRegistered?Promise.resolve():k.upsert([D],de.UNSENT).then((function(){M.send({source:A?be.LOCAL_MESSAGE_RESEND_STARTED:be.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:t,message:D}})}))).then((function(){var e=I.bMessage({channelUrl:t.url,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,requestId:n,rootMessageId:d,parentMessageId:h,silent:g,translationTargetLanguages:p,pushNotificationDeliveryOption:c,appleCriticalAlertOptions:f,pollId:_,isReplyToChannel:m});(D.reqId=e.requestId,t.isGroupChannel()&&O.getConnectionState()!==O.ConnectionState.OPEN&&O.currentUser&&!O.connecting&&!O.reconnecting&&"string"==typeof s&&0===s.indexOf("SB_VIDEOCHAT"))?U.get(O._iid).container.apiClient.sendUserMessage({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),message:r,data:i,customType:s,translationTargetLanguages:p,metaArrays:a,mentionType:o,mentionedUserIds:u,pushNotificationDeliveryOption:c,rootMessageId:d,parentMessageId:h,appleCriticalAlertOptions:f,pollId:_,isReplyToChannel:m},(function(e,r){var i=null;if(e){if(D._isAutoResendRegistered&&ie.isAutoResendableError(e.code))return;(i=new T(w)).requestState=O.MessageRequestState.FAILED,i.requestedMentionUserIds=u,C&&(i._isAutoResendRegistered=C._isAutoResendRegistered),e.code===H.REQUEST_CANCELED?(i.sendingStatus=O.MessageSendingStatus.CANCELED,k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){M.send({source:be.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(new H(e.message,e.code),i)}))):(i.errorCode=e.code,i.sendingStatus=O.MessageSendingStatus.FAILED,P&&ie.isAutoResendableError(e.code)&&(i.sendingStatus=O.MessageSendingStatus.PENDING,i.errorCode=0,i._isAutoResendRegistered=!0),k.upsert([i],de.UNSENT).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,i),M.send({source:be.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){var t=i._clone();t.sendingStatus=O.MessageSendingStatus.FAILED,t.errorCode=e.code,t._isAutoResendRegistered=!1,N&&N(new H(e.message,e.code),t)})))}else{for(var s in(i=new T(r)).reqId=n,i.requestState=O.MessageRequestState.SUCCEEDED,i.sendingStatus=O.MessageSendingStatus.SUCCEEDED,C&&(i._isAutoResendRegistered=C._isAutoResendRegistered),t.lastMessage=i,O.channelHandlers){O.channelHandlers[s].onChannelChanged(t)}R.upsert([t]).then((function(){M.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return k.upsert([i],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,i),M.send({source:be.EVENT_MESSAGE_SENT,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(null,i)}))}})):O.sendCommand(e,(function(r,i){if(O.getErrorFirstCallback()){var s=[r,i];i=s[0],r=s[1]}if(i){if(D._isAutoResendRegistered&&ie.isAutoResendableError(i.code))return;var a=new T(w);a.reqId=e.requestId,a.requestState=O.MessageRequestState.FAILED,i.code===H.REQUEST_CANCELED?(a.sendingStatus=O.MessageSendingStatus.CANCELED,t.isGroupChannel()&&k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){M.send({source:be.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:a}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(new H(i.message,i.code),a)}))):(a.sendingStatus=O.MessageSendingStatus.FAILED,a.errorCode=i.code,a.requestedMentionUserIds=u,t.isGroupChannel()?(P&&ie.isAutoResendableError(i.code)&&(a.sendingStatus=O.MessageSendingStatus.PENDING,a.errorCode=0,a._isAutoResendRegistered=!0),k.upsert([a],de.UNSENT).then((function(){return Xe._completeCurrentAndProcessNextAutoResend(O,a),M.send({source:be.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:a}})})).catch((function(e){J.error(e)})).finally((function(){var e=a._clone();e.sendingStatus=O.MessageSendingStatus.FAILED,e.errorCode=i.code,e._isAutoResendRegistered=!1,N&&N(new H(i.message,i.code),e)}))):N&&N(new H(i.message,i.code),a))}else{var o=new T(l(l({},r.getJsonElement()),{},{messageParams:E}));o.reqId=n,o.requestState=O.MessageRequestState.SUCCEEDED,o.sendingStatus=O.MessageSendingStatus.SUCCEEDED,C&&(o._isAutoResendRegistered=C._isAutoResendRegistered);var c=O.currentUser;if(c&&o._sender&&c.userId===o._sender.userId&&(c.nickname!==o._sender.nickname&&(c.nickname=o._sender.nickname),c.plainProfileUrl!==o._sender.plainProfileUrl&&(c.plainProfileUrl=o._sender.plainProfileUrl),ie.deepEqual(c.metaData,o._sender.metaData)||(c.metaData=o._sender.metaData)),t.isGroupChannel()){t.lastMessage=o,Object.keys(O.channelHandlers).forEach((function(e){O.channelHandlers[e].onChannelChanged(t)}));var d=Ie.of(t._iid);Et.of(t._iid).upsert([t]).then((function(){d.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return k.upsert([o],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,o),d.send({source:be.EVENT_MESSAGE_SENT,payload:{channel:t,message:o}})})).catch((function(e){J.error(e)})).finally((function(){N&&N(null,o)}))}else N&&N(null,o)}}))})),D}},{key:"sendUserMessage",value:function(){var e=tt.toArray(arguments),t=e.pop(),n=null,r=null,i=x.get(this._iid),s=i.UserMessageParams;if("function"==typeof t)if(e[0]instanceof s)null===(r=e[0]).data&&(r.data=""),null===r.customType&&(r.customType="");else if("string"==typeof e[0])switch((r=new s).message=e[0],e.length){case 1:break;case 2:r.data=e[1]||"";break;case 3:r.data=e[1]||"",r.customType=e[2]||"";break;case 4:r.data=e[1]||"",r.customType=e[2]||"",r.translationTargetLanguages=Array.isArray(e[3])?e[3]:[e[3]];break;default:n=tt.error}else n=tt.error;else n=tt.error;var a=U.get(this._iid),o=a.container.isErrorFirstInCallback;return!n&&r._validate()&&r.message?this._sendUserMessage(l(l({},r),{},{metaArrays:r.metaArrays,mentionType:r.mentionType,mentionedUserIds:r._mentionedUserIds,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,messageParams:r,callback:function(e,n){o?t(e,n):t(n,e)}})):(o?t(tt.error,null):t(null,tt.error),null)}},{key:"_autoResendUserMessage",value:function(e){var t=this,n=Ri.getInstance(this._iid);if(n&&n.currentUser){var r=e._messageParams;return new Promise((function(n,i){return t._sendUserMessage(l(l({},r),{},{reqId:e.reqId,metaArrays:r.metaArrays,mentionType:r.mentionType,mentionedUserIds:r._mentionedUserIds,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,pushNotificationDeliveryOption:r.pushNotificationDeliveryOption,messageParams:r,oldMessage:e,callback:function(e,t){e?i(e):n(t)}}))}))}}},{key:"_autoResendFileMessage",value:function(e){var t=Ri.getInstance(this._iid);if(t&&t.currentUser){var n=this._parsePendingFileMessage(e),r=x.get(this._iid).FileMessageQueue;r.create(this).addJob(new r.Job({fileInfo:n,pendingMessage:e._clone(),requestId:e.reqId,error:n.error,response:null}))}}},{key:"resendUserMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.UserMessage,s=r.UserMessageParams,a=null,o=tt.parse(arguments,[new tt({type:i,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===n.url&&"string"==typeof e.message&&"string"==typeof e.data&&"string"==typeof e.customType&&"object"===u(e.translations)&&!Array.isArray(e.translations)}}),new tt({type:"callback"})]),c=b(o,3);return a=c[0],e=c[1],t=c[2],oe(this._iid,(function(t){if(a)a.message+=" Please check if the failed message is resend-able with `message.isResendable().`",t(a,null);else{var r=Object.keys(e.translations),i=s.PushNotificationDeliveryOption.DEFAULT;n._sendUserMessage(l(l({},e),{},{mentionedUserIds:e.requestedMentionUserIds,translationTargetLanguages:r,pushNotificationDeliveryOption:i,reqId:e.reqId,messageParams:e._messageParams,isManualResend:!0,callback:t}))}}),t)}},{key:"updateUserMessage",value:function(e,t,n,r,i){var s=this,a=x.get(this._iid),o=a.Command,u=a.UserMessage,c=a.UserMessageParams,d=arguments,h=null,p=null;if("number"==typeof e)switch(d.length){case 3:var f=tt.parse(d,[new tt({type:"number"}),new tt({type:c}),new tt({type:"callback"})]),_=b(f,4);h=_[0],e=_[1],p=_[2],i=_[3];break;case 5:p=new c;var y=tt.parse(d,[new tt({type:"number"}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),g=b(y,6);h=g[0],e=g[1],t=g[2],n=g[3],r=g[4],i=g[5],p.message=t,p.data=n,p.customType=r}return oe(this._iid,(function(t){if(!h&&p&&p._validate()){var n=o.bUpdateUserMessage(l(l({channelUrl:s.url,messageId:e},p),{},{mentionType:p._mentionType,mentionedUserIds:p._mentionedUserIds})),r=Ri.getInstance(s._iid),i=Ae.of(s._iid),a=Ie.of(s._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var o=[e,n];n=o[0],e=o[1]}var c=null;n||(c=new u(l(l({},e.getJsonElement()),{},{messageParams:p})),s.isGroupChannel()&&i.upsert([c],de.SUCCEEDED).then((function(){a.send({source:be.EVENT_MESSAGE_UPDATED,payload:{channel:s,message:c}})})).catch((function(e){J.error(e)}))),t(n,c)}))}else t(tt.error,null)}),i)}},{key:"translateUserMessage",value:function(e,t,n){var r=this,i=Ri.getInstance(this._iid),s=x.get(this._iid),a=s.UserMessage,o=null,l=tt.parse(arguments,[new tt({type:a,constraint:function(e){return e.channelUrl===r.url&&e.sendingStatus===i.MessageSendingStatus.SUCCEEDED}}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),u=b(l,4);return o=u[0],e=u[1],t=u[2],n=u[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.translateUserMessage({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),messageId:e.messageId,translationTargetLanguages:t},(function(e,t){var r=null;e||(r=new a(t)),n(e,r)}))}),n)}},{key:"_parsePendingFileMessage",value:function(e){var t=e._messageParams.serialize(),n=t.data,r=t.customType,i=t.fileUrl,s=t.thumbnailSizes,a=t.mentionType,o=t.mentionedUserIds,l=t.metaArrays,u=t.parentMessageId,c=t.pushNotificationDeliveryOption,d=e._messageParams;return{file:d.file?d.file:i,name:e.name,type:e.type,size:e.size,data:n,customType:r,thumbnailSizes:s,metaArrays:l,mentionType:a,mentionedUserIds:o,pushNotificationDeliveryOption:c,rootMessageId:u,parentMessageId:u,appleCriticalAlertOptions:d.appleCriticalAlertOptions,messageParams:e._messageParams,silent:e.silent,error:null,progressHandler:null,callback:null}}},{key:"_parseFileMessageArguments",value:function(e){var t=x.get(this._iid),n=t.BaseMessageParams,r=t.FileMessageParams,i={error:null,file:null,name:null,type:null,size:null,data:"",customType:"",thumbnailSizes:[],metaArrays:[],mentionType:n.MentionType.USERS,mentionedUserIds:[],pushNotificationDeliveryOption:r.PushNotificationDeliveryOption.DEFAULT,rootMessageId:null,parentMessageId:null,progressHandler:null,silent:!1,appleCriticalAlertOptions:null,isReplyToChannel:!1,messageParams:null,callback:null};if("function"==typeof e[e.length-1]&&(i.callback=e.pop()),"function"==typeof e[e.length-1]&&(i.progressHandler=e.pop()),e[0]instanceof r)i.file=e[0].file||e[0].fileUrl,i.name=e[0].fileName,i.type=e[0].mimeType,i.size=e[0].fileSize,i.data=e[0].data,i.customType=e[0].customType,i.thumbnailSizes=e[0].thumbnailSizes,i.metaArrays=e[0].metaArrays,i.mentionType=e[0]._mentionType,i.mentionedUserIds=e[0]._mentionedUserIds,i.pushNotificationDeliveryOption=e[0].pushNotificationDeliveryOption?e[0].pushNotificationDeliveryOption:r.PushNotificationDeliveryOption.DEFAULT,i.rootMessageId=e[0].rootMessageId,i.parentMessageId=e[0].parentMessageId,i.silent=e[0].silent,e[0]._validate()||(i.error=tt.error),i.appleCriticalAlertOptions=e[0].appleCriticalAlertOptions,i.isReplyToChannel=e[0].isReplyToChannel,i.messageParams=e[0];else if(ie.isFile(e[0])||"string"==typeof e[0]){switch(i.file=e[0],e.length){case 1:break;case 2:i.data=e[1];break;case 3:i.data=e[1],i.customType=e[2];break;case 4:i.data=e[1],i.customType=e[2],i.thumbnailSizes=e[3];break;case 5:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4];break;case 6:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4],i.customType=e[5];break;case 7:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4],i.customType=e[5],i.thumbnailSizes=e[6]}var s=b(tt.parse([i.file,i.name,i.type,i.size,i.data,i.customType,i.thumbnailSizes],[new tt({type:["file","string"]}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"number",nullable:!0,constraint:function(e){return e>=0}}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"array"})]),8);i.error=s[0],i.file=s[1],i.name=s[2],i.type=s[3],i.size=s[4],i.data=s[5],i.customType=s[6],i.thumbnailSizes=s[7];var a=ie.isFile(i.file);a&&(i.name=i.name||i.file.name,i.type=i.type||i.file.type,i.size=i.size||i.file.size),i.messageParams={mentionType:n.MentionType.USERS,mentionedUserIds:i.mentionedUserIds,cachedMentionedUsers:[],cachedMentionedUserIds:[],metaArrays:i.metaArrays,parentMessageId:i.parentMessageId,pushNotificationDeliveryOption:i.pushNotificationDeliveryOption,appleCriticalAlertOptions:i.appleCriticalAlertOptions,fileName:i.name,mimeType:i.type,fileSize:i.size,data:i.data,customType:i.customType,isUpdate:!1,file:a?i.file:null,fileUrl:a?null:i.file,thumbnailSizes:i.thumbnailSizes}}else i.error=tt.error;return ie.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 t=Ri.getInstance(this._iid),n=x.get(this._iid),r=n.Command,i=n.FileMessage,s=l(l({},e),{},{messageId:0,reqId:r.generateRequestId(),user:t.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:t.MessageSendingStatus.PENDING,createdAt:(new Date).getTime()}),a=i.objectify(s);return new i(a)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this,t=tt.toArray(arguments),n=this._parseFileMessageArguments(t),r=x.get(this._iid),i=r.Command,s=null,a=i.generateRequestId();n.error||((s=this._createTempFileMessage(n)).requestedMentionUserIds=n.mentionedUserIds,a=s.reqId);var o=Ri.getInstance(this._iid);if(o&&o.currentUser||(n.error=new H("Connection should be made first.",H.CONNECTION_REQUIRED)),this.isGroupChannel()){var l=Ae.of(this._iid),u=Ie.of(this._iid);l.upsert([s],de.UNSENT).then((function(){u.send({source:be.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:e,message:s}})}))}var c=x.get(this._iid),d=c.FileMessageQueue,h=d.create(this);return h.addJob(new d.Job({fileInfo:n,pendingMessage:s,requestId:a,error:n.error,response:null})),s}},{key:"sendFileMessages",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.progress?n.progress:function(){},i=n.sent?n.sent:function(){},s=n.complete?n.complete:function(){};if(Array.isArray(e)&&e.length>0&&e.length<=20){var a=[];return e.forEach((function(n,o){a.push(t.sendFileMessage(n,r,(function(t,n){i(t,n),o===e.length-1&&s(null)})))})),a}return s(tt.error),null}},{key:"resendFileMessage",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.FileMessage,a=i.FileMessageParams,o=null,l=tt.parse(arguments,[new tt({type:s,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 tt({type:"file",optionalIf:function(e){return!!e[0].plainUrl},defaultValue:null}),new tt({type:"callback"})]),u=b(l,4);return o=u[0],e=u[1],t=u[2],n=u[3],oe(this._iid,(function(n){if(o)o.message+=" Please check if the failed message is resend-able with `message.isResendable().`",n(o,null);else{var i=new a;e.plainUrl?i.fileUrl=e.plainUrl:i.file=t,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,n)}}),n)}},{key:"updateFileMessage",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.Command,o=s.FileMessage,u=s.FileMessageParams,c=arguments,d=null,h=null;if("number"==typeof e)switch(c.length){case 3:var p=tt.parse(c,[new tt({type:"number"}),new tt({type:u}),new tt({type:"callback"})]),f=b(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 _=tt.parse(c,[new tt({type:"number"}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),y=b(_,5);d=y[0],e=y[1],t=y[2],n=y[3],r=y[4],h.data=t,h.customType=n,h._isUpdate=!0}return oe(this._iid,(function(t){if(!d&&h&&h._validate()){var n=a.bUpdateFileMessage(l(l({channelUrl:i.url,messageId:e},h),{},{mentionType:h._mentionType,mentionedUserIds:h._mentionedUserIds})),r=Ri.getInstance(i._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var s=[e,n];n=s[0],e=s[1]}var a=null;if(!n&&(a=new o(l(l({},e.getJsonElement()),{},{messageParams:h})),i.isGroupChannel())){var u=Ae.of(i._iid),c=Ie.of(i._iid);u.upsert([a],de.SUCCEEDED).then((function(){c.send({source:be.EVENT_MESSAGE_UPDATED,payload:{channel:i,message:a}})})).catch((function(e){J.error(e)}))}t(n,a)}))}else t(tt.error,null)}),r)}},{key:"cancelUploadingFileMessage",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:["number","string"]}),new tt({type:"callback"})]),i=b(r,3);n=i[0],e=i[1],t=i[2];var s=U.get(this._iid),a=s.container.isErrorFirstInCallback;if(n)return a?t(n,null):t(null,n),!1;var o=x.get(this._iid),l=o.FileMessageQueue,u=l.create(this);return u.cancelUploadItemByRequestId(e,(function(e,n){return a?t(e,n):t(n,e)}))}},{key:"addReaction",value:function(e,t,n){var r=this,i=Ri.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=tt.parse(arguments,[new tt({type:St}),new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),c=b(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?U.get(r._iid).container.apiClient.addReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:t},(function(t,r){var i=null;t||(i=a.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),n(t,i)})):n(new H("Cannot add reaction to a non-succeeded message.",H.REQUEST_FAILED),null)}),n)}},{key:"deleteReaction",value:function(e,t,n){var r=this,i=Ri.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=tt.parse(arguments,[new tt({type:St}),new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),c=b(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?U.get(r._iid).container.apiClient.deleteReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:t},(function(t,r){var i=null;t||(i=a.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),n(t,i)})):n(new H("Cannot remove reaction to a non-succeeded message.",H.REQUEST_FAILED),null)}),n)}},{key:"deleteMessage",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMessage({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),messageId:e.messageId},(function(r,i){if(!r&&n.isGroupChannel()){var s=Ae.of(n._iid),a=Ie.of(n._iid);s.remove([e.messageId],de.SUCCEEDED).then((function(){a.send({source:be.EVENT_MESSAGE_DELETED,payload:{channel:n,message:e}})})).catch((function(e){return J.error(e)}))}t(r,null)}))}),t)}},{key:"copyUserMessage",value:function(t,n,r){var i=x.get(this._iid);i.Command;var s=i.UserMessage,a=i.BaseMessageParams,o=null,u=tt.parse(arguments,[new tt({type:e}),new tt({type:s}),new tt({type:"callback"})]),c=b(u,4);o=c[0],t=c[1],n=c[2],r=c[3];var d=U.get(this._iid),h=d.container.isErrorFirstInCallback;if(o)return h?r(tt.error,null):r(null,tt.error),null;if(this.url!==n.channelUrl){var p=new H("The message does not belong to this channel",H.INVALID_PARAMETER);return h?r(p,null):r(null,p),null}var f={},_=Object.keys(n.translations);_.forEach((function(e){return f[e]=""}));var y=a.PushNotificationDeliveryOption.DEFAULT;return t._sendUserMessage(l(l({},n),{},{reqId:null,pushNotificationDeliveryOption:y,translationTargetLanguages:_,rootMessageId:null,parentMessageId:null,parentMessageText:null,messageParams:n._messageParams,callback:r}))}},{key:"copyFileMessage",value:function(t,n,r){var i=this,s=x.get(this._iid),a=s.Command;s.GroupChannel;var o=s.FileMessage,l=s.BaseMessageParams;s.FileMessageParams;var u=s.User,c=null,d=tt.parse(arguments,[new tt({type:e}),new tt({type:o}),new tt({type:"callback"})]),h=b(d,4);c=h[0],t=h[1],n=h[2],r=h[3];var p=U.get(this._iid),f=p.container.isErrorFirstInCallback;if(c)return f?r(tt.error,null):r(null,tt.error),null;if(this.url!==n.channelUrl){var _=new H("The message does not belong to this channel");return f?r(_,null):r(null,_),null}var y=Ri.getInstance(this._iid),g=n,m=g.url,E=g.name,v=g.type,C=g.size,A=g.data,N=g.customType,S=g.mentionType,I=g.mentionedUserIds,T=g.mentionedUsers,O=g.metaArrays,k=g.thumbnails,R=g.requireAuth,M=g.messageSurvivalSeconds,P=g.silent,L=g.appleCriticalAlertOptions,w=a.generateRequestId(),D=y.currentUser||{},F=t.url,G=t.isOpenChannel(),j=T.filter((function(e){return new u(u.objectify(e))})),V=l.PushNotificationDeliveryOption.DEFAULT,B=o.objectify({messageId:0,reqId:w,user:D,channel:t,plainUrl:m,name:E,type:v,size:C,data:A,customType:N,mentionType:S,mentionedUserIds:I,mentionedUsers:j,requestedMentionUserIds:I,metaArrays:O,thumbnails:k,requireAuth:R,messageSurvivalSeconds:M,silent:P,createdAt:(new Date).getTime(),appleCriticalAlertOptions:L}),K=new o(B);if(K.requestState=y.MessageRequestState.PENDING,K.sendingStatus=y.MessageSendingStatus.PENDING,!y.currentUser){var q=new H("Connection should be made first.",H.CONNECTION_REQUIRED),z=new o(B);return z.requestState=y.MessageRequestState.FAILED,z.sendingStatus=y.MessageSendingStatus.FAILED,z.errorCode=q.code,f?r(q,z):r(z,q),K}var Y=a.bFile({requestId:w,channelUrl:F,url:m,name:E,type:v,size:C,data:A,customType:N,metaArrays:O,mentionType:S,mentionedUserIds:I,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:V,silent:P,appleCriticalAlertOptions:L});return y.getConnectionState()===y.ConnectionState.OPEN||y.connecting||y.reconnecting?y.sendCommand(Y,(function(e,n){if(y.getErrorFirstCallback()){var s=[e,n];n=s[0],e=s[1]}if(n)if(n.code!==H.INVALID_PARAMETER){var a=new o(B);a.requestState=y.MessageRequestState.FAILED,a.sendingStatus=y.MessageSendingStatus.FAILED,n.code!==H.FILE_UPLOAD_CANCEL_FAILED&&n.code!==H.REQUEST_CANCELED||(a.sendingStatus=y.MessageSendingStatus.CANCELED),a.errorCode=n.code,f?r(n,a):r(a,n)}else f?r(n,null):r(null,n);else{var l=new o(e.getJsonElement()),u=l._sender;if(D&&u&&D.userId===u.userId&&(D.nickname!==u.nickname&&(D.nickname=u.nickname),D.plainProfileUrl!==u.plainProfileUrl&&(D.plainProfileUrl=u.plainProfileUrl)),t.isGroupChannel()){t.lastMessage=l,Object.keys(y.channelHandlers).forEach((function(e){y.channelHandlers[e].onChannelChanged(t)}));var c=Ie.of(i._iid);Et.of(i._iid).upsert([t]).then((function(){c.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).catch((function(e){J.error(e)})),Ae.of(i._iid).upsert([l]).then((function(){c.send({source:be.EVENT_MESSAGE_SENT,payload:{channel:i,message:l}})})).catch((function(e){J.error(e)}))}f?r(null,l):r(l,null)}})):p.container.apiClient.sendFileMessage({channelUrl:F,isOpenChannel:G,fileUrl:m,fileName:E,fileType:v,fileSize:C,data:A,customType:N,metaArrays:O,mentionType:S,mentionedUserIds:I,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:V,appleCriticalAlertOptions:L},(function(e,n){if(e)if(e.code!==H.INVALID_PARAMETER){var i=new o(commnad.getJsonElement());i.requestState=y.MessageRequestState.FAILED,i.sendingStatus=y.MessageSendingStatus.FAILED,e.code!==H.FILE_UPLOAD_CANCEL_FAILED&&e.code!==H.REQUEST_CANCELED||(i.sendingStatus=y.MessageSendingStatus.CANCELED),i.errorCode=e.code,f?r(e,i):r(i,e)}else f?r(e,null):r(null,e);else{var s=new o(n),a=s._sender;D&&a&&D.userId===a.userId&&(D.nickname!==a.nickname&&(D.nickname=a.nickname),D.plainProfileUrl!==a.plainProfileUrl&&(D.plainProfileUrl=a.plainProfileUrl)),t.isGroupChannel()&&(t.lastMessage=s,Object.keys(y.channelHandlers).forEach((function(e){y.channelHandlers[e].onChannelChanged(t)}))),f?r(null,s):r(s,null)}})),K}},{key:"addOperators",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.addOperators({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),operatorUserIds:e},(function(e,n){return t(e,n)}))}),t)}},{key:"removeOperators",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.removeOperators({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),operatorUserIds:e},(function(e,n){return t(e,n)}))}),t)}},{key:"getMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),keys:e},(function(e,n){return t(e,n)}))}),t)}},{key:"getAllMetaCounters",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),keys:[]},(function(t,n){return e(t,n)}))}),e)}},{key:"createMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.createMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e},(function(e,n){return t(e,n)}))}),t)}},{key:"updateMetaCounters",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateMetaCounters({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaCounter:e,upsert:t,mode:"set"},(function(e,t){return n(e,t)}))}),n)}},{key:"increaseMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e,upsert:!1,mode:"increase"},(function(e,n){return t(e,n)}))}),t)}},{key:"decreaseMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e,upsert:!1,mode:"decrease"},(function(e,n){var r=null;e||(r={},Object.keys(n).forEach((function(e){r[e]=n[e]}))),t(e,r)}))}),t)}},{key:"deleteMetaCounter",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMetaCounter({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),key:e},(function(e,n){return t(e,n)}))}),t)}},{key:"deleteAllMetaCounters",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteAllMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel()},(function(t,n){return e(t,n)}))}),e)}},{key:"getCachedMetaData",value:function(){var e=Ot.get(this),t={};return Object.keys(e).forEach((function(n){var r=e[n];r.isRemoved||(t[n]=r.value)})),t}},{key:"getMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),keys:e},(function(e,n){t(e,n&&n.ts?n.metadata:n)}))}),t)}},{key:"getAllMetaData",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMetaData({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),keys:[]},(function(t,n){e(t,n&&n.ts?n.metadata:n)}))}),e)}},{key:"createMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.createMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaData:e},(function(e,n){t(e,n&&n.ts?n.metadata:n)}))}),t)}},{key:"updateMetaData",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateMetaData({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaData:e,upsert:t},(function(e,t){n(e,t&&t.ts?t.metadata:t)}))}),n)}},{key:"deleteMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),key:e},(function(e,n){t(e,n&&n.ts?{}:n)}))}),t)}},{key:"deleteAllMetaData",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteAllMetaData({channelUrl:t.url,isOpenChannel:t.isOpenChannel()},(function(t,n){return e(t,n&&n.ts?{}:n)}))}),e)}},{key:"_updateMessageMetaArray",value:function(e,t,n,r){var i=this;return oe(this._iid,(function(r){var s=x.get(i._iid),a=s.Command,o=s.UserMessage,l=s.FileMessage,u=s.AdminMessage,c=null;if(t.isUserMessage()?c=a.bUpdateUserMessage({channelUrl:e,messageId:t.messageId,metaArrayParams:n}):t.isFileMessage()&&(c=a.bUpdateFileMessage({channelUrl:e,messageId:t.messageId,metaArrayParams:n})),c){var d=Ri.getInstance(i._iid);d.sendCommand(c,(function(e,n){if(d.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}var s=null;n||(t.isUserMessage()?s=new o(e.getJsonElement()):t.isFileMessage()?s=new l(e.getJsonElement()):t.isAdminMessage()&&(s=new u(e.getJsonElement()))),r(n,s)}))}else r(tt.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=tt.parse(arguments,[new tt({type:St}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new tt({type:"callback"})]),o=b(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=[];if(Array.isArray(t))for(var u=0;u0&&e.every((function(e){return e instanceof i}))||Object.keys(e).length>0&&Object.keys(e).every((function(t){return Array.isArray(e[t])&&e[t].length>0&&e[t].every((function(e){return"string"==typeof e&&e.length>0}))})))}}),new tt({type:"callback"})]),o=b(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=Array.isArray(t)?t.map((function(e){return e.encode()})):Object.keys(t).map((function(e){return{key:e,value:t[e]}}));return this._updateMessageMetaArray(this.url,e,{array:l,mode:"add",upsert:!0},n)}},{key:"removeMessageMetaArrayValues",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=tt.parse(arguments,[new tt({type:St}),new tt({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(t){return Array.isArray(e[t])&&e[t].length>0&&e[t].every((function(e){return"string"==typeof e&&e.length>0}))})))}}),new tt({type:"callback"})]),o=b(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=Array.isArray(t)?t.map((function(e){return e.encode()})):Object.keys(t).map((function(e){return{key:e,value:t[e]}}));return this._updateMessageMetaArray(this.url,e,{array:l,mode:"remove",upsert:!0},n)}},{key:"report",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=null,o=tt.parse(arguments,[new tt({type:s.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),l=b(o,4);return a=l[0],e=l[1],t=l[2],n=l[3],oe(this._iid,(function(n){if(a)n(a,null);else{var i=Ri.getInstance(r._iid);U.get(r._iid).container.apiClient.report({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),reportCategory:e,reportingUserId:i.currentUser?i.currentUser.userId:null,reportDescription:t},(function(e,t){n(e,null)}))}}),n)}},{key:"reportUser",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=null,l=tt.parse(arguments,[new tt({type:It}),new tt({type:a.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),u=b(l,5);return o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],oe(this._iid,(function(r){if(o)r(o,null);else{var s=Ri.getInstance(i._iid);U.get(i._iid).container.apiClient.reportUser({channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:t,offendingUserId:e.userId,reportingUserId:s.currentUser?s.currentUser.userId:null,reportDescription:n},(function(e,t){r(e,null)}))}}),r)}},{key:"reportMessage",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=null,l=tt.parse(arguments,[new tt({type:St}),new tt({type:a.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),u=b(l,5);return o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],oe(this._iid,(function(r){if(o)r(o,null);else{var s=Ri.getInstance(i._iid);U.get(i._iid).container.apiClient.reportMessage({messageId:e.messageId,channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:t,offendingUserId:e.sender.userId,reportingUserId:s.currentUser?s.currentUser.userId:null,reportDescription:n},(function(e,t){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,t){var n=x.get(this._iid),r=n.UserMessage,i=n.FileMessage,s=n.AdminMessage;if(e)switch(e.hasOwnProperty("channel_type")||(e.channel_type=t.channelType),e.type){case"MESG":return new r(e);case"FILE":var a=e.file;return new i(l(l({},e),{},{url:String(a.url),name:String(a.name),type:String(a.type),size:parseInt(a.size),data:String(a.data)}));case"BRDM":case"ADMM":return new s(e)}return null}}]),e}(),Rt=function(){function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0,this.data=t.hasOwnProperty("data")?t.data:null,this.channelUrl=t.hasOwnProperty("channel_url")?String(t.channel_url):"",this.channelType=t.hasOwnProperty("channel_type")?String(t.channel_type):kt.CHANNEL_TYPE_GROUP)}return h(e,[{key:"isGroupChannel",value:function(){return this.channelType===kt.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===kt.CHANNEL_TYPE_OPEN}}]),e}();Rt.CATEGORY_NONE=0,Rt.CATEGORY_CHANNEL_ENTER=10102,Rt.CATEGORY_CHANNEL_EXIT=10103,Rt.CATEGORY_USER_CHANNEL_MUTE=10201,Rt.CATEGORY_USER_CHANNEL_UNMUTE=10200,Rt.CATEGORY_USER_CHANNEL_BAN=10601,Rt.CATEGORY_USER_CHANNEL_UNBAN=10600,Rt.CATEGORY_CHANNEL_FREEZE=10701,Rt.CATEGORY_CHANNEL_UNFREEZE=10700,Rt.CATEGORY_TYPING_START=10900,Rt.CATEGORY_TYPING_END=10901,Rt.CATEGORY_CHANNEL_JOIN=1e4,Rt.CATEGORY_CHANNEL_LEAVE=10001,Rt.CATEGORY_CHANNEL_OPERATOR_UPDATE=10002,Rt.CATEGORY_CHANNEL_INVITE=10020,Rt.CATEGORY_CHANNEL_DECLINE_INVITE=10022,Rt.CATEGORY_CHANNEL_PROP_CHANGED=11e3,Rt.CATEGORY_CHANNEL_DELETED=12e3,Rt.CATEGORY_CHANNEL_META_DATA_CHANGED=11100,Rt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED=11200,Rt.CATEGORY_CHANNEL_HIDE=13e3,Rt.CATEGORY_CHANNEL_UNHIDE=13001;var Mt=function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0)};Mt.CATEGORY_USER_BLOCK=20001,Mt.CATEGORY_USER_UNBLOCK=2e4,Mt.CATEGORY_FRIEND_DISCOVERED=20900;var Pt=function(){function e(t){c(this,e),this.sb=t,this.cls=x.get(this.sb._iid)}return h(e,[{key:"onRawCommandReceived",value:function(e){var t=this,n=this.cls,r=n.Command,i=n.User,s=n.Member,a=n.RestrictedUser,o=n.BaseChannel,c=n.GroupChannel,d=n.OpenChannel,h=n.UserMessage,p=n.FileMessage,f=n.AdminMessage,_=n.BaseMessageParams,y=n.ReactionEvent,g=n.ReadStatus,m=n.ThreadInfoUpdateEvent,E=n.PollUpdateEvent,v=n.PollVoteEvent,C=n.RestrictionInfo,b=U.get(this.sb._iid),A=b.container,N=A.pinger,S=A.auth,O=A.subscribedUnreadMessageCount,k=A.sessionManager,R=A.ackStateMap,M=new r(e),P=M.getJsonElement();if(P.hasOwnProperty("unread_cnt")&&"object"===u(P.unread_cnt)){var L=!1,w=P.unread_cnt.ts;"number"==typeof w&&w>O.ts&&(O.all!==P.unread_cnt.all&&(L=!0),O.all=P.unread_cnt.all>=0?P.unread_cnt.all:0,P.unread_cnt.custom_types&&Object.keys(P.unread_cnt.custom_types).forEach((function(e){O.custom_types[e]!==P.unread_cnt.custom_types[e]&&(L=!0),O.custom_types[e]=P.unread_cnt.custom_types[e]})),L=L&&O.ts>0,O.ts=w),L&&Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onTotalUnreadMessageCountUpdated(O.all,O.custom_types)}))}var D=M.requestId;if(D){var F=R[D];if(F){clearTimeout(F.timer);var G=F.handler;G&&("EROR"===M.command?G(new H(P.message,P.code),null):G(null,M)),R.hasOwnProperty(D)&&delete R[D]}}else{N&&"LOGI"!==M.command&&N.refreshTimer();var x=Et.of(this.sb._iid),j=Ae.of(this.sb._iid),V=Ie.of(this.sb._iid);switch(M.command){case"LOGI":if(this.sb.loginTimer)if(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,P.hasOwnProperty("error"))this.sb.isSessionOpened=!1,this.sb.loginHandler(new H(P.message,P.code),null);else{if(this.sb.isSessionOpened=!0,P.hasOwnProperty("key")&&(S.sessionKey=P.key),P.hasOwnProperty("ekey")&&(S.eKey=P.ekey),P.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(P)),"number"==typeof P.ping_interval&&P.ping_interval>0&&b.set("pingInterval",1e3*P.ping_interval),"number"==typeof P.pong_timeout&&P.pong_timeout>0&&b.set("pongTimeout",1e3*P.pong_timeout),"number"==typeof P.login_ts){var B=1e3*P.login_ts;b.set("connectedAt",B),b.container.firstConnectedAt||b.set("firstConnectedAt",B)}"number"==typeof P.max_unread_cnt_on_super_group?b.set("maxUnreadCountOfSuperGroupChannel",P.max_unread_cnt_on_super_group):b.set("maxUnreadCountOfSuperGroupChannel",T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),P.profile_image_encryption&&b.set("profileImageEncryption",!0),N&&N.start(),P.hasOwnProperty("file_upload_size_limit")&&P.hasOwnProperty("premium_feature_list")&&P.hasOwnProperty("emoji_hash")&&b.set("appInfo",new $e(P)),P.hasOwnProperty("concurrent_call_limit")&&P.hasOwnProperty("back_off_delay")&&(b.set("concurrentCallLimit",P.concurrent_call_limit),b.set("backOffDelay",P.back_off_delay)),this.sb.loginHandler(null,this.sb.currentUser)}break;case"EXPR":var K=new H("The session would be expired.",P.reason||H.SESSION_KEY_EXPIRED);k.refreshSessionIfExpiredError(K).then((function(){})).catch((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var q=null;if("MESG"===M.command?q=new h(P):"FILE"===M.command?q=new p(P):"BRDM"!==M.command&&"ADMM"!==M.command||(q=new f(P)),q){var z=this.sb.currentUser?this.sb.currentUser.userId:null,Y=q.silent,Q=!!P.force_update_last_message,W=q._sender&&q._sender.userId===z;if(q.isGroupChannel()){var X=c.cachedChannels.hasOwnProperty(q.channelUrl);c.getChannel(q.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}if(!n){if(!b.container.appInfo.isSupergroupMackDisabled||!e.isSuper||e.isBroadcast){var s=r.bMessageAck({channelUrl:q.channelUrl,messageId:q.messageId});t.sb.sendCommand(s)}if(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,q._sender&&e.memberMap.hasOwnProperty(q._sender.userId)){var a=e.memberMap[q._sender.userId];a.nickname!==q._sender.nickname&&(a.nickname=q._sender.nickname),a.plainProfileUrl!==q._sender.plainProfileUrl&&(a.plainProfileUrl=q._sender.plainProfileUrl),ie.deepEqual(a.metaData,q._sender.metaData)||(a.metaData=q._sender.metaData),a.isBlockedByMe!==q._sender.isBlockedByMe&&(a.isBlockedByMe=q._sender.isBlockedByMe)}var o=t.sb.currentUser;o&&W&&(o.nickname!==q._sender.nickname&&(o.nickname=q._sender.nickname),o.plainProfileUrl!==q._sender.plainProfileUrl&&(o.plainProfileUrl=q._sender.plainProfileUrl),ie.deepEqual(o.metaData,q._sender.metaData)||(o.metaData=q._sender.metaData));var l=!1;if(q.mentionType===_.MentionType.CHANNEL)W||(l=!0);else if(q.mentionType===_.MentionType.USERS)for(var u=0;u=Z.createAt,a=t.sb.currentUser;a&&te&&(a.nickname!==Z._sender.nickname&&(a.nickname=Z._sender.nickname),a.plainProfileUrl!==Z._sender.plainProfileUrl&&(a.plainProfileUrl=Z._sender.plainProfileUrl),ie.deepEqual(a.metaData,Z._sender.metaData)||(a.metaData=Z._sender.metaData));var o=!1,l=!1;if(!te&&!s&&P&&P.hasOwnProperty("old_values")){var u=P.old_values.mention_type||Z.mentionType,c=P.old_values.mentioned_user_ids||Z.mentionedUsers.map((function(e){return e.userId}));if(u===_.MentionType.USERS&&Z.mentionType===_.MentionType.USERS){for(var d=!1,h=!1,p=0;p0||e.unreadMentionCount>0)&&(e._setGroupChannelUnreadCount(0,0),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReadReceiptUpdated(e)})),V.send({source:be.EVENT_READ_RECEIPT_UPDATED,payload:{channel:e,user:oe.reader}})))}));break;case"MRCT":var ue=String(P.channel_type),ce=String(P.channel_url),de=y.createFromJson(P);switch(ue){case o.CHANNEL_TYPE_GROUP:c.getChannel(ce,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,de)})),j.get("".concat(de.messageId)).then((function(n){n&&(n.applyReactionEvent(de),j.upsert([n]).then((function(){V.send({source:be.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:de}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(ce,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,de)})),V.send({source:be.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:de}}))}))}break;case"DLVR":var he=String(P.channel_url),pe=P.hasOwnProperty("updated")?P.updated:null,fe=c.cachedChannels.hasOwnProperty(he);c.getChannel(he,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(!n){var i=!1;Object.keys(pe).forEach((function(n){t.sb.currentUser&&n===t.sb.currentUser.userId&&(i=!0),fe&&e.updateDeliveryReceipt(n,parseInt(pe[n]))})),c.cachedChannels[e.url]=e,i&&1===Object.keys(pe).length||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onDeliveryReceiptUpdated(e)})),V.send({source:be.EVENT_DELIVERY_RECEIPT_UPDATED,payload:{channel:e}}))}}));break;case"MTHD":var _e=String(P.channel_url),ye=String(P.channel_type),ge=m.createFromJson(P);switch(ye){case o.CHANNEL_TYPE_GROUP:c.getChannel(_e,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onThreadInfoUpdated(e,ge)})),j.get("".concat(ge.targetMessageId)).then((function(n){n&&(n.applyThreadInfoUpdateEvent(ge),j.upsert([n]).then((function(){V.send({source:be.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:ge}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(_e,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onThreadInfoUpdated(e,ge)})),V.send({source:be.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:ge}}))}))}break;case"MCNT":if(P.hasOwnProperty("group_channels")&&Array.isArray(P.group_channels)){var me,Ee=[],ve=I(P.group_channels);try{for(ve.s();!(me=ve.n()).done;){var Ce=me.value;if(Ce){var Ne=c.cachedChannels[Ce.channel_url];if(Ne&&Ne.isBroadcast)Ne.setLatestMemberCount(Ce.member_count,Ce.joined_member_count,Ce.ts)&&Ee.push(Ne)}}}catch(e){ve.e(e)}finally{ve.f()}Ee.length>0&&(Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelMemberCountChanged(Ee)})),x.upsert(Ee).then((function(){var e,t=I(Ee);try{for(t.s();!(e=t.n()).done;){var n=e.value;V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:n}})}}catch(e){t.e(e)}finally{t.f()}})).catch((function(e){t.handleCacheError(e)})))}if(P.hasOwnProperty("open_channels")&&Array.isArray(P.open_channels)){var Se,Te=[],Oe=I(P.open_channels);try{for(Oe.s();!(Se=Oe.n()).done;){var Ue=Se.value;if(Ue){var ke=d.cachedChannels[Ue.channel_url];if(ke)ke.setLatestParticipantCount(Ue.participant_count,Ue.ts)&&Te.push(ke)}}}catch(e){Oe.e(e)}finally{Oe.f()}if(Te.length>0){Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelParticipantCountChanged(Te)}));var Re,Me=I(Te);try{for(Me.s();!(Re=Me.n()).done;){var Pe=Re.value;V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:Pe}})}}catch(e){Me.e(e)}finally{Me.f()}}}break;case"PEDI":var Le=E.createFromJson(P);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollUpdated(Le)}));break;case"VOTE":var we=v.createFromJson(P);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollVoted(we)}));break;case"SYEV":var De=new Rt(P),He=P.ts;switch(De.category){case Rt.CATEGORY_CHANNEL_JOIN:case Rt.CATEGORY_CHANNEL_LEAVE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var a=De.data.hasOwnProperty("member_count")?De.data.member_count:null,o=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null,l=!1;if(De.category===Rt.CATEGORY_CHANNEL_JOIN){(De.data.hasOwnProperty("users")?De.data.users:[De.data]).forEach((function(n){e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,P.ts):(n.state=s.JOINED,e.addMember(new s(n),He),e.updateJoinedMemberCount());var r=new i(n);t.sb.currentUser&&r.userId===t.sb.currentUser.userId&&(e.myMemberState="joined",c.cachedChannels[e.url]=e),Object.keys(t.sb.channelHandlers).forEach((function(n){var i=t.sb.channelHandlers[n];i.onUserJoined(e,r),e.isBroadcast&&l&&i.onChannelMemberCountChanged([e])})),x.upsert([e]).then((function(){V.send({source:be.EVENT_USER_JOINED,payload:{channel:e,user:r}})})).catch((function(e){t.handleCacheError(e)}))}))}else{var u=new i(De.data);t.sb.currentUser&&u.userId===t.sb.currentUser.userId?(e.isPublic||c.removeCachedChannel(De.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)):c.cachedChannels[e.url]=e,e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,P.ts):(e.removeMember(u),e.updateJoinedMemberCount()),Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserLeft(e,u),e.isBroadcast&&l&&r.onChannelMemberCountChanged([e])})),x.upsert([e]).then((function(){V.send({source:be.EVENT_USER_LEFT,payload:{channel:e,user:u}})})).catch((function(e){t.handleCacheError(e)}))}}}));break;case Rt.CATEGORY_CHANNEL_OPERATOR_UPDATE:De.isGroupChannel()?c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{for(var s=De.data.operators.map((function(e){return new i(e)})),a=s.map((function(e){return e.userId})),o=0;o=0?c.Role.OPERATOR:c.Role.NONE;e.myRole=t.sb.currentUser&&a.indexOf(t.sb.currentUser.userId)>=0?c.Role.OPERATOR:c.Role.NONE,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onOperatorUpdated(e,s)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:s}})})).catch((function(e){t.handleCacheError(e)}))}})):De.isOpenChannel()&&d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.operators=De.data.operators.map((function(e){return new i(e)})),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onOperatorUpdated(e,e.operators)})),V.send({source:be.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:operators}}))}));break;case Rt.CATEGORY_CHANNEL_INVITE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var a=null;De.data&&De.data.inviter&&Object.keys(De.data.inviter).length>0&&(a=new i(De.data.inviter));for(var o=[],l=0;l0&&(s=new i(De.data.inviter));var a=new i(De.data.invitee);if(t.sb.currentUser&&a.userId===t.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||c.removeCachedChannel(De.channelUrl)),e.isSuper||e.isBroadcast){var o=De.data.hasOwnProperty("member_count")?De.data.member_count:null,l=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null;e.setLatestMemberCount(o,l,P.ts)}else e.removeMember(a);t.sb.currentUser&&a.userId!==t.sb.currentUser.userId&&(c.cachedChannels[e.url]=e),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserDeclinedInvitation(e,s,a)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_USER_DECLINED_INVITATION,payload:{channel:e,inviter:s,invitee:a}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_TYPING_START:case Rt.CATEGORY_TYPING_END:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var s=new i(De.data);De.category===Rt.CATEGORY_TYPING_START?e.updateTypingStatus(s,!0):e.updateTypingStatus(s,!1),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onTypingStatusUpdated(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_TYPING_STATUS_UPDATED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_CHANNEL_ENTER:case Rt.CATEGORY_CHANNEL_EXIT:d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var s=De.data.hasOwnProperty("participant_count")?De.data.participant_count:null,a=e.setLatestParticipantCount(s,P.ts),o=new i(De.data);De.category===Rt.CATEGORY_CHANNEL_ENTER?(Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserEntered(e,o),a&&r.onChannelParticipantCountChanged([e])})),V.send({source:be.EVENT_CHANNEL_ENTER,payload:{channel:e,user:o}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserExited(e,o),a&&r.onChannelParticipantCountChanged([e])})),V.send({source:be.EVENT_CHANNEL_EXIT,payload:{channel:e,user:o}}))}}));break;case Rt.CATEGORY_USER_CHANNEL_MUTE:case Rt.CATEGORY_USER_CHANNEL_UNMUTE:var Fe=De.category===Rt.CATEGORY_USER_CHANNEL_MUTE,Ge=l({},De.data);Fe&&(Ge.restriction_type=a.RestrictionType.MUTED);var xe=Fe?new a(Ge):new i(De.data),je=Fe?"muted":"unmuted";De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):Fe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,xe)})),V.send({source:be.EVENT_USER_MUTED,payload:{channel:e,user:xe}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,xe)})),V.send({source:be.EVENT_USER_UNMUTED,payload:{channel:e,user:xe}}))})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(t.sb.currentUser&&xe.userId===t.sb.currentUser.userId&&(e.myMutedState=je),Array.isArray(e.members)&&e.members.filter((function(e){return e&&e.userId===xe.userId})).forEach((function(e){e.isMuted=Fe,e.restrictionInfo=new C(Ge)})),Fe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,xe)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_USER_MUTED,payload:{channel:e,user:xe}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,xe)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_USER_UNMUTED,payload:{channel:e,user:xe}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Rt.CATEGORY_USER_CHANNEL_BAN:case Rt.CATEGORY_USER_CHANNEL_UNBAN:var Ve=De.category===Rt.CATEGORY_USER_CHANNEL_BAN,Be=l({},De.data);Ve&&(Be.restriction_type=a.RestrictionType.BANNED);var Ke=Ve?new a(Be):new i(De.data);De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else if(Ve){if(t.sb.currentUser&&Ke.userId===t.sb.currentUser.userId)delete d.enteredChannels[De.channelUrl],t.cls.FileMessageQueue.delete(De.channelUrl);Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,Ke)})),V.send({source:be.EVENT_USER_BANNED,payload:{channel:e,user:Ke}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,Ke)})),V.send({source:be.EVENT_USER_UNBANNED,payload:{channel:e,user:Ke}})})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else if(Ve){if(t.sb.currentUser&&Ke.userId===t.sb.currentUser.userId&&(e.isPublic||c.removeCachedChannel(De.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var i=De.data.hasOwnProperty("member_count")?De.data.member_count:null,s=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null;e.setLatestMemberCount(i,s,P.ts)}else e.removeMember(Ke),e.updateJoinedMemberCount();Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,Ke)})),V.send({source:be.EVENT_USER_BANNED,payload:{channel:e,user:Ke}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,Ke)})),V.send({source:be.EVENT_USER_UNBANNED,payload:{channel:e,user:Ke}})}));break;case Rt.CATEGORY_CHANNEL_FREEZE:case Rt.CATEGORY_CHANNEL_UNFREEZE:De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.isFrozen=De.data.freeze,d.cachedChannels[e.url]=e,De.category===Rt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),V.send({source:be.EVENT_CHANNEL_FROZEN,payload:{channel:e}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),V.send({source:be.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})))})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.isFrozen=De.data.freeze,c.cachedChannels[e.url]=e,De.category===Rt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_FROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Rt.CATEGORY_CHANNEL_DELETED:De.isGroupChannel()?c.removeCachedChannel(De.channelUrl):d.removeCachedChannel(De.channelUrl);var qe=De.channelUrl,ze=De.isGroupChannel()?"group":"open";Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelDeleted(qe,ze)})),x.remove([qe]).then((function(){V.send({source:be.EVENT_CHANNEL_DELETED,payload:{channelUrl:qe,channelType:ze}})})).catch((function(e){t.handleCacheError(e)}));break;case Rt.CATEGORY_CHANNEL_PROP_CHANGED:De.isOpenChannel()?d.getChannelWithoutCache(De.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:e}}))})):c.getChannelWithoutCache(De.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var i=e.unreadMessageCount,s=e.unreadMentionCount;e.myCountPreference!==c.CountPreference.ALL&&(e.myCountPreference===c.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?s=0:e.myCountPreference===c.CountPreference.UNREAD_MENTION_COUNT_ONLY?i=0:(i=0,s=0)),e._setGroupChannelUnreadCount(i,s),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_CHANNEL_META_DATA_CHANGED:case Rt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var Ye=De.data.hasOwnProperty("created"),Qe=De.data.hasOwnProperty("updated"),We=De.data.hasOwnProperty("deleted");(De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL):c.getChannel(De.channelUrl,T.INTERNAL_CALL)).then((function(e){var n=De.data.created,r=De.data.updated,i=De.data.deleted,s=P.ts;Ye&&e._addOrUpdateCachedMetaData(n,s),Qe&&e._addOrUpdateCachedMetaData(r,s),We&&e._markAsDeletedCachedMetaData(i,s),Object.keys(t.sb.channelHandlers).forEach((function(s){var a=t.sb.channelHandlers[s];De.category===Rt.CATEGORY_CHANNEL_META_DATA_CHANGED?(Ye&&a.onMetaDataCreated(e,n),Qe&&a.onMetaDataUpdated(e,r),We&&a.onMetaDataDeleted(e,i),(Ye||Qe)&&V.send({source:be.EVENT_CHANNEL_METADATA_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),We&&V.send({source:be.EVENT_CHANNEL_METADATA_DELETED,payload:{channel:e,metaData:l({},i)}})):(Ye&&a.onMetaCountersCreated(e,n),Qe&&a.onMetaCountersUpdated(e,r),We&&a.onMetaCountersDeleted(e,i),(Ye||Qe)&&V.send({source:be.EVENT_CHANNEL_METACOUNTER_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),We&&V.send({source:be.EVENT_CHANNEL_METACOUNTER_DELETED,payload:{channel:e,metaData:l({},i)}}))}))})).catch((function(e){return J.debug("Discard command:","`".concat(M.command,"`"),De.category)}));break;case Rt.CATEGORY_CHANNEL_HIDE:case Rt.CATEGORY_CHANNEL_UNHIDE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):De.category===Rt.CATEGORY_CHANNEL_HIDE?(e.isHidden=!0,De.data&&(De.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=De.data.allow_auto_unhide?c.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:c.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),De.data.hasOwnProperty("hide_previous_messages")&&De.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),P.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=P.ts_message_offset),c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelHidden(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_HIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){V.send({source:be.EVENT_CHANNEL_UNHIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)})))}))}break;case"USEV":var Je=new Rt(P);switch(Je.category){case Mt.CATEGORY_USER_BLOCK:case Mt.CATEGORY_USER_UNBLOCK:var Xe=Je.data.blocker.user_id,Ze=Je.data.blockee.user_id;Object.keys(c.cachedChannels).forEach((function(e){var n=c.cachedChannels[e];try{t.sb.currentUser&&(t.sb.currentUser.userId===Xe?n.memberMap[Ze].isBlockedByMe=Je.category===Mt.CATEGORY_USER_BLOCK:t.sb.currentUser.userId===Ze&&(n.memberMap[Xe].isBlockingMe=Je.category===Mt.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Mt.CATEGORY_FRIEND_DISCOVERED:var et=Je.data.friend_discoveries.map((function(e){return new i(e)}));Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onFriendsDiscovered(et)}))}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:J.debug("Discard command:","`".concat(M.command,"`"))}}}},{key:"handleCacheError",value:function(e){J.error(e)}}]),e}(),Lt=200,wt={},Dt={},Ht=function(){function e(t){c(this,e),this.channel=t,this.uploadQueue=[],this.messageQueue=[],this.latestTimestampToSendMessage=0,x.get(this._iid).FileMessageQueue.queueMap[t.url]=this}return h(e,[{key:"_handleMessageQueueUpdated",value:function(e){var t=this;switch(J.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 n=x.get(this._iid).FileMessageQueue,r=this.messageQueue[0];if(r)if(r.state===n.State.UPLOADED)if(navigator&&"boolean"==typeof navigator.onLine)if(navigator.onLine){for(r.state=n.State.SENDING,0===this.latestTimestampToSendMessage&&(this.latestTimestampToSendMessage=(new Date).getTime()-Lt);(new Date).getTime()-this.latestTimestampToSendMessage-1&&(t.state=r.State.SENT,this._handleMessageQueueUpdated("update")),this._finalizeUpload(t.requestId);else navigator&&"boolean"==typeof navigator.onLine?navigator.onLine?this._uploadFile(t,(function(e){t.error&&t.state===r.State.SENT||(t.state=r.State.UPLOADED),t.fileInfo=e,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId)})):(t.state=r.State.SENT,t.error=new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),t.response=null,this._handleMessageQueueUpdated("update"),this._finalizeUpload(t.requestId)):qe.ready().then((function(e){e?n._uploadFile(t,(function(e){t.error&&t.state===r.State.SENT||(t.state=r.State.UPLOADED),t.fileInfo=e,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId)})):(t.state=r.State.SENT,t.error=new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),t.response=null,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId))}));break;case"update":break;case"remove":this.uploadQueue.length<6&&this._moveFirstPendingMessageToUploadQueue()}}},{key:"_moveFirstPendingMessageToUploadQueue",value:function(){var e=x.get(this._iid).FileMessageQueue,t=this.messageQueue.filter((function(t){return t.state===e.State.PENDING}));if(t.length>0){var n=t[0];this.uploadQueue.push(n),this._handleUploadQueueUpdated("add",n)}}},{key:"_sendUploadedMessage",value:function(e,t){var n=x.get(this._iid),r=n.Command,i=n.FileMessage,s=e.fileInfo,a=r.bFile(l(l({},s),{},{requestId:e.requestId,channelUrl:this.channel.url,url:s.file,metaArrays:s.metaArrays})),o=Ri.getInstance(this._iid),u=U.get(this._iid);o.getConnectionState()===o.ConnectionState.OPEN||!o.currentUser||o.connecting||o.reconnecting?o.sendCommand(a,(function(e,n){if(o.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n){var l=new i(a.getJsonElement());l.requestedMentionUserIds=s.mentionedUserIds,t(n,l)}else{var u=new i(e.getJsonElement());t(null,u)}})):u.container.apiClient.sendFileMessage(l(l({reqId:e.requestId,channelUrl:this.channel.url,isOpenChannel:this.channel.isOpenChannel()},s),{},{fileUrl:s.file,fileName:s.name,fileSize:s.size,fileType:s.type,metaArrays:s.metaArrays}),(function(e,n){var r=new i(e?a.getJsonElement():n);e&&(r.requestedMentionUserIds=s.mentionedUserIds),t(e,r)}))}},{key:"_uploadFile",value:function(e,t){var n=e.fileInfo,r=e.pendingMessage;if("string"!=typeof n.file&&n.file){var i=x.get(this._iid).FileMessageQueue;U.get(this._iid).container.apiClient.uploadFile(l(l({},n),{},{fileType:n.type,channelUrl:this.channel.url,reqId:r?r.reqId:null}),(function(r,s){if(r)e.state=i.State.SENT,e.error=r,e.response=null,t(n);else{var a="object"===u(s)?s:JSON.parse(s);n.file=a.url,n.thumbnailSizes=a.hasOwnProperty("thumbnails")?a.thumbnails:[],n.requireAuth=!!a.hasOwnProperty("require_auth")&&a.require_auth,n.size=a.hasOwnProperty("file_size")?a.file_size:n.size,t(n)}}))}else n.thumbnailSizes=[],n.requireAuth=!1,t(n)}},{key:"_finalizeUpload",value:function(e){var t=this.uploadQueue.map((function(e){return e.requestId})).indexOf(e);if(t>-1){var n=this.uploadQueue.splice(t,1);n.length>0&&this._handleUploadQueueUpdated("remove",n[0])}}},{key:"_finalizeMessage",value:function(){var e=this,t=U.get(this._iid),n=t.container.localCacheEnabled,r=t.container.isErrorFirstInCallback,i=Ri.getInstance(this._iid),s=Et.of(this._iid),a=Ae.of(this._iid),o=Ie.of(this._iid),l=x.get(this._iid).FileMessageQueue,u=this.messageQueue[0],c=u.pendingMessage;if(u&&u.state===l.State.SENT){u.state=l.State.DONE;var d=u.response;d&&c&&(d._isAutoResendRegistered=c._isAutoResendRegistered);var h=u.error,p=h?new H(h.message,h.code):null,f=u.fileInfo.callback;if(d&&!h){d.reqId=c.reqId,d.requestState=i.MessageRequestState.SUCCEEDED,d.sendingStatus=i.MessageSendingStatus.SUCCEEDED;var _=i.currentUser;if(_&&d._sender&&_.userId===d._sender.userId&&(_.nickname!==d._sender.nickname&&(_.nickname=d._sender.nickname),_.plainProfileUrl!==d._sender.plainProfileUrl&&(_.plainProfileUrl=d._sender.plainProfileUrl)),this.channel.isGroupChannel())return this.channel.lastMessage=d,Object.keys(i.channelHandlers).forEach((function(t){i.channelHandlers[t].onChannelChanged(e.channel)})),void s.upsert([this.channel]).then((function(){o.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:e.channel}})})).then((function(){return a.removeUnsentMessages({channelUrl:e.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]})})).then((function(){return a.upsert([d],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:be.EVENT_MESSAGE_SENT,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(null,d):f(d,null)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}if(h){if(d&&d._isAutoResendRegistered&&ie.isAutoResendableError(h.code))return this.messageQueue.shift(),void this._handleMessageQueueUpdated("remove");if(u.pendingMessage&&(d=u.pendingMessage._clone()),d&&h.code!==H.INVALID_PARAMETER)if(d.requestState=i.MessageRequestState.FAILED,h.code===H.FILE_UPLOAD_CANCEL_FAILED||h.code===H.REQUEST_CANCELED){if(d.sendingStatus=i.MessageSendingStatus.CANCELED,this.channel.isGroupChannel())return void a.removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]}).then((function(){o.send({source:be.LOCAL_MESSAGE_CANCELED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}else if(d.sendingStatus=i.MessageSendingStatus.FAILED,d.errorCode=h.code,d.requestedMentionUserIds=u.fileInfo.mentionedUserIds,h.code===H.FILE_SIZE_LIMIT_EXCEEDED&&d._messageParams&&d._messageParams.file&&(d._messageParams.file=null),this.channel.isGroupChannel())return void(h.code===H.USER_NOT_MEMBER||h.code===H.CHANNEL_NOT_FOUND?s.remove([this.channel.url]).then((function(){return a.removeUnsentMessages({channelUrl:e.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]})})).then((function(){o.send({source:be.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")})):(n&&ie.isAutoResendableError(h.code)&&(d.sendingStatus=i.MessageSendingStatus.PENDING,d.errorCode=0,d._isAutoResendRegistered=!0),a.upsert([d],de.UNSENT).then((function(){Xe._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:be.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){var t=d._clone();t.sendingStatus=i.MessageSendingStatus.FAILED,t.errorCode=h.code,t._isAutoResendRegistered=!1,f&&(r?f(p,t):f(t,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))))}f&&(r?f(p,d):f(d,p)),this.messageQueue.shift(),this._handleMessageQueueUpdated("remove")}}},{key:"addJob",value:function(e){this.messageQueue.push(e),this._handleMessageQueueUpdated("add")}},{key:"cancelUploadItemByRequestId",value:function(e,t){this._finalizeUpload(e);var n=this.messageQueue.map((function(e){return e.requestId})).indexOf(e);if(n>-1){var r=x.get(this._iid).FileMessageQueue,i=this.messageQueue[n];!i||i.state!==r.State.UPLOADING&&i.state!==r.State.PENDING||(i.state=r.State.SENT,i.response=null,i.error=new H("Uploading has been completed or canceled.",H.FILE_UPLOAD_CANCEL_FAILED),this._handleMessageQueueUpdated("update"));var s=r.uploadRequest[e];if(s)return"function"==typeof s.abort?s.abort():"function"==typeof s.cancel&&s.cancel("Upload has been canceled."),t(null,!0),!0;t(new H("Uploading has been completed or canceled.",H.FILE_UPLOAD_CANCEL_FAILED),!1)}else t(new H("Uploading has been completed or canceled.",H.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 x.get(this._iid).FileMessageQueue.queueMap[e]}},{key:"create",value:function(e){var t=x.get(this._iid).FileMessageQueue;return t.queueMap.hasOwnProperty(e.url)||(t.queueMap[e.url]=new t(e)),t.queueMap[e.url]}},{key:"delete",value:function(e){var t=x.get(this._iid).FileMessageQueue;t.queueMap.hasOwnProperty(e)&&delete t.queueMap[e]}},{key:"clear",value:function(){Dt[this._iid]={}}},{key:"queueMap",get:function(){return Dt[this._iid]||(Dt[this._iid]={}),Dt[this._iid]}},{key:"uploadRequest",get:function(){return wt[this._iid]||(wt[this._iid]={}),wt[this._iid]}}]),e}();Ht.Job=function(){return function e(t){var n=t.fileInfo,r=t.requestId,i=t.pendingMessage,s=t.state,a=t.error,o=void 0===a?null:a,l=t.response,u=void 0===l?null:l;c(this,e),this.fileInfo=n,this.requestId=r,this.pendingMessage=i,this.state=s||Ht.State.PENDING,this.error=o,this.response=u}}();var Ft,Gt={},xt=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,l=e.blockHashMultiplier,u=void 0===l?10:l,c=e.blockHashConstant,d=void 0===c?11:c,h=e.transactionApplyDelay,p=void 0===h?200:h;return Gt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=d,this.transactionApplyDelay=p,Gt[t]=this),Gt[t]}return e.get=function(e){return Gt[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ft||(Ft={}));var jt,Vt=function(e){function t(t){var n=t.code,r=void 0===n?Ft.UNKNOWN_ERROR:n,i=t.message,s=void 0===i?"Unknown error occurred.":i,a=e.call(this,s)||this;return a.code=r,a}return R(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Ft.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Ft.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Ft.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Ft.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ft.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Ft.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Ft.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Ft.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Ft.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ft.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ft.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Ft.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Ft.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Ft.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Ft.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ft.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Ft.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ft.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Ft.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Ft.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(jt||(jt={}));var Bt,Kt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Vt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return Kt(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=Kt(e[r],t);return t.delete(e),n}return e},qt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Vt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},zt=function(e,t){for(var n=0,r=0;r>>0)%t},Yt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Qt=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Qt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Qt(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(qt(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(qt(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(qt(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(qt(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Wt=function(){},Jt=function(){return Promise.resolve()},Xt=function(e){return e},Zt=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Bt||(Bt={}));var $t,en,tn,nn=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Xt:a,l=e.backward,u=void 0===l?Jt:l,c=e.forward,d=void 0===c?Jt:c,h=e.complete,p=void 0===h?Wt:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,this._forward=d,this._iterator=s,this._complete=p}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return P(this,void 0,void 0,(function(){var e,t,n;return L(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return P(this,void 0,void 0,(function(){var e,t,n;return L(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),rn=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var l in this.condition[s])if(o.includes(l))for(var u=r;u>=0;u--)if(a*qt(this._indexer.origin[u].columnValues[i],this.condition[s][l])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*qt(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=c;o=0){c=o;break}}));else for(var a=c;a=0){c=a;break}},h=this,i=0;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],a=0;a0))return[3,6];a=0,u.label=1;case 1:return a0))return[3,2];for(i=0;i-1){var r=this._items[n];return t===tn.PERSISTENT&&(r.state=en.PERSISTENT),t!==tn.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)pn.includes(this._items[t].state)&&pn.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].generation=e.generation,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===en.VOLATILE})).length-this._limit;if(n>0){for(var r=[],i=0,s=this._items;i0?n--:r.push(a)}this._items=r}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==en.VOLATILE}))},e}(),yn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(on(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(on(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,e),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],l=o.data;n[l.key]||(s.unshift(o),n[l.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c;return L(this,(function(d){switch(d.label){case 0:n=_n.get(this.dbname),r=t.generation,i=t.requests,s=null,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return M(M({},e.data),{generation:r})})))];case 2:for(a=d.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],u=r.data,n[u.key]||(n[u.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(p.sent(),a=_n.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=gn.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return n=xt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,_n.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(a=s?gn.createFromCacheItem(s):new gn({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return e=un(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=o.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:for(o.sent(),r=_n.get(this.dbname),i=0,s=n;i")),this._transaction=a,this._store=o,this._transaction.on($t.COMMIT,this.indexerKey,(function(){return t.commit()})),this._transaction.on($t.ERROR,this.indexerKey,(function(){return t.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=this.indexOf(n),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=this.indexOf(n),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){for(var t,n,r=[],i=0,s=this.fields;i0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d;return L(this,(function(h){switch(h.label){case 0:return[4,(e=_n.get(this.dbname)).find(this._store,this.indexerKey,tn.PERSISTENT)];case 1:return(t=h.sent())?[3,7]:(n=un(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),i=0,s=r,h.label=3;case 3:return i0?this._resolvers.shift()():this._locked=!1)},e}(),Cn=function(){function e(e){var t=this,n=e.dbname,r=e.collectionName,i=e.keyName,s=e.keyHash,a=e.indexes,o=e.store;this._state=jt.INIT,this._metadata=null,this._indexers=[],this.dbname=n,this.name=r,this.keyName=i,this.indexes=w([[i]],a.filter((function(e){return En.createKey(e)!==t.keyName})),!0),this._keyHash=s,this._store=o,this._mutex=new vn(function(e,t){return"".concat(on(e,t),".lock")}(n,r)),this._blobContainer=new hn({dbname:n,collectionName:r,store:o}),this._transaction=new yn({dbname:n,collectionName:r,store:o})}return e.metadataOf=function(e,t,n){return P(this,void 0,void 0,(function(){var r;return L(this,(function(i){switch(i.label){case 0:return r=ln(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.init=function(){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p=this;return L(this,(function(f){switch(f.label){case 0:return[4,this._mutex.lock()];case 1:f.sent(),f.label=2;case 2:return f.trys.push([2,9,,10]),t=xt.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=f.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:for(f.sent(),this._blockManager=new mn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=w([],this.indexes,!0),i=[],s=r.map((function(e){return En.createKey(e)})),a=n?n.indexes.map((function(e){return En.createKey(e)})):[],o=0,l=a;o0&&!r.some((function(t){switch(t){case wn.CHANNEL_NAME:return e.name.toLowerCase().includes(n.toLowerCase());case wn.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(n.toLowerCase())}));default:return!0}})))return!1;var i=this._userIdsFilter,s=i.includeMode,a=i.queryType,o=i.userIds,l=U.get(this._iid).get("currentUserId"),u=e.members.map((function(e){return e.userId}));if(s){if(o.length>0)switch(a){case Ln.AND:if(o.some((function(e){return!u.includes(e)})))return!1;break;case Ln.OR:if(o.every((function(e){return!u.includes(e)})))return!1}}else{if(o.includes(l)||o.push(l),e.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=w([],e,!0).sort(),r=w([],t,!0).sort(),i=0;i0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var c=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(c)})))return!1}if(this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){case Dn.JOINED:if("joined"!==e.myMemberState)return!1;break;case Dn.INVITED:if("invited"!==e.myMemberState)return!1;break;case Dn.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Dn.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case xn.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case xn.HIDDEN:if(!e.isHidden)return!1;break;case xn.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case xn.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter)switch(this.unreadChannelFilter){case Gn.UNREAD_MESSAGE:if(0===e.unreadMessageCount)return!1}if(this.publicChannelFilter)switch(this.publicChannelFilter){case Fn.PUBLIC:if(!e.isPublic)return!1;break;case Fn.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Hn.SUPER:if(!e.isSuper)return!1;break;case Hn.NON_SUPER:if(e.isSuper)return!1}return!0},e.QueryType=Ln,e.SearchField=wn,e}(),Kn=function(){function e(e){var t=e.iid;this._iid=t,this._filter=new Bn,this._filter.iid=this._iid,this._order=ze.LATEST_LAST_MESSAGE,this._limit=20}return e.prototype.setFilter=function(e){return this._filter=e.clone(),this._filter.iid=this._iid,this},e.prototype.setOrder=function(e){return this._order=e,this},e.prototype.setLimit=function(e){return this._limit=e,this},e.prototype.build=function(){return new gt({iid:this._iid,filter:this._filter,order:this._order,limit:this._limit})},e}(),qn=function(){function e(e){var t=e.iid,n=e.channel;this._iid=t,this._channel=n,this._startingPoint=Date.now(),this._filter=new He,this._limit=100}return e.prototype.setFilter=function(e){return this._filter=e.clone(),this},e.prototype.setStartingPoint=function(e){return this._startingPoint=e,this},e.prototype.setLimit=function(e){return this._limit=e,this},e.prototype.build=function(){return new Xe({iid:this._iid,channel:this._channel,startingPoint:this._startingPoint,filter:this._filter,limit:this._limit})},e}(),zn={},Yn={},Qn=new WeakMap,Wn=new WeakMap,Jn=new WeakMap,Xn=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=kt.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=n.PushTriggerOption.DEFAULT,r.isPushEnabled,r.isHidden=!1,r.hiddenState=n.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},Qn.set(g(r),{}),Wn.set(g(r),{start:0,end:0}),Jn.set(g(r),0),e&&r._update(e),r}return h(n,[{key:"messageOffsetTimestamp",get:function(){return this._messageOffsetTimestamp}},{key:"createMessageCollection",value:function(){return new qn({iid:this._iid,channel:this})}},{key:"_setGroupChannelUnreadCount",value:function(e,t){try{if("number"==typeof e&&e>=0)if("all"===this.myCountPreference||"unread_message_count_only"===this.myCountPreference)if(this.isSuper||this.isBroadcast){var n=U.get(this._iid).container.maxUnreadCountOfSuperGroupChannel;this.unreadMessageCount=e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&("all"===this.myCountPreference||"unread_mention_count_only"===this.myCountPreference?this.unreadMentionCount=t:this.unreadMentionCount=0)}catch(e){}}},{key:"_update",value:function(e){var t=this,n=x.get(this._iid),r=n.BaseChannel,i=n.GroupChannel,s=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:i.PushTriggerOption.DEFAULT,this.myCountPreference=e.hasOwnProperty("count_preference")?e.count_preference:i.CountPreference.ALL,this.unreadMessageCount=0,this.unreadMentionCount=0,this._setGroupChannelUnreadCount(parseInt(e.unread_message_count),parseInt(e.unread_mention_count)),e.hasOwnProperty("read_receipt")&&(this.cachedReadReceiptStatus={},Object.keys(e.read_receipt).forEach((function(n){var r=e.read_receipt[n];t.updateReadReceipt(n,parseInt(r))}))),e.hasOwnProperty("delivery_receipt")&&"object"===u(e.delivery_receipt)&&null!==e.delivery_receipt&&(this.cachedDeliveryReceiptStatus||(this.cachedDeliveryReceiptStatus={}),Object.keys(e.delivery_receipt).forEach((function(n){var r=e.delivery_receipt[n];t.updateDeliveryReceipt(n,parseInt(r))}))),e.hasOwnProperty("user_last_read")&&"number"==typeof e.user_last_read?this.myLastRead=e.user_last_read:this.myLastRead=0,e.hasOwnProperty("members")){this.members=[],this.memberMap={};for(var o=0;o0?this.inviter=new s(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=i.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 t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isSuper&&!this.isBroadcast){var n=x.get(this._iid),r=n.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,t),this.updateDeliveryReceipt(e.userId,t)}}},{key:"removeMember",value:function(e){var t=null;if(!this.isSuper&&!this.isBroadcast&&this.memberMap.hasOwnProperty(e.userId)){delete this.memberMap[e.userId];for(var n=0;n0&&e.every((function(e){return!!e.userId&&"string"==typeof e.userId}))}}),new tt({type:"callback"})]),i=b(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){return e(tt.error,null)}),t):this.inviteWithUserIds(e.map((function(e){return e.userId})),t)}},{key:"inviteWithUserIds",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.inviteToGroupChannel({channelUrl:n.url,userIds:e},(function(e,r){var i=null;e||(i=x.get(n._iid).GroupChannel.upsert(r));t(e,i)}))}),t)}},{key:"acceptInvitation",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.acceptInvitation({channelUrl:n.url,accessCode:e},(function(e,r){var i=null;e||((i=x.get(n._iid).GroupChannel.upsert(r)).myMemberState="joined");t(e,i)}))}),t)}},{key:"declineInvitation",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.declineInvitation({channelUrl:t.url},(function(n,r){var i=null;if(!n){var s=x.get(t._iid).GroupChannel;(i=s.upsert(r)).myMemberState="none",t.isPublic||s.removeCachedChannel(t.url)}e(n,i)}))}),e)}},{key:"join",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.joinGroupChannel({channelUrl:n.url,accessCode:e},(function(e,r){var i=null;e||((i=x.get(n._iid).GroupChannel.upsert(r)).myMemberState="joined");t(e,i)}))}),t)}},{key:"leave",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.leaveGroupChannel({channelUrl:t.url},(function(t,n){return e(t,null)}))}),e)}},{key:"muteUser",value:function(e,t,n,r){return this.muteUserWithUserId(e?e.userId:null,t,n,r)}},{key:"muteUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string",optional:!0,defaultValue:""}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!0},(function(e,t){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,t){return this.unmuteUserWithUserId(e?e.userId:null,t)}},{key:"unmuteUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unmuteUser({channelUrl:n.url,userId:e,isGroupChannel:!0},(function(e,n){t(e,null)}))}),t)}},{key:"banUser",value:function(e,t,n,r){return this.banUserWithUserId(e?e.userId:null,t,n,r)}},{key:"banUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string"}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.banUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!0},(function(e,t){r(e,null)}))}),r)}},{key:"unbanUser",value:function(e,t){return this.unbanUserWithUserId(e?e.userId:null,t)}},{key:"unbanUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unbanUser({channelUrl:n.url,userId:e,isGroupChannel:!0},(function(e,n){t(e,null)}))}),t)}},{key:"updateJoinedMemberCount",value:function(){if(!this.isSuper&&!this.isBroadcast){var e=x.get(this._iid).Member;this.joinedMemberCount=this.members.filter((function(t){return t.state===e.JOINED})).length}}},{key:"setLatestMemberCount",value:function(e,t,n){var r=!1;return"number"==typeof e&&"number"==typeof t&&"number"==typeof n&&n>=Jn.get(this)&&(Jn.set(this,n),r=t!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"hide",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!0}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.hideGroupChannel({channelUrl:r.url,hidePreviousMessages:e,allowAutoUnhide:t},(function(i,s){if(!i){var a=x.get(r._iid).GroupChannel;r.isHidden=!0,r.hiddenState=t?a.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:a.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,e&&r._setGroupChannelUnreadCount(0,0),s.hasOwnProperty("ts_message_offset")&&(r._messageOffsetTimestamp=s.ts_message_offset),a.cachedChannels[r.url]=r}n(i,s)}))}),n)}},{key:"unhide",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unhideGroupChannel({channelUrl:t.url},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isHidden=!1,t.hiddenState=i.HiddenState.UNHIDDEN,i.cachedChannels[t.url]=t}e(n,r)}))}),e)}},{key:"freeze",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.freeze({channelUrl:t.url,isGroupChannel:!0,freezing:!0},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isFrozen=!0,i.cachedChannels[t.url]=t}e(n,null)}))}),e)}},{key:"unfreeze",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.freeze({channelUrl:t.url,isGroupChannel:!0,freezing:!1},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isFrozen=!1,i.cachedChannels[t.url]=t}e(n,null)}))}),e)}},{key:"delete",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteGroupChannel({channelUrl:t.url},(function(n,r){n||x.get(t._iid).GroupChannel.removeCachedChannel(t.url);e(n,r)}))}),e)}},{key:"markAsRead",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).Command,r=Ri.getInstance(t._iid),i=n.bRead({channelUrl:t.url});r.sendCommand(i,(function(n,i){if(r.getErrorFirstCallback()){var s=[n,i];i=s[0],n=s[1]}if(i)e(i,null);else if(r.currentUser){var a=Et.of(t._iid),o=Ie.of(t._iid);t.updateReadReceipt(r.currentUser.userId,n.getJsonElement().ts);var l=!1;(t.unreadMessageCount>0||t.unreadMentionCount>0)&&(t._setGroupChannelUnreadCount(0,0),Object.keys(r.channelHandlers).forEach((function(e){r.channelHandlers[e].onChannelChanged(t)})),l=!0),e(null,null),a.upsert([t]).then((function(){l&&o.send({source:be.EVENT_CHANNEL_CHANGED,payload:{channel:t}}),o.send({source:be.EVENT_READ_RECEIPT_UPDATED,payload:{channel:t}})})).catch((function(e){J.error(e)}))}else{var u=new SendBirdException("Connection should be made first.",SendBirdException.CONNECTION_REQUIRED);e(u,null)}}))}),e)}},{key:"getUnreadMemberCount",value:function(e){var t=U.get(this._iid),n=x.get(this._iid).Member,r=t.container.currentUserId;if(e instanceof St&&!e.isAdminMessage()&&r&&!this.isSuper&&!this.isBroadcast){for(var i=0,s=e.createdAt,a=this.members,o=0;o1&&void 0!==arguments[1]&&arguments[1],n=Ri.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof St&&!e.isAdminMessage()){for(var r=[],i=0;i=e.createdAt&&r.push(s)}}return r}return[]}},{key:"getUnreadMembers",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Ri.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof St&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],n=Ri.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast){for(var r={},i=Object.keys(this.cachedReadReceiptStatus),s=function(s){var a=i[s];if(!t&&a===n.currentUser.userId)return"continue";var o=e.cachedReadReceiptStatus[a],l=e.members.filter((function(e){return e.userId===a}));r[a]={user:l.length>0?l[0]:null,last_seen_at:parseInt(o)}},a=0;a9e3)&&(n=1e3);var r=Wn.get(this);if(t-r.start>=n){r.end=0,r.start=t;var i=x.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=Ri.getInstance(this._iid),t=(new Date).getTime(),n=e.Options.typingIndicatorThrottle;("number"!=typeof n||n<1e3||n>9e3)&&(n=1e3);var r=Wn.get(this);if(t-r.end>=n){r.start=0,r.end=t;var i=x.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=Qn.get(this),t=(new Date).getTime(),n=!1;return Object.keys(e).forEach((function(r){var i=e[r].ts;t-i>=1e4&&(delete e[r],n=!0)})),n}},{key:"getTypingMembers",value:function(){var e=this,t=Qn.get(this),n=[];return Object.keys(t).forEach((function(t){var r=e.memberMap[t];r&&n.push(r)})),n}},{key:"getTypingUsers",value:function(){var e=Qn.get(this),t=[];return Object.keys(e).forEach((function(n){var r=e[n].user;t.push(r)})),t}},{key:"updateTypingStatus",value:function(e,t){var n=Qn.get(this);t?n[e.userId]={user:e,ts:(new Date).getTime()}:delete n[e.userId]}},{key:"isTyping",value:function(){var e=Qn.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.ScheduledUserMessage,s=r.ScheduledUserMessageParams,a=null,o=tt.parse(arguments,[new tt({type:s,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new tt({type:"callback"})]),l=b(o,3);return a=l[0],e=l[1],t=l[2],oe(this._iid,(function(t){a?t(a,null):U.get(n._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:n.url,isOpenChannel:!1},(function(e,r){var s=null;if(!e){s=new i(r);var a=Ri.getInstance(n._iid).currentUser;a&&s._sender&&a.userId===s._sender.userId&&(a.nickname=s._sender.nickname,a.plainProfileUrl=s._sender.plainProfileUrl,a.metaData=s._sender.metaData)}t(e,s)}))}),t)}},{key:"getPushPreference",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMyPushTriggerOption({channelUrl:t.url},(function(n,r){var i=null;if(!n){try{i=r.enable}catch(e){i=!1}t.isPushEnabled=i}e&&e(n,i)}))}),e)}},{key:"setPushPreference",value:function(e,t){var n=this;return oe(this._iid,(function(t){var r=x.get(n._iid).GroupChannel;U.get(n._iid).container.apiClient.setMyPushTriggerOption({channelUrl:n.url,enable:e},(function(e,i){e||(n.isPushEnabled=i.enable,n.isPushEnabled||(n.myPushTriggerOption=r.PushTriggerOption.OFF)),t(e,i)}))}),t)}},{key:"getMyPushTriggerOption",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMyPushTriggerOption({channelUrl:t.url},(function(r,i){var s=null;if(!r){try{s=i.push_trigger_option||n.PushTriggerOption.DEFAULT}catch(e){J.debug(e)}t.myPushTriggerOption=s}e(r,s)}))}),e)}},{key:"setMyPushTriggerOption",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.PushTriggerOption}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.setMyPushTriggerOption({channelUrl:n.url,pushTriggerOption:e},(function(e,r){var i=null;if(!e){try{i=r.push_trigger_option}catch(e){J.debug(e)}n.myPushTriggerOption=i}t(e,i)}))}),t)}},{key:"setMyCountPreference",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.CountPreference}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.setMyCountPreference({channelUrl:n.url,countPreference:e},(function(e,r){var s=null;e||(s=n.myCountPreference=r.count_preference,n._setGroupChannelUnreadCount(n.unreadMessageCount,n.unreadMentionCount),i.cachedChannels[n.url]=n),t(e,s)}))}),t)}},{key:"resetMyHistory",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.resetMyHistory({channelUrl:t.url},(function(n,r){if(!n&&r.hasOwnProperty("ts_message_offset")){var i=x.get(t._iid).GroupChannel;t._messageOffsetTimestamp=r.ts_message_offset,i.cachedChannels[t.url]=t}e(n,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",BROADCAST_ONLY:"broadcast_only"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return zn[this._iid]||(zn[this._iid]={}),zn[this._iid]}},{key:"createGroupChannelCollection",value:function(){return new Kn({iid:this._iid})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.Member,i=t.GroupChannel,s=t.BaseMessage,a=t.UserMessage,o=t.FileMessage,c=t.AdminMessage,d=bt.deserialize(e),h=function(e){return null!=e&&"object"===u(e)?e.messageType===s.MESSAGE_TYPE_USER?new a(a.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):e.messageType===s.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({},e))})),last_message:h,created_by:null!==d.creator&&void 0!==d.creator&&"object"===u(d.creator)?n.objectify(d.creator):null,inviter:null!==d.inviter&&void 0!==d.inviter&&"object"===u(d.inviter)?n.objectify(d.inviter):null,cached_primary_key:d.cachedPrimaryKey})}},{key:"upsert",value:function(e){var t=x.get(this._iid).GroupChannel,n=new t(e);if(t.cachedChannels.hasOwnProperty(n.url)){if(n.isEphemeral){var r=t.cachedChannels[n.url];e.last_message=r.lastMessage,e.unread_message_count=r.unreadMessageCount}t.cachedChannels[n.url].update(e)}else t.cachedChannels[n.url]=n;return t.cachedChannels[n.url]}},{key:"removeCachedChannel",value:function(e){var t=x.get(this._iid),n=t.GroupChannel,r=t.FileMessageQueue;n.cachedChannels[e]&&delete n.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){zn[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),s=b(i,4);if(n=s[0],e=s[1],r=s[2],t=s[3],n)return oe(this._iid,(function(e){e(n,null)}),t);var a=x.get(this._iid),o=a.GroupChannel;return o.cachedChannels[e]?oe(this._iid,(function(t){t(null,o.cachedChannels[e])}),t):o.getChannelWithoutCache(e,r,t)}},{key:"getChannelWithoutCache",value:function(e,t){var n=this,r=null,i=null,s=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),a=b(s,4);return r=a[0],e=a[1],i=a[2],t=a[3],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},(function(e,r){var i=null;e||(i=n.upsert(r)),t(e,i)}))}),t)}},{key:"createDistinctChannelIfNotExist",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannelParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):(e.isPublic||(e.accessCode=null),U.get(n._iid).container.apiClient.createGroupChannel(l(l({},e),{},{isDistinct:!0}),(function(e,r){var i=null;if(!e){var s=x.get(n._iid).GroupChannel;i={channel:new s(r),isCreated:r.is_created},s.cachedChannels[i.channel.url]=i.channel}t(e,i)})))}),t)}},{key:"createChannel",value:function(){var e=this,t=tt.toArray(arguments),n=void 0;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];(r.isPublic||(r.accessCode=null),r._validate())?U.get(e._iid).container.apiClient.createGroupChannel(r,(function(e,t){var r=null;e||(r=new i(t),i.cachedChannels[r.url]=r),n(e,r)})):n(tt.error,null)}),n);if(Array.isArray(t[0])){var a=new s;switch(t.length){case 1:a.addUsers(t[0]);break;case 2:a.addUsers(t[0]),a.isDistinct=t[1];break;case 3:a.addUsers(t[0]),a.isDistinct=t[1],a.customType=t[2];break;case 5:a.addUsers(t[0]),a.isDistinct=t[1],a.name=t[2],"string"==typeof t[3]?a.coverUrl=t[3]:a.coverImage=t[3],a.data=t[4];break;case 6:a.addUsers(t[0]),a.isDistinct=t[1],a.name=t[2],"string"==typeof t[3]?a.coverUrl=t[3]:a.coverImage=t[3],a.data=t[4],a.customType=t[5];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}return oe(this._iid,(function(e){return e(tt.error,null)}),n)}},{key:"createChannelWithUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;"function"==typeof e[e.length-1]&&(t=e.pop());var n=x.get(this._iid),r=n.GroupChannel,i=n.GroupChannelParams,s=new i;switch(e.length){case 1:s.addUserIds(e[0]);break;case 2:s.addUserIds(e[0]),s.isDistinct=e[1];break;case 3:s.addUserIds(e[0]),s.isDistinct=e[1],s.customType=e[2];break;case 5:s.addUserIds(e[0]),s.isDistinct=e[1],s.name=e[2],"string"==typeof e[3]?s.coverUrl=e[3]:s.coverImage=e[3],s.data=e[4];break;case 6:s.addUserIds(e[0]),s.isDistinct=e[1],s.name=e[2],"string"==typeof e[3]?s.coverUrl=e[3]:s.coverImage=e[3],s.data=e[4],s.customType=e[5];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}return r.createChannel(s,t)}},{key:"createMyGroupChannelListQuery",value:function(){return new(0,x.get(this._iid).GroupChannelListQuery)}},{key:"createPublicGroupChannelListQuery",value:function(){return new(0,x.get(this._iid).PublicGroupChannelListQuery)}},{key:"markAsReadAllLastSentAt",get:function(){return Yn[this._iid]||0},set:function(e){Yn[this._iid]=e}},{key:"getChannelCount",value:function(e,t){return Ri.getInstance(this._iid).getGroupChannelCount(e,t)}},{key:"getUnreadItemCount",value:function(e,t){return Ri.getInstance(this._iid).getUnreadItemCount(e,t)}},{key:"getTotalUnreadMessageCount",value:function(){var e=tt.toArray(arguments),t="function"==typeof e[e.length-1]?e.pop():null,n=Ri.getInstance(this._iid);return n.getTotalUnreadMessageCount.apply(n,A(e).concat([t]))}},{key:"getTotalUnreadChannelCount",value:function(e){return Ri.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),n}(kt),Zn=function(e){function t(t){var n=e.call(this,t)||this;return n.state="",n.role="",n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.restrictionInfo=null,t&&n._update(t),n}return R(t,e),t.objectify=function(e){var t=x.get(this._iid),n=t.User,r=t.RestrictedUser,i=t.RestrictionInfo,s=e.state,a=e.role,o=void 0===a?"":a,l=e.isMuted,u=void 0!==l&&l,c=e.isBlockedByMe,d=void 0!==c&&c,h=e.isBlockingMe,p=void 0!==h&&h,f=e.restrictionInfo,_=void 0===f?null:f,y=u?r.objectify(e):n.objectify(e);if(y.state=s,y.role=o,y.is_muted=u,y.is_blocked_by_me=d,y.is_blocking_me=p,_){var g=i.objectify(_);y.restriction_type=g.restriction_type,y.muted_description=g.description,y.muted_end_at=g.end_at}return y},t.buildFromSerializedData=function(e){var t=x.get(this._iid).Member,n=bt.deserialize(e);return new t(t.objectify(M({},n)))},t.prototype._update=function(e){var t=x.get(this._iid),n=t.RestrictedUser,r=t.RestrictionInfo;this.state=e.state,this.role=e.role||Xn.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me),this.isMuted&&(this.restrictionInfo=new r(e),this.restrictionInfo.restrictionType=n.RestrictionType.MUTED)},t.prototype.parse=function(e){this._update(e)},Object.defineProperty(t,"JOINED",{get:function(){return"joined"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"INVITED",{get:function(){return"invited"},enumerable:!1,configurable:!0}),t}(It),$n=function(e){function t(t){var n=e.call(this,t)||this;return n.role="",n.isBlockedByMe=!1,t&&n._update(t),n}return R(t,e),t.objectify=function(e){var t=x.get(this._iid).User,n=e.role,r=void 0===n?"":n,i=e.isBlockedByMe,s=void 0!==i&&i,a=t.objectify(e);return a.role=r,a.is_blocked_by_me=s,a},t.buildFromSerializedData=function(e){var t=x.get(this._iid).Sender,n=bt.deserialize(e);return new t(t.objectify(M({},n)))},t.prototype.parse=function(e){this._update(e)},t.prototype._update=function(e){this.role=e.role||Xn.Role.NONE,e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)},t}(It),er=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).restrictionInfo=null,e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=x.get(this._iid).RestrictionInfo;this.restrictionInfo=new t(e)}}],[{key:"RestrictionType",get:function(){return{MUTED:"muted",BANNED:"banned"}}},{key:"objectify",value:function(e){var t=x.get(this._iid),n=t.User,r=t.RestrictionInfo,i=e.restrictionInfo,s=void 0===i?{}:i;return l(l({},n.objectify(e)),r.objectify(s))}}]),n}(It),tr=function(){function e(e){this.emojiHash=null,this.emojiCategories=null,e&&this._update(e)}return e.prototype._update=function(e){var t=x.get(this._iid).EmojiCategory;this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new t(e)})):[]},e}(),nr=function(){function e(e){this.id=null,this.name=null,this.url=null,this.emojis=null,e&&this._update(e)}return e.prototype._update=function(e){var t=x.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 t(e)})):[]},e}(),rr=function(){function e(e){this.key=null,this.url=null,e&&this._update(e)}return e.prototype._update=function(e){this.key=e.key,this.url=e.url},e}(),ir={},sr={},ar=new WeakMap,or=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=kt.CHANNEL_TYPE_OPEN,r.participantCount=0,ar.set(g(r),0),r.operators=[],e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=x.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 t(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,x.get(this._iid).ParticipantListQuery)({channelUrl:this.url})}},{key:"createMutedUserListQuery",value:function(){return new(0,x.get(this._iid).MutedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"createBannedUserListQuery",value:function(){return new(0,x.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 x.get(this._iid).OpenChannel.getChannelWithoutCache(this.url,e)}},{key:"enter",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).Command.bEnter({channelUrl:t.url}),r=Ri.getInstance(t._iid);r.sendCommand(n,(function(n,i){if(r.getErrorFirstCallback()){var s=[n,i];i=s[0],n=s[1]}i?(i=i?new H(i.message,i.code):null,e(i,null)):(x.get(t._iid).OpenChannel.enteredChannels[t.url]=t,Ie.of(t._iid).send({source:be.EVENT_CHANNEL_ENTER,payload:{channel:t}}),t.refresh((function(){return e(null,null)})))}))}),e)}},{key:"exit",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.Command,i=n.FileMessageQueue,s=r.bExit({channelUrl:t.url}),a=Ri.getInstance(t._iid);a.sendCommand(s,(function(n,r){if(a.getErrorFirstCallback()){var s=[n,r];r=s[0],n=s[1]}r?(r=r?new H(r.message,r.code):null,e(r,null)):(delete x.get(t._iid).OpenChannel.enteredChannels[t.url],i.delete(t.url),Ie.of(t._iid).send({source:be.EVENT_CHANNEL_EXIT,payload:{channel:t}}),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,t=tt.toArray(arguments),n=null;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.OpenChannel,s=r.OpenChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];(r.channelUrl=e.url,r._validate())?U.get(e._iid).container.apiClient.updateOpenChannel(r,(function(e,t){var r=null;e||(r=i.upsert(t)),n(e,r)})):n(tt.error,null)}),n);if(3===t.length){var a=new s;return a.channelUrl=this.url,a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=this.operators.map((function(e){return e.userId})),this.updateChannel(a,n)}if(4===t.length){var o=new s;return o.channelUrl=this.url,o.name=t[0],o.coverUrlOrImage=t[1],o.data=t[2],Array.isArray(t[3])&&(o.operatorUserIds=t[3]),this.updateChannel(o,n)}if(5===t.length){var l=new s;return l.channelUrl=this.url,l.name=t[0],l.coverUrlOrImage=t[1],l.data=t[2],Array.isArray(t[3])&&(l.operatorUserIds=t[3]),l.customType=t[4],this.updateChannel(l,n)}return oe(this._iid,(function(e){return e(tt.error,null)}),n)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return this.updateChannel.apply(this,A(e).concat([t]));default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}}},{key:"muteUser",value:function(e,t,n,r){return this.muteUserWithUserId(e?e.userId:null,t,n,r)}},{key:"muteUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string",optional:!0,defaultValue:""}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!1},(function(e,t){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,t){return this.unmuteUserWithUserId(e?e.userId:null,t)}},{key:"unmuteUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unmuteUser({channelUrl:n.url,userId:e,isGroupChannel:!1},(function(e,n){t(e,null)}))}),t)}},{key:"banUser",value:function(e,t,n){return this.banUserWithUserId(e?e.userId:null,t,n)}},{key:"banUserWithUserId",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.banUser({channelUrl:r.url,userId:e,description:null,seconds:t,isGroupChannel:!1},(function(e,t){n(e,null)}))}),n)}},{key:"unbanUser",value:function(e,t){return this.unbanUserWithUserId(e?e.userId:null,t)}},{key:"unbanUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unbanUser({channelUrl:n.url,userId:e,isGroupChannel:!1},(function(e,n){t(e,null)}))}),t)}},{key:"setLatestParticipantCount",value:function(e,t){var n=!1;return"number"==typeof e&&"number"==typeof t&&t>=ar.get(this)&&(ar.set(this,t),n=e!==this.participantCount,this.participantCount=e),n}},{key:"delete",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteOpenChannel({channelUrl:t.url},(function(n,r){n||(delete x.get(t._iid).OpenChannel.cachedChannels[t.url],x.get(t._iid).FileMessageQueue.delete(t.url));e(n,r)}))}),e)}}],[{key:"cachedChannels",get:function(){return ir[this._iid]||(ir[this._iid]={}),ir[this._iid]}},{key:"enteredChannels",get:function(){return sr[this._iid]||(sr[this._iid]={}),sr[this._iid]}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.OpenChannel,i=bt.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 n.objectify(e)}))})}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),s=b(i,4);if(n=s[0],e=s[1],r=s[2],t=s[3],n)return oe(this._iid,(function(e){e(n,null)}),t);var a=x.get(this._iid),o=a.OpenChannel;return o.cachedChannels[e]?oe(this._iid,(function(t){t(null,o.cachedChannels[e])}),t):o.getChannelWithoutCache(e,r,t)}},{key:"getChannelWithoutCache",value:function(e,t){var n=this,r=null,i=null,s=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),a=b(s,4);return r=a[0],e=a[1],i=a[2],t=a[3],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getOpenChannel({channelUrl:e,internalCall:i},(function(e,r){var i=null;e||(i=x.get(n._iid).OpenChannel.upsert(r));t(e,i)}))}),t)}},{key:"createChannel",value:function(){var e=this,t=tt.toArray(arguments),n=null;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.OpenChannel,s=r.OpenChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];r._validate()?U.get(e._iid).container.apiClient.createOpenChannel(r,(function(t,r){var i=null;t||(i=x.get(e._iid).OpenChannel.upsert(r));n(t,i)})):n(tt.error,null)}),n);var a=new s;switch(t.length){case 0:break;case 1:a.name=t[0];break;case 2:a.name=t[0],a.coverUrlOrImage=t[1];break;case 3:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2];break;case 4:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=t[3];break;case 5:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=t[3],a.customType=t[4];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return this.createChannel.apply(this,A(e).concat([t]));default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}}},{key:"upsert",value:function(e){var t=new(0,x.get(this._iid).OpenChannel)(e);return this.cachedChannels.hasOwnProperty(t.url)?this.cachedChannels[t.url].update(e):this.cachedChannels[t.url]=t,this.cachedChannels[t.url]}},{key:"removeCachedChannel",value:function(e){this.cachedChannels[e]&&delete this.cachedChannels[e],x.get(this._iid).FileMessageQueue.delete(e)}},{key:"clearCache",value:function(){ir[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){sr[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,x.get(this._iid).OpenChannelListQuery)}}]),n}(kt),lr="default",ur=function(){function e(e){this.name=lr,this.volume=1,e&&this._update(e)}return e.prototype._update=function(e){e.hasOwnProperty("name")&&(this.name=e.name),e.hasOwnProperty("volume")&&(this.volume=e.volume)},e.objectify=function(e){var t=e.name,n=void 0===t?lr:t,r=e.volume;return{name:n,volume:void 0===r?1:r}},e.prototype.serialize=function(){return bt.serialize(this)},e}(),cr=function(){function e(e,t){void 0===t&&(t=[]),this.key=e,this.value=Array.isArray(t)&&t.every((function(e){return"string"==typeof e}))?t:[]}return e.prototype.encode=function(){return{key:this.key,value:this.value||[]}},e}(),dr=new WeakMap,hr=function(){function e(t){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],dr.set(this,null),this._parentMessageId=null,this.data=null,this.customType=null,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this.isReplyToChannel=!1,t&&this._update(t)}return h(e,[{key:"mentionType",get:function(){return this._mentionType},set:function(e){var t=x.get(this._iid).BaseMessageParams;Object.keys(t.MentionType).map((function(e){return t.MentionType[e]})).indexOf(e)>-1&&(this._mentionType=e)}},{key:"mentionedUserIds",get:function(){return this._cachedMentionedUserIds},set:function(e){if(Array.isArray(e))for(var t=Ri.getInstance(this._iid),n=0;n-1&&this._mentionedUserIds.every((function(e){return"string"==typeof e}))&&Array.isArray(this._metaArrays)&&this._metaArrays.every((function(e){return e instanceof n}))&&("number"==typeof r||null===r)&&("number"==typeof this._parentMessageId||null===this._parentMessageId)&&("string"==typeof this.data||null===this.data)&&("string"==typeof this.customType||null===this.customType)&&(null===this.pushNotificationDeliveryOption||Object.keys(t.PushNotificationDeliveryOption).map((function(e){return t.PushNotificationDeliveryOption[e]})).indexOf(this.pushNotificationDeliveryOption)>-1)&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof ur)&&"boolean"==typeof this.isReplyToChannel}}],[{key:"_objectify",value:function(t){var n=t.mentionType,r=void 0===n?e.MentionType.USERS:n,i=t.mentionedUserIds,s=void 0===i?[]:i,a=t.cachedMentionedUsers,o=void 0===a?[]:a,l=t.cachedMentionedUserIds,u=void 0===l?[]:l,c=t.metaArrays,d=void 0===c?[]:c,h=t.parentMessageId,p=void 0===h?null:h,f=t.pushNotificationDeliveryOption,_=void 0===f?null:f,y=t.appleCriticalAlertOptions,g=void 0===y?null:y,m=t.isReplyToChannel;return{mention_type:r,mentioned_user_ids:s,cached_mentioned_users:o,cached_mentioned_user_ids:u,meta_arrays:d,parent_message_id:p,push_notification_delivery_option:_,apple_critical_alert_options:g,is_reply_to_channel:void 0!==m&&m}}},{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),pr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).message=null,r.pollId=void 0,r._translationTargetLanguages=[],e&&r._update(e),r}return h(n,[{key:"serialize",value:function(){return C(_(n.prototype),"_serialize",this).call(this,(function(e){e.hasOwnProperty("_translationTargetLanguages")&&(e.translationTargetLanguages=e._translationTargetLanguages,delete e._translationTargetLanguages)}))}},{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 t=0;t0?t.MessageRequestState.SUCCEEDED:t.MessageRequestState.FAILED,e.hasOwnProperty("sending_status")&&(this.requestState=e.sending_status,this.requestState===t.MessageSendingStatus.CANCELED&&(this.requestState=t.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)}))),this.poll=null,e.hasOwnProperty("poll")&&(this.poll=new s(e.poll)),e.hasOwnProperty("message_params")&&(this._messageParams=new pr(e.message_params))}},{key:"sender",get:function(){var e=Ri.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.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=Ri.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&ie.isResendableError(this.errorCode)}},{key:"serialize",value:function(){var e=this;return C(_(n.prototype),"serialize",this).call(this,(function(t){e._messageParams&&(t.messageParams=e._messageParams.serialize())}))}},{key:"messageParams",get:function(){return this._messageParams}},{key:"_clone",value:function(){return x.get(this._iid).UserMessage.buildFromSerializedData(this.serialize())}}],[{key:"objectify",value:function(e){var t=Ri.getInstance(this._iid),n=x.get(this._iid),r=n.BaseChannel,i=n.BaseMessageParams,s=n.Sender,a=n.User,o=n.UserMessage,u=n.FileMessage,c=n.AdminMessage,d=n.ThreadInfo,h=n.OGMetaData,p=n.Plugin,f=n.AppleCriticalAlertOptions,_=n.Poll,y=n.UserMessageParams,g=e.messageId,m=e.reqId,E=void 0===m?"":m,v=e.user,C=e.channel,b=e.message,A=e.data,N=void 0===A?"":A,S=e.customType,I=void 0===S?"":S,T=e.mentionType,O=void 0===T?i.MentionType.USERS:T,U=e.mentionedUsers,k=void 0===U?[]:U,R=e.mentionedUserIds,M=void 0===R?[]:R,P=e.requestedMentionUserIds,L=void 0===P?[]:P,w=e.reactions,D=void 0===w?[]:w,H=e.metaArrays,F=void 0===H?[]:H,G=e.rootMessageId,j=void 0===G?0:G,V=e.parentMessageId,B=void 0===V?0:V,K=e.parentMessageText,q=void 0===K?"":K,z=e.threadInfo,Y=void 0===z?null:z,Q=e.isReplyToChannel,W=void 0!==Q&&Q,J=e.parentMessage,X=void 0===J?null:J,Z=e.translations,$=void 0===Z?{}:Z,ee=e.sendingStatus,te=e.errorCode,ne=void 0===te?0:te,re=e.silent,ie=void 0!==re&&re,se=e.isGlobalBlocked,ae=void 0!==se&&se,oe=e.messageSurvivalSeconds,le=void 0===oe?-1:oe,ue=e.ogMetaData,ce=void 0===ue?null:ue,de=e.isOperatorMessage,he=void 0!==de&&de,pe=e.plugins,fe=void 0===pe?[]:pe,_e=e.appleCriticalAlertOptions,ye=e.poll,ge=void 0===ye?null:ye,me=e.createdAt,Ee=e.updatedAt,ve=void 0===Ee?0:Ee,Ce=e.messageParams,be=void 0===Ce?null:Ce,Ae=e.isAutoResendRegistered,Ne=void 0!==Ae&&Ae,Se={};if(Se.req_id=E,Se.msg_id=g,Se.user=s.objectify(l({},v)),Se.channel_url=C.url,Se.channel_type=C.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,Se.message=b,Se.data=N,Se.custom_type=I,Se.translations=$,Se.is_global_block=!!ae,Se.ts=me,Se.updated_at=ve,Se.mention_type=O,Se.mentioned_users=k.map((function(e){return a.objectify(e)})),Se.mentioned_user_ids=M,Se.requested_mention_user_ids=L,Se.reactions=D.map((function(e){return e.serialize()})),Se.metaarray={},F.forEach((function(e){var t=e.key;Se.metaarray[t]=e.value})),Se.metaarray_key_order=F.map((function(e){return e.key})),Se.root_message_id=j,Se.parent_message_id=B,Se.parent_message_text=q,Y&&(Se.thread_info=d.objectify(Y)),Se.is_reply_to_channel=W,X)switch(X.messageType){case r.MESSAGE_TYPE_USER:Se.parent_message_info=o.objectify(X);break;case r.MESSAGE_TYPE_FILE:Se.parent_message_info=u.objectify(X);break;case r.MESSAGE_TYPE_ADMIN:Se.parent_message_info=c.objectify(X)}return Se.sending_status=g>0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ee&&(Se.sending_status=ee),Se.silent=!!ie,Se.error_code=ne,Se.message_survival_seconds=le,ce&&(Se.og_tag=h.objectify(ce)),Se.is_op_msg=!!he,Se.plugins=fe.map((function(e){return p.objectify(e)})),ge&&(Se.poll=_.objectify(ge)),_e&&(Se.apple_critical_alert_options=f.objectify(_e)),be&&(Se.message_params=y.objectify(be)),Se.is_auto_resend_registered=Ne,Se}},{key:"build",value:function(e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_,y,g,m,E,v,C,b,A,N,S,I,T,O,U){return this.objectify({messageId:t,reqId:e,user:n,channel:r,message:i,data:s,customType:a,mentionType:p,mentionedUsers:f,mentionedUserIds:E,requestedMentionUserIds:C,reactions:h,metaArrays:d,rootMessageId:_,parentMessageId:y,parentMessageText:g,threadInfo:m,translations:o,sendingStatus:v,errorCode:b,isGlobalBlocked:l,messageSurvivalSeconds:A,ogMetaData:N,isOperatorMessage:S,plugins:I,appleCriticalAlertOptions:T,poll:O,createdAt:u,updatedAt:c,messageParams:U})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).UserMessage,n=bt.deserialize(e);return new t(t.objectify(l(l({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,messageParams:n.messageParams?new pr(pr.objectify(n.messageParams)):null})))}}]),n}(St),_r="file",yr="blob",gr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).fileName=null,r.mimeType=null,r.fileSize=null,r._isUpdate=!1,r._file=null,r._fileType=null,r._fileUrl=null,r._thumbnailSizes=[],e&&r._update(e),r}return h(n,[{key:"serialize",value:function(){return C(_(n.prototype),"_serialize",this).call(this,(function(e){e.hasOwnProperty("_isUpdate")&&(e.isUpdate=e._isUpdate,delete e._isUpdate),e.hasOwnProperty("_file")&&(e.file=e._file,delete e._file),e.hasOwnProperty("_fileType")&&(e.fileType=e._fileType,delete e._fileType),e.hasOwnProperty("_fileUrl")&&(e.fileUrl=e._fileUrl,delete e._fileUrl),e.hasOwnProperty("_thumbnailSizes")&&(e.thumbnailSizes=e._thumbnailSizes,delete e._thumbnailSizes)}))}},{key:"file",get:function(){return this._file},set:function(e){ie.isFile(e)&&(this._fileUrl=null,this._file=e,se.isFile(e)?this._fileType=_r:se.isBlob(e)&&(this._fileType=yr))}},{key:"fileType",get:function(){return this._fileType}},{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 t=0;t0&&e.maxHeight>0})))}}],[{key:"objectify",value:function(e){var t=e.fileName,n=void 0===t?null:t,r=e.mimeType,i=void 0===r?null:r,s=e.fileSize,a=void 0===s?null:s,o=e.data,u=void 0===o?null:o,c=e.customType,d=void 0===c?null:c,h=e.isUpdate,p=void 0!==h&&h,f=e.file,_=void 0===f?null:f,y=e.fileType,g=void 0===y?null:y,m=e.fileUrl,E=void 0===m?null:m,v=e.thumbnailSizes,C=void 0===v?[]:v;return l(l({},hr._objectify(e)),{},{file_name:n,mime_type:i,file_size:a,data:u,custom_type:d,is_update:p,file:_,file_type:g,file_url:E,thumbnail_sizes:C})}}]),n}(hr),mr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=St.MESSAGE_TYPE_FILE,r.plainUrl=null,r.name="File",r.size=0,r.type=null,r.thumbnails=[],r._sender=null,r.requireAuth=null,r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r._messageParams=null,e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=Ri.getInstance(this._iid),n=U.get(this._iid).container.auth,r=x.get(this._iid).Sender;if(this._sender=new r(e.user),this.requireAuth=!!e.hasOwnProperty("require_auth")&&e.require_auth,e.hasOwnProperty("url")&&(this.plainUrl=e.url.split("?auth=")[0]),this.name=e.hasOwnProperty("name")?e.name:"File",this.size=parseInt(e.size)||0,this.type=e.type,e.hasOwnProperty("custom")&&(this.data=e.custom),e.hasOwnProperty("file")){var i=e.file;i.hasOwnProperty("url")&&(this.plainUrl=i.url),i.hasOwnProperty("name")&&(this.name=i.name),i.hasOwnProperty("size")&&(this.size=i.size),i.hasOwnProperty("type")&&(this.type=i.type),i.hasOwnProperty("custom")&&(this.data=i.custom)}if(Object.defineProperty(this,"url",{value:this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(n.eKey):this.plainUrl,configurable:!0,writable:!1}),this.reqId=e.hasOwnProperty("req_id")?String(e.req_id):"",this.thumbnails=e.hasOwnProperty("thumbnails")?e.thumbnails:[],this.requireAuth)for(var s=0;s0?t.MessageRequestState.SUCCEEDED:t.MessageRequestState.FAILED,e.hasOwnProperty("sending_status")&&(this.requestState=e.sending_status,this.requestState===t.MessageSendingStatus.CANCELED&&(this.requestState=t.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),e.hasOwnProperty("message_params")&&(this._messageParams=new gr(e.message_params))}},{key:"sender",get:function(){var e=Ri.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.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=Ri.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&ie.isResendableError(this.errorCode)}},{key:"serialize",value:function(){var e=this;return C(_(n.prototype),"serialize",this).call(this,(function(t){e._messageParams&&(t.messageParams=e._messageParams.serialize())}))}},{key:"messageParams",get:function(){return this._messageParams}},{key:"_clone",value:function(){var e=x.get(this._iid).FileMessage.buildFromSerializedData(this.serialize());if(this._messageParams&&e._messageParams){var t=this._messageParams.file;t&&se.isBlob(t)&&(e._messageParams.file=t.slice())}return e}}],[{key:"objectify",value:function(e){var t=Ri.getInstance(this._iid),n=x.get(this._iid),r=n.BaseChannel,i=n.BaseMessageParams,s=n.Sender,a=n.User,o=n.UserMessage,u=n.FileMessage,c=n.AdminMessage,d=n.ThreadInfo,h=n.OGMetaData,p=n.FileMessageParams,f=n.AppleCriticalAlertOptions,_=e.messageId,y=e.reqId,g=void 0===y?"":y,m=e.user,E=void 0===m?{}:m,v=e.channel,C=e.plainUrl,b=e.name,A=void 0===b?null:b,N=e.type,S=e.size,I=void 0===S?0:S,T=e.data,O=void 0===T?"":T,U=e.customType,k=void 0===U?"":U,R=e.mentionType,M=void 0===R?i.MentionType.USERS:R,P=e.mentionedUsers,L=void 0===P?[]:P,w=e.mentionedUserIds,D=void 0===w?[]:w,H=e.requestedMentionUserIds,F=void 0===H?[]:H,G=e.reactions,j=void 0===G?[]:G,V=e.metaArrays,B=void 0===V?[]:V,K=e.rootMessageId,q=void 0===K?0:K,z=e.parentMessageId,Y=void 0===z?0:z,Q=e.parentMessageText,W=void 0===Q?"":Q,J=e.threadInfo,X=void 0===J?null:J,Z=e.isReplyToChannel,$=void 0!==Z&&Z,ee=e.parentMessage,te=void 0===ee?null:ee,ne=e.thumbnails,re=void 0===ne?[]:ne,ie=e.requireAuth,se=void 0!==ie&&ie,ae=e.sendingStatus,oe=e.errorCode,le=void 0===oe?0:oe,ue=e.silent,ce=void 0!==ue&&ue,de=e.isGlobalBlocked,he=void 0!==de&&de,pe=e.messageSurvivalSeconds,fe=void 0===pe?-1:pe,_e=e.ogMetaData,ye=void 0===_e?null:_e,ge=e.isOperatorMessage,me=void 0!==ge&&ge,Ee=e.appleCriticalAlertOptions,ve=e.createdAt,Ce=e.updatedAt,be=void 0===Ce?0:Ce,Ae=e.messageParams,Ne=void 0===Ae?null:Ae,Se=e.isAutoResendRegistered,Ie=void 0!==Se&&Se,Te={};Te.req_id=g,Te.msg_id=_,Te.user=s.objectify(l({},E)),Te.channel_url=v.url,Te.channel_type=v.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,Te.url=C,Te.name=A,Te.type=N,Te.size=I,Te.custom=O,Te.custom_type=k,Te.thumbnails=re,Te.require_auth=se,Te.is_global_block=!!he,Te.ts=ve,Te.updated_at=be,Te.mention_type=M,Te.mentioned_users=L.map((function(e){return a.objectify(e)})),Te.mentioned_user_ids=D,Te.requested_mention_user_ids=F,Te.reactions=j.map((function(e){return e.serialize()})),Te.metaarray={};for(var Oe=0;Oe0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ae&&(Te.sending_status=ae),Te.silent=!!ce,Te.error_code=le,Te.message_survival_seconds=fe,ye&&(Te.og_tag=h.objectify(ye)),Te.is_op_msg=!!me,Ee&&(Te.apple_critical_alert_options=f.objectify(Ee)),Ne&&(Te.message_params=p.objectify(Ne)),Te.is_auto_resend_registered=Ie,Te}},{key:"build",value:function(e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_,y,g,m,E,v,C,b,A,N,S,I,T,O,U,k,R){return this.objectify({messageId:t,reqId:e,user:n,channel:r,plainUrl:i,name:s,type:a,size:o,data:l,customType:u,mentionType:g,mentionedUsers:m,mentionedUserIds:A,requestedMentionUserIds:S,reactions:y,metaArrays:_,rootMessageId:E,parentMessageId:v,parentMessageText:C,threadInfo:b,thumbnails:h,requireAuth:p,sendingStatus:N,errorCode:I,isGlobalBlocked:c,messageSurvivalSeconds:T,ogMetaData:O,isOperatorMessage:U,appleCriticalAlertOptions:k,createdAt:d,updatedAt:f,messageParams:R})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).FileMessage,n=bt.deserialize(e);return new t(t.objectify(l(l({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,messageParams:n.messageParams?new gr(gr.objectify(n.messageParams)):null})))}}]),n}(St),Er=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=St.MESSAGE_TYPE_ADMIN,r.message="",r.translations={},e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){this.message=String(e.message),this.translations=e.hasOwnProperty("translations")?e.translations:{}}}],[{key:"objectify",value:function(e){var t=x.get(this._iid),n=t.BaseChannel,r=t.BaseMessageParams,i=t.UserMessage,s=t.FileMessage,a=t.AdminMessage,o=t.User,l=t.ThreadInfo,u=t.OGMetaData,c=e.messageId,d=e.channel,h=e.message,p=e.data,f=void 0===p?"":p,_=e.customType,y=void 0===_?"":_,g=e.mentionType,m=void 0===g?r.MentionType.USERS:g,E=e.mentionedUsers,v=void 0===E?[]:E,C=e.reactions,b=void 0===C?[]:C,A=e.metaArrays,N=void 0===A?[]:A,S=e.rootMessageId,I=void 0===S?0:S,T=e.parentMessageId,O=void 0===T?0:T,U=e.parentMessageText,k=void 0===U?"":U,R=e.threadInfo,M=void 0===R?null:R,P=e.isReplyToChannel,L=void 0!==P&&P,w=e.parentMessage,D=void 0===w?null:w,H=e.translations,F=void 0===H?{}:H,G=e.silent,j=void 0!==G&&G,V=e.ogMetaData,B=void 0===V?null:V,K=e.createdAt,q=e.updatedAt,z=void 0===q?0:q,Y={msg_id:c,channel_url:d.url,channel_type:d.channelType===n.CHANNEL_TYPE_OPEN?n.CHANNEL_TYPE_OPEN:n.CHANNEL_TYPE_GROUP,message:h,data:f,custom_type:y,silent:j,ts:K,updated_at:z};Y.translations=F,Y.mention_type=m,Y.mentioned_users=v.map((function(e){return o.objectify(e)})),Y.reactions=b.map((function(e){return e.serialize()})),Y.metaarray={};for(var Q=0;Q0&&Array.isArray(t.userIdsFilter)&&"string"==typeof t.metaDataKeyFilter&&Array.isArray(t.metaDataValuesFilter)&&!!t.metaDataKeyFilter==t.metaDataValuesFilter.length>0&&("string"==typeof t.nicknameStartsWithFilter||null===t.nicknameStartsWithFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadUserList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Sr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._isOpenChannel=!1,this._channelUrl=null,this._token="",t.channelUrl&&(this._channelUrl=t.channelUrl),t.isOpenChannel&&(this._isOpenChannel=t.isOpenChannel)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadBannedUserList(l(l({},t),{},{channelUrl:t._channelUrl,isOpenChannel:t._isOpenChannel,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).RestrictedUser,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.banned_list.map((function(e){var t=new s(e);return t.restrictionInfo.restrictionType=s.RestrictionType.BANNED,t}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Ir=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 t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0&&Array.isArray(t.userIdsFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadBlockedUserList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Tr=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 t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasMore?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadFriendList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasMore=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Or=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=Xn.MemberStateFilter.ALL,this.customTypesFilter=[],this.channelUrlsFilter=[],this.superChannelFilter=Xn.SuperChannelFilter.ALL,this.publicChannelFilter=Xn.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Xn.UnreadChannelFilter.ALL,this.metadataOrderKeyFilter=null,this.metadataKey=null,this.metadataValues=[],this.metadataValueStartsWith=null,this.hiddenChannelFilter=Xn.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(t){Object.keys(e.QueryType).map((function(t){return e.QueryType[t]})).indexOf(t)>-1&&(this._userIdsIncludeFilterQueryType=t.toUpperCase(),this._userIdsFilter.queryType=this._userIdsIncludeFilterQueryType)}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={search_query:t,search_fields:e.join(",").toLocaleLowerCase()})}},{key:"serialize",value:function(){return bt.serialize(this,(function(e){e.isLoading=!1}))}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.GroupChannel,i=n.GroupChannelListQuery;!("number"==typeof t.limit&&t.limit>0&&"boolean"==typeof t.includeEmpty&&"string"==typeof t.order&&[i.ORDER_CHRONOLOGICAL,i.ORDER_LATEST_LAST_MESSAGE,i.CHANNEL_NAME_ALPHABETICAL,i.METADATA_VALUE_ALPHABETICAL].indexOf(t.order.toLowerCase())>-1&&Array.isArray(t._userIdsExactFilter)&&Array.isArray(t._userIdsIncludeFilter)&&Array.isArray(t.customTypesFilter)&&Array.isArray(t.channelUrlsFilter)&&Object.keys(i.QueryType).map((function(e){return i.QueryType[e]})).indexOf(t._userIdsIncludeFilterQueryType.toUpperCase())>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(t.memberStateFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(t.superChannelFilter)>-1&&Object.keys(r.PublicChannelFilter).map((function(e){return r.PublicChannelFilter[e]})).indexOf(t.publicChannelFilter)>-1&&Object.keys(r.UnreadChannelFilter).map((function(e){return r.UnreadChannelFilter[e]})).indexOf(t.unreadChannelFilter)>-1&&Object.keys(r.HiddenChannelFilter).map((function(e){return r.HiddenChannelFilter[e]})).indexOf(t.hiddenChannelFilter)>-1)||"string"!=typeof t.customTypeStartsWithFilter&&null!==t.customTypeStartsWithFilter||"string"!=typeof t.nicknameContainsFilter||"string"!=typeof t.channelNameContainsFilter||"string"!=typeof t.metadataOrderKeyFilter&&null!==t.metadataOrderKeyFilter||"string"!=typeof t.metadataKey&&null!==t.metadataKey||!Array.isArray(t.metadataValues)||!t.metadataValues.every((function(e){return"string"==typeof e}))||"string"!=typeof t.metadataValueStartsWith&&null!==t.metadataValueStartsWith||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadGroupChannelList(l(l({},t),{},{token:t._token,userIdsFilter:t._userIdsFilter,searchFilter:t._searchFilter})).then((function(n){var r=x.get(t._iid).GroupChannel,i=String(n.next);t._token=i,t.hasNext=!!i;var s=n.channels;if(!s||!Array.isArray(s))throw new H("Failed at loading group channels.",H.MALFORMED_DATA);var a=s.map((function(e){return"number"==typeof n.ts&&(e.ts=n.ts),r.upsert(e)}));t.isLoading=!1,e(null,a)})).catch((function(n){t.isLoading=!1,e(n,null)}))):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 t=x.get(this._iid).GroupChannel,n=bt.deserialize(e),r=t.createMyGroupChannelListQuery();return Object.keys(n).forEach((function(e){r.hasOwnProperty(e)&&(r[e]=n[e])})),r}}]),e}(),Ur=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.mutedMemberFilter=e.MutedMemberFilter.ALL,this.memberStateFilter=Xn.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.order=e.Order.MEMBER_NICKNAME_ALPHABETICAL,this._token="",this._channelUrl=t}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.GroupChannel,i=n.Member,s=n.MemberListQuery;"number"==typeof t.limit&&t.limit>0&&Object.keys(s.MutedMemberFilter).map((function(e){return s.MutedMemberFilter[e]})).indexOf(t.mutedMemberFilter)>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(t.memberStateFilter)>-1&&Object.keys(s.Order).map((function(e){return s.Order[e]})).indexOf(t.order)>-1&&("string"==typeof t.nicknameStartsWithFilter||null===t.nicknameStartsWithFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadMemberList(l(l({},t),{},{channelUrl:t._channelUrl,token:t._token}),(function(n,r){var s=null;if(!n){var a=String(r.next);t._token=a,t.hasNext=!!a,s=r.members.map((function(e){return new i(e)}))}t.isLoading=!1,e(n,s)}))):e(null,[]):e(tt.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}(),kr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t.channelUrl&&(this._channelUrl=t.channelUrl),t.isOpenChannel&&(this._isOpenChannel=t.isOpenChannel)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadMutedUserList(l(l({},t),{},{channelUrl:t._channelUrl,isOpenChannel:t._isOpenChannel,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).RestrictedUser,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.muted_list.map((function(e){var t=new s(e);return t.restrictionInfo.restrictionType=s.RestrictionType.MUTED,t}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Rr=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 t=this;return oe(this._iid,(function(e){!("number"==typeof t.limit&&t.limit>0&&Array.isArray(t.customTypes))||"string"!=typeof t.nameKeyword&&null!==t.nameKeyword||"string"!=typeof t.urlKeyword&&null!==t.urlKeyword||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadOpenChannelList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).OpenChannel,a=String(r.next);t._token=a,t.hasNext=!!a;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),s.upsert(e)})):n=new H("Failed at loading open channels.",H.MALFORMED_DATA)}t.isLoading=!1,e(n,i)}))):e(null,[])}),e)}}]),e}(),Mr=new WeakMap,Pr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",Mr.set(this,t)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){if("number"==typeof t.limit&&t.limit>0)if(t.isLoading)e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(t.hasNext){t.isLoading=!0;var n=Mr.get(t);U.get(t._iid).container.apiClient.loadOperatorList(l(l({},t),{},{token:t._token,channelUrl:n.url,isOpenChannel:n.isOpenChannel()}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.operators.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))}else e(null,[]);else e(tt.error,null)}),e)}}]),e}(),Lr=new WeakMap,wr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t&&Lr.set(this,t.channelUrl)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadParticipantList(l(l({},t),{},{channelUrl:Lr.get(t),token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.participants.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Dr=new WeakMap,Hr=function(){function e(t,n){var r=n.limit,i=void 0===r?20:r,s=n.reverse,a=void 0!==s&&s,o=n.exactMatch,l=void 0!==o&&o,u=n.channelUrl,d=void 0===u?"":u,h=n.channelCustomType,p=void 0===h?"":h,f=n.messageTimestampFrom,_=void 0===f?null:f,y=n.messageTimestampTo,g=void 0===y?null:y,m=n.order,E=void 0===m?"score":m,v=n.advancedQuery,C=void 0!==v&&v,b=n.targetFields,A=void 0===b?null:b;c(this,e),this.isLoading=!1,this.hasNext=!0,Dr.set(this,{keyword:t,limit:i,reverse:a,exactMatch:l,channelUrl:d,channelCustomType:p,messageTimestampFrom:_,messageTimestampTo:g,order:E,advancedQuery:C,targetFields:A,previousToken:"",nextToken:""})}return h(e,[{key:"key",get:function(){return Dr.get(this).keyword}},{key:"limit",get:function(){return Dr.get(this).limit}},{key:"reverse",get:function(){return Dr.get(this).reverse}},{key:"exactMatch",get:function(){return Dr.get(this).exactMatch}},{key:"channelUrl",get:function(){return Dr.get(this).channelUrl}},{key:"channelCustomType",get:function(){return Dr.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return Dr.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return Dr.get(this).messageTimestampTo}},{key:"order",get:function(){return Dr.get(this).order}},{key:"next",value:function(e){var t=this,n=x.get(this._iid),r=n.BaseChannel,i=n.GroupChannel,s=n.OpenChannel;return oe(this._iid,(function(e){var n=Dr.get(t),a=n.keyword,o=n.limit,l=n.reverse,u=n.exactMatch,c=n.channelUrl,d=n.channelCustomType,h=n.messageTimestampFrom,p=n.messageTimestampTo,f=n.order,_=n.advancedQuery,y=n.targetFields,g=n.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 _&&null!==_||!Array.isArray(y)&&null!==y?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.searchMessages({keyword:a,limit:o,reverse:l,exactMatch:u,channelUrl:c,channelCustomType:d,messageTimestampFrom:h,messageTimestampTo:p,order:f,advancedQuery:_,targetFields:y,nextToken:g},(function(n,a){var o=null;n||(o=[],a.results.forEach((function(e){if(e.channel.hasOwnProperty("members")){var t=new i(e.channel);i.cachedChannels[t.url]=t,o.push(r.buildMessage(e,t))}else{var n=new s(e.channel);s.cachedChannels[n.url]=n,o.push(r.buildMessage(e,n))}})),t.hasNext=a.has_next,Dr.get(t).nextToken=a.end_cursor),t.isLoading=!1,e(n,o)}))):e(null,[])}),e)}}]),e}(),Fr=new WeakMap,Gr=new WeakMap,xr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,Gr.set(this,Number.MAX_SAFE_INTEGER),Fr.set(this,t),this.reverse=!1,this.messageTypeFilter=null,this.customTypeFilter=null,this.customTypesFilter=[],this.senderUserIdsFilter=[],this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.showSubchannelMessagesOnly=!1,this.includePollDetails=!1}return h(e,[{key:"load",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=s.BaseMessage,l=null,u=tt.parse(arguments,[new tt({type:"number",optional:!0,defaultValue:this.limit}),new tt({type:"boolean",optional:!0,defaultValue:this.reverse}),new tt({type:["string","number"],optional:!0,defaultValue:this.messageTypeFilter,constraint:function(e){return Object.keys(a.MessageTypeFilter).map((function(e){return a.MessageTypeFilter[e]})).indexOf(e)>-1||[0,1,2,3].indexOf(e)>-1}}),new tt({type:"callback"})]),c=b(u,5);return l=c[0],e=c[1],t=c[2],n=c[3],r=c[4],oe(this._iid,(function(r){if(("string"!=typeof i.customTypeFilter&&null!==i.customTypeFilter||!Array.isArray(i.customTypesFilter)||!i.customTypesFilter.every((function(e){return"string"==typeof e||null===e}))||!Array.isArray(i.senderUserIdsFilter)||!i.senderUserIdsFilter.every((function(e){return"string"==typeof e}))||"boolean"!=typeof i.includeMetaArray||null!==i.includeReaction&&"boolean"!=typeof i.includeReaction||null!==i.includeReactions&&"boolean"!=typeof i.includeReactions||"boolean"!=typeof i.includeThreadInfo||null!==i.includeReplies&&"boolean"!=typeof i.includeReplies||!(null===i.replyType||"string"==typeof i.replyType&&Object.values(o.ReplyType).includes(i.replyType))||null!==i.includeParentMessageText&&"boolean"!=typeof i.includeParentMessageText||null!==i.includeParentMessageInfo&&"boolean"!=typeof i.includeParentMessageInfo||"boolean"!=typeof i.showSubchannelMessagesOnly)&&(l=tt.error),l)r(l,null);else{if(i.limit=e,i.reverse=t,i.messageTypeFilter=n,"number"==typeof i.messageTypeFilter)switch(i.messageTypeFilter){case 0:i.messageTypeFilter=a.MessageTypeFilter.ALL;break;case 1:i.messageTypeFilter=a.MessageTypeFilter.USER;break;case 2:i.messageTypeFilter=a.MessageTypeFilter.FILE;break;case 3:i.messageTypeFilter=a.MessageTypeFilter.ADMIN}if(i.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(i.hasMore){i.isLoading=!0;var s=Fr.get(i);U.get(i._iid).container.apiClient.getMessageList({channel:s,token:Gr.get(i)||(new Date).getTime()+1e4,tokenType:"timestamp",isInclusive:!1,prevResultSize:e,nextResultSize:0,shouldReverse:t,messageType:i.messageTypeFilter,customType:i.customTypeFilter,customTypes:i.customTypesFilter,senderUserIds:i.senderUserIdsFilter,includeMetaArray:i.includeMetaArray,includeReaction:i.includeReaction,includeReactions:i.includeReactions,includeReplies:i.includeReplies,includeParentMessageText:i.includeParentMessageText,includeThreadInfo:i.includeThreadInfo,replyType:i.replyType,includeParentMessageInfo:i.includeParentMessageInfo,showSubchannelMessagesOnly:i.showSubchannelMessagesOnly,includePollDetails:i.includePollDetails}).then((function(t){var n=t.messages.map((function(e){return a.buildMessage(e,s)}));(0===n.length||n.length0&&"boolean"==typeof n.includeEmpty&&"string"==typeof n.order&&[e.ORDER_CHRONOLOGICAL,e.CHANNEL_NAME_ALPHABETICAL,e.METADATA_VALUE_ALPHABETICAL,e.ORDER_LATEST_LAST_MESSAGE].indexOf(n.order.toLowerCase())>-1&&Array.isArray(n.customTypesFilter)&&Array.isArray(n.channelUrlsFilter)&&Object.keys(e.MembershipType).map((function(t){return e.MembershipType[t]})).indexOf(n.membershipFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(n.superChannelFilter)>-1)||"string"!=typeof n.customTypeStartsWithFilter&&null!==n.customTypeStartsWithFilter||"string"!=typeof n.channelNameContainsFilter||"string"!=typeof n.metadataOrderKeyFilter&&null!==n.metadataOrderKeyFilter||"string"!=typeof n.metadataKey&&null!==n.metadataKey||!Array.isArray(n.metadataValues)||!n.metadataValues.every((function(e){return"string"==typeof e}))||"string"!=typeof n.metadataValueStartsWith&&null!==n.metadataValueStartsWith||"boolean"!=typeof n.includeFrozen||"boolean"!=typeof n.includeMetaData?t(tt.error,null):n.isLoading?t(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,U.get(n._iid).container.apiClient.loadPublicGroupChannelList(l(l({},n),{},{token:n._token}),(function(e,i){var s=null;if(!e){var a=String(i.next);n._token=a,n.hasNext=!!a;var o=i.channels;o&&Array.isArray(o)?s=o.map((function(e){return"number"==typeof i.ts&&(e.ts=i.ts),r.upsert(e)})):e=new H("Failed at loading group channels.",H.MALFORMED_DATA)}n.isLoading=!1,t(e,s)}))):t(null,[])}),t)}}],[{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}(),Vr=new WeakMap,Br=new WeakMap,Kr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.token,s=void 0===i?"":i,a=t.limit,o=void 0===a?20:a;c(this,e),this.channelUrl=r,this.token=s,this.limit=o,Vr.set(this,!1),Br.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!Vr.get(this)}},{key:"hasNext",get:function(){return!!Br.get(this)}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"string"==typeof t.channelUrl&&"number"==typeof t.limit&&t.limit>0&&t.limit<=100?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(Vr.set(t,!0),U.get(t._iid).container.apiClient.getPollList(l({},t),(function(n,r){if(n)Vr.set(t,!1),e(n,null);else{var i=x.get(t._iid).Poll,s=r.hasOwnProperty("polls")&&Array.isArray(r.polls)?r.polls.map((function(e){return new i(e)})):[],a=r.hasOwnProperty("next")&&r.next?String(r.next):"";t.token=a,Vr.set(t,!1),Br.set(t,!!a),e(null,s)}}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),qr=new WeakMap,zr=new WeakMap,Yr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.pollId,s=void 0===i?null:i,a=t.optionId,o=void 0===a?null:a,l=t.token,u=void 0===l?"":l,d=t.limit,h=void 0===d?100:d;c(this,e),this.channelUrl=r,this.pollId=s,this.optionId=o,this.token=u,this.limit=h,qr.set(this,!1),zr.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!qr.get(this)}},{key:"hasNext",get:function(){return!!zr.get(this)}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"string"==typeof t.channelUrl&&"number"==typeof t.pollId&&"number"==typeof t.optionId&&"number"==typeof t.limit&&t.limit>0&&t.limit<=100?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(qr.set(t,!0),U.get(t._iid).container.apiClient.getPollOptionVoterList(l({},t),(function(n,r){if(n)qr.set(t,!1),e(n,null);else{var i=x.get(t._iid).User,s=r.hasOwnProperty("voters")&&Array.isArray(r.voters)?r.voters.map((function(e){return new i(e)})):[],a=r.hasOwnProperty("next")&&r.next?String(r.next):"";t.token=a,qr.set(t,!1),zr.set(t,!!a),e(null,s)}}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Qr=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 t=null;Object.defineProperty(this,"operators",{set:function(e){Array.isArray(e)&&(e.filter((function(e){return e.hasOwnProperty("userId")})).length===e.length&&(t=e.map((function(e){return e.userId}))))}}),Object.defineProperty(this,"operatorUserIds",{get:function(){return t},set:function(e){Array.isArray(e)&&(e.filter((function(e){return"string"==typeof e})).length===e.length&&(t=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)&&(ie.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 t,n=e.filter((function(e){return e.hasOwnProperty("userId")&&"string"==typeof e.userId})).map((function(e){return e.userId}));(t=this._invitedUserIds).push.apply(t,A(n))}}},{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 t,n=e.filter((function(e){return"string"==typeof e}));(t=this._invitedUserIds).push.apply(t,A(n))}}},{key:"addUserId",value:function(e){"string"==typeof e&&this._invitedUserIds.push(e)}}]),e}(),Wr=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||ie.isFile(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&("string"==typeof this.name||null===this.name)&&("string"==typeof this.data||null===this.data)&&("string"==typeof this.customType||null===this.customType)&&("string"==typeof this.channelUrl&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)}}]),e}(),Jr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.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(n,[{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,t,n,r,i,s){"number"==typeof e&&4===e.toString().length&&"number"==typeof t&&t>=1&&t<=12&&"number"==typeof n&&n>=1&&n<=31&&"number"==typeof r&&r>=0&&r<=24&&"number"==typeof i&&i>=0&&i<=60&&"string"==typeof s&&s.length>0&&(this.scheduledDateTimeString=e.toString()+"-"+("0"+t.toString()).substr(-2)+"-"+("0"+n.toString()).substr(-2)+" "+("0"+r.toString()).substr(-2)+":"+("0"+i.toString()).substr(-2),this.timezone=s)}}]),n}(pr),Xr=function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=Xn.SuperChannelFilter.ALL},Zr=function(){function e(){c(this,e),this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid).BaseChannel;return"string"==typeof this.channelUrl&&"string"==typeof this.channelType&&[e.CHANNEL_TYPE_BASE,e.CHANNEL_TYPE_OPEN,e.CHANNEL_TYPE_GROUP].includes(this.channelType)&&"number"==typeof this.messageId&&"boolean"==typeof this.includeMetaArray&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),$r=function(){function e(){c(this,e);var t=x.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=t.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.showSubchannelMessagesOnly=!1,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid),t=e.BaseChannel,n=e.BaseMessage;return"number"==typeof this.prevResultSize&&"number"==typeof this.nextResultSize&&"boolean"==typeof this.isInclusive&&"boolean"==typeof this.reverse&&"string"==typeof this.messageType&&Object.values(t.MessageTypeFilter).includes(this.messageType)&&("string"==typeof this.customType||null===this.customType)&&Array.isArray(this.customTypes)&&this.customTypes.every((function(e){return"string"==typeof e||null===e}))&&(Array.isArray(this.senderUserIds)&&this.senderUserIds.every((function(e){return"string"==typeof e}))||null===this.senderUserIds)&&"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(n.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.showSubchannelMessagesOnly&&"boolean"==typeof this.includePollDetails}},{key:"belongsTo",value:function(e){var t=x.get(this._iid),n=t.BaseChannel,r=t.UserMessageParams,i=t.FileMessageParams,s=t.BaseMessage;if(this.messageType!==n.MessageTypeFilter.ALL){if(e instanceof r&&this.messageType!==n.MessageTypeFilter.USER)return!1;if(e instanceof i&&this.messageType!==n.MessageTypeFilter.FILE)return!1}if(Array.isArray(this.customTypes)&&this.customTypes.length>0&&!this.customTypes.includes(e.customType))return!1;if("string"==typeof this.customType&&this.customType!==e.customType)return!1;if(Array.isArray(this.senderUserIds)&&this.senderUserIds.length>0){var a=Ri.getInstance(e._iid);if(!a||!a.currentUser||!this.senderUserIds.includes(a.currentUser.userId))return!1}if("string"==typeof this.replyType&&e.parentMessageId){if(this.replyType===s.ReplyType.NONE)return!1;if(this.replyType===s.ReplyType.ONLY_REPLY_TO_CHANNEL&&!e.isReplyToChannel)return!1}else if(!1===this.includeReplies&&e.parentMessageId)return!1;return!0}}]),e}(),ei=function(){function e(){c(this,e);var t=x.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=t.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeParentMessageText=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid).BaseChannel;return"number"==typeof this.prevResultSize&&"number"==typeof this.nextResultSize&&"boolean"==typeof this.isInclusive&&"boolean"==typeof this.reverse&&"string"==typeof this.messageType&&Object.values(e.MessageTypeFilter).includes(this.messageType)&&("string"==typeof this.customType||null===this.customType)&&Array.isArray(this.customTypes)&&this.customTypes.every((function(e){return"string"==typeof e||null===e}))&&(Array.isArray(this.senderUserIds)&&this.senderUserIds.every((function(e){return"string"==typeof e}))||null===this.senderUserIds)&&"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),ti=function(){function e(){c(this,e),this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){return"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(BaseMessage.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),ni=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}(),ri=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.title,r=void 0===n?null:n,i=t.options,s=void 0===i?null:i,a=t.data,o=void 0===a?null:a,l=t.isAnonymous,u=void 0===l?null:l,d=t.allowUserSuggestion,h=void 0===d?null:d,p=t.allowMultipleVotes,f=void 0===p?null:p,_=t.closeAt,y=void 0===_?null:_;c(this,e),this.title=r,this.options=s,this.data=o,this.isAnonymous=u,this.allowUserSuggestion=h,this.allowMultipleVotes=f,this.closeAt=y}return h(e,[{key:"_validate",value:function(){return"string"==typeof this.title&&(Array.isArray(this.options)&&this.options.length>0&&this.options.every((function(e){return"string"==typeof e}))||null===this.options)&&("string"==typeof this.data||null==this.data)&&("boolean"==typeof this.isAnonymous||null===this.isAnonymous)&&("boolean"==typeof this.allowUserSuggestion||null===this.allowUserSuggestion)&&("boolean"==typeof this.allowMultipleVotes||null===this.allowMultipleVotes)&&("number"==typeof this.closeAt||null===this.closeAt)}}]),e}(),ii=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.pollId,s=void 0===i?null:i,a=t.showPartialVoters,o=void 0!==a&&a;c(this,e),this.channelUrl=r,this.pollId=s,this.showPartialVoters=o}return h(e,[{key:"_validate",value:function(){return"string"==typeof this.channelUrl&&"number"==typeof this.pollId&&"boolean"==typeof this.showPartialVoters}}]),e}(),si=function(){this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},ai=function(){this.onFriendsDiscovered=function(){},this.onTotalUnreadMessageCountUpdated=function(){}},oi=function e(){c(this,e),this.onMessageReceived=function(e,t){},this.onMessageUpdated=function(e,t){},this.onMessageDeleted=function(e,t){},this.onReadReceiptUpdated=function(e){},this.onReactionUpdated=function(e,t){},this.onDeliveryReceiptUpdated=function(e){},this.onTypingStatusUpdated=function(e){},this.onUserJoined=function(e,t){},this.onUserLeft=function(e,t){},this.onOperatorUpdated=function(e,t){},this.onUserEntered=function(e,t){},this.onUserExited=function(e,t){},this.onUserMuted=function(e,t){},this.onUserUnmuted=function(e,t){},this.onUserBanned=function(e,t){},this.onUserUnbanned=function(e,t){},this.onChannelFrozen=function(e){},this.onChannelUnfrozen=function(e){},this.onChannelChanged=function(e){},this.onChannelDeleted=function(e,t){},this.onUserReceivedInvitation=function(e,t,n){},this.onUserDeclinedInvitation=function(e,t,n){},this.onMetaDataCreated=function(e,t){},this.onMetaDataUpdated=function(e,t){},this.onMetaDataDeleted=function(e,t){},this.onMetaCountersCreated=function(e,t){},this.onMetaCountersUpdated=function(e,t){},this.onMetaCountersDeleted=function(e,t){},this.onChannelHidden=function(e){},this.onMentionReceived=function(e,t){},this.onThreadInfoUpdated=function(e,t){},this.onChannelMemberCountChanged=function(e){},this.onChannelParticipantCountChanged=function(e){},this.onPollUpdated=function(e){},this.onPollVoted=function(e){}},li=function e(t){if(c(this,e),t){var n=x.get(this._iid),r=n.User,i=n.BaseChannel;this.reader=new r(t.user),this.timestamp=parseInt(t.ts),this.channelUrl=t.hasOwnProperty("channel_url")?String(t.channel_url):"",this.channelType=t.hasOwnProperty("channel_type")?String(t.channel_type):i.CHANNEL_TYPE_GROUP}},ui=function(){function e(e,t,n){void 0===t&&(t=[]),void 0===n&&(n=0),this.key=e,this.userIds=t,this.updatedAt=n;for(var r={},i=0,s=this.userIds;i0&&"number"==typeof r?new this(t,n,r):null},e.prototype.serialize=function(){return{key:this.key,user_ids:this.userIds,updated_at:this.updatedAt}},e.prototype._applyEvent=function(e){if(e.key===this.key&&(!this._version[e.userId]||this._version[e.userId]=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}},e}(),ci=function(){function e(e){this.replyCount=0,this.mostRepliedUsers=[],this.lastRepliedAt=0,this.updatedAt=0,e&&this._update(e)}return e.objectify=function(e){var t=x.get(this._iid).User,n=e.replyCount,r=void 0===n?0:n,i=e.mostRepliedUsers,s=void 0===i?[]:i,a=e.lastRepliedAt,o=void 0===a?0:a,l=e.updatedAt,u=void 0===l?0:l,c={};return c.reply_count=r,Array.isArray(s)&&s.every((function(e){return e instanceof t}))&&(c.most_replies=s.map((function(e){return t.objectify(e)}))),c.last_replied_at=o,c.updated_at=u,c},e.build=function(e,t,n,r){return this.objectify({replyCount:e,mostRepliedUsers:t,lastRepliedAt:n,updatedAt:r})},e.prototype._update=function(e){var t=x.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"==typeof e}))&&(this.mostRepliedUsers=e.most_replies.map((function(e){return new t(e)}))),e.hasOwnProperty("last_replied_at")&&(this.lastRepliedAt=parseInt(e.last_replied_at)),e.hasOwnProperty("updated_at")&&(this.updatedAt=parseInt(e.updated_at))},e}(),di=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e&&this._update(e)}return e.objectify=function(e){var t=x.get(this._iid).OGImage,n=e.title,r=void 0===n?null:n,i=e.url,s=void 0===i?null:i,a=e.description,o=void 0===a?null:a,l=e.defaultImage,u=void 0===l?null:l,c={};return c["og:title"]=r,c["og:url"]=s,c["og:description"]=o,u&&(c["og:image"]=t.objectify(u)),c},e.prototype._update=function(e){var t=x.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 t(e["og:image"]))},e}(),hi=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,e&&this._update(e)}return e.objectify=function(e){var t=e.url,n=void 0===t?null:t,r=e.secureUrl,i=void 0===r?null:r,s=e.type,a=void 0===s?null:s,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=n,p.secure_url=i,p.type=a,p.width=l,p.height=c,p.alt=h,p},e.prototype._update=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)},e}(),pi=function(){function e(e){this.type=null,this.vendor=null,this.detail={},e&&this._update(e)}return e.objectify=function(e){var t=e.type,n=void 0===t?"":t,r=e.vendor,i=void 0===r?"":r,s=e.detail,a=void 0===s?{}:s,o={};return o.type=n,o.vendor=i,o.detail=a,o},e.prototype._update=function(e){this.type=e.hasOwnProperty("type")?e.type:"",this.vendor=e.hasOwnProperty("vendor")?e.vendor:"",e.hasOwnProperty("detail")&&"object"==typeof e.detail&&!Array.isArray(e.detail)&&(this.detail=e.detail)},e}(),fi=function(){function e(t){c(this,e),this.id=0,this.title="",this.details=null,this._update(t)}return h(e,[{key:"update",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){if(s)t(s,null);else{var r={text:e.data};U.get(n._iid).container.apiClient.updatePoll(l(l({pollId:n.id},e),{},{data:r}),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}}),t)}},{key:"delete",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=b(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.deletePoll({pollId:t.id},(function(t,n){e(t||null,null)}))}),e)}},{key:"addOption",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"string"}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.addPollOption({channelUrl:e,pollId:r.id,text:t},(function(e,t){if(e)n(e,null);else{var i=new(0,x.get(r._iid).Poll)(t);n(null,i)}}))}),n)}},{key:"vote",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.votePoll({channelUrl:e,pollId:r.id,optionIds:t},(function(e,t){if(e)n(e,null);else{var i=new(0,x.get(r._iid).Poll)(t);n(null,i)}}))}),n)}},{key:"close",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=b(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.closePoll({pollId:t.id},(function(n,r){if(n)e(n,null);else{var i=new(0,x.get(t._iid).Poll)(r);e(null,i)}}))}),e)}},{key:"_update",value:function(e){var t=x.get(this._iid).PollDetails;this.id=parseInt(e.id),this.title=e.title,e.hasOwnProperty("options")&&e.hasOwnProperty("is_anonymous")&&e.hasOwnProperty("allow_user_suggestion")&&e.hasOwnProperty("allow_multiple_votes")&&e.hasOwnProperty("close_at")&&e.hasOwnProperty("voter_count")&&e.hasOwnProperty("status")&&e.hasOwnProperty("created_by")&&e.hasOwnProperty("created_at")&&e.hasOwnProperty("updated_at")&&(this.details=new t(e))}}],[{key:"Status",get:function(){return{OPEN:"open",CLOSED:"closed",REMOVED:"removed"}}},{key:"objectify",value:function(e){var t=x.get(this._iid).PollDetails,n=e.id,r=void 0===n?0:n,i=e.title,s=void 0===i?"":i,a=e.details,o=void 0===a?null:a,u=l({},o?t.objectify(o):{});return u.id=r,u.title=s,u}},{key:"get",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollRetrievalParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.getPoll(l({},e),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}),t)}},{key:"create",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){if(s)t(s,null);else{var r={text:e.data};U.get(n._iid).container.apiClient.createPoll(l(l({},e),{},{data:r}),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}}),t)}}]),e}(),_i=function(){function e(t){c(this,e),this.options=[],this.data=null,this.isAnonymous=!1,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.closeAt=-1,this.voterCount=0,this.votedOptionIds=[],this.status="",this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._update(t)}return h(e,[{key:"_update",value:function(e){var t=x.get(this._iid).PollOption;e.hasOwnProperty("options")&&Array.isArray(e.options)&&(this.options=e.options.map((function(e){return new t(e)})));try{this.data=JSON.parse(e.data)}catch(t){this.data=e.data}this.isAnonymous=!!e.hasOwnProperty("is_anonymous")&&e.is_anonymous,this.allowUserSuggestion=!!e.hasOwnProperty("allow_user_suggestion")&&e.allow_user_suggestion,this.allowMultipleVotes=!!e.hasOwnProperty("allow_multiple_votes")&&e.allow_multiple_votes,this.closeAt=parseInt(e.close_at),this.voterCount=parseInt(e.voter_count),e.hasOwnProperty("voted_option_ids")&&Array.isArray(e.voted_option_ids)&&(this.votedOptionIds=e.voted_option_ids.map((function(e){return parseInt(e)}))),this.status=e.status,this.createdBy=e.created_by,this.createdAt=parseInt(e.created_at),this.updatedAt=parseInt(e.updated_at)}}],[{key:"objectify",value:function(e){var t=x.get(this._iid).PollOption,n=e.options,r=void 0===n?[]:n,i=e.data,s=void 0===i?null:i,a=e.isAnonymous,o=void 0!==a&&a,l=e.allowUserSuggestion,u=void 0!==l&&l,c=e.allowMultipleVotes,d=void 0!==c&&c,h=e.closeAt,p=void 0===h?-1:h,f=e.voterCount,_=void 0===f?0:f,y=e.votedOptionIds,g=void 0===y?[]:y,m=e.status,E=void 0===m?"":m,v=e.createdBy,C=void 0===v?"":v,b=e.createdAt,A=void 0===b?0:b,N=e.updatedAt,S=void 0===N?0:N,I={};return I.options=r.map((function(e){return t.objectify(e)})),I.data=JSON.stringify(s),I.is_anonymous=o,I.allow_user_suggestion=u,I.allow_multiple_votes=d,I.close_at=p,I.voter_count=_,I.voted_option_ids=g,I.status=E,I.created_by=C,I.created_at=A,I.updated_at=S,I}}]),e}(),yi=new WeakMap,gi=function(){function e(t){c(this,e),this.pollId=0,this.id=0,this.text="",this.voteCount=0,this.partialVoters=[],this.createdBy="",this.createdAt=0,this.updatedAt=0,yi.set(this,null),this._update(t)}return h(e,[{key:"lastVotedAt",get:function(){return yi.get(this)}},{key:"update",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updatePollOption({pollId:n.pollId,optionId:n.id,text:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}),t)}},{key:"delete",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=b(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.deletePollOption({pollId:t.pollId,optionId:t.id},(function(t,n){e(t||null,null)}))}),e)}},{key:"_applyEvent",value:function(e){return this.id===e.optionId&&this.lastVotedAt0&&void 0!==arguments[0]?arguments[0]:[];c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.userIds=t,this.metaDataKey="",this.metaDataValues=[],this._token=""}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0&&Array.isArray(t.userIds)&&"string"==typeof t.metaDataKey&&Array.isArray(t.metaDataValues)&&!!t.metaDataKey==t.metaDataValues.length>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadUserList(l(l({},t),{},{userIdsFilter:t.userIds,metaDataKeyFilter:t.metaDataKey,metaDataValuesFilter:t.metaDataValues,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),vi=new WeakMap,Ci=function(){function e(t){c(this,e),this.isLoading=!1,vi.set(this,t)}return h(e,[{key:"prev",value:function(e,t,n,r){var i=arguments,s=this;return oe(this._iid,(function(r){var a,o=x.get(s._iid).BaseChannel,l=b(tt.parse(i,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"function"})]),5);if(a=l[0],e=l[1],t=l[2],n=l[3],r=l[4],a)r(a,null);else if(s.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var u=vi.get(s);U.get(s._iid).container.apiClient.getMessageList({channelUrl:u.url,channelType:u.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:t,nextResultSize:0,shouldReverse:n,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return o.buildMessage(e,u)}));s.isLoading=!1,r(null,t)})).catch((function(e){s.isLoading=!1,r(e,null)}))}}),r)}},{key:"next",value:function(e,t,n,r){var i=arguments,s=this;return oe(this._iid,(function(r){var a,o=x.get(s._iid).BaseChannel,l=b(tt.parse(i,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"function"})]),5);if(a=l[0],e=l[1],t=l[2],n=l[3],r=l[4],a)r(a,null);else if(s.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var u=vi.get(s);U.get(s._iid).container.apiClient.getMessageList({channelUrl:u.url,channelType:u.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:0,nextResultSize:t,shouldReverse:n,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return o.buildMessage(e,u)}));s.isLoading=!1,r(null,t)})).catch((function(e){s.isLoading=!1,r(e,null)}))}}),r)}},{key:"load",value:function(e,t,n,r,i){var s=arguments,a=this;return oe(this._iid,(function(i){var o,l=x.get(a._iid).BaseChannel,u=b(tt.parse(s,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"callback"})]),6);if(o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],i=u[5],o)i(o,null);else if(a.isLoading)i(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var c=vi.get(a);U.get(a._iid).container.apiClient.getMessageList({channelUrl:c.url,channelType:c.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:t,nextResultSize:n,shouldReverse:r,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return l.buildMessage(e,c)}));a.isLoading=!1,i(null,t)})).catch((function(e){a.isLoading=!1,i(e,null)}))}}),i)}}]),e}(),bi=0,Ai=1,Ni=2,Si=function(){function e(t){var n=this;c(this,e),this.state=bi,this._value=null,this._reason=null;if("function"!=typeof t)throw"Promise resolver ".concat(t," is not a function");t((function(e){n.state===bi&&(n.state=Ai,n._value=e)}),(function(e){n.state===bi&&(n.state=Ni,n._reason=e)}))}return h(e,[{key:"length",get:function(){return 1}},{key:"then",value:function(t,n){var r=this,i=this;switch(this.state){case bi:setTimeout((function(){return r.then(t,n)}),100);break;case Ai:t&&"function"==typeof t&&(i=t(this._value));break;case Ni:n&&"function"==typeof n&&(i=n(this._reason))}return i instanceof e?i:this}},{key:"catch",value:function(t){var n=this,r=this;switch(this.state){case bi:setTimeout((function(){return n.catch(t)}),100);break;case Ai:break;case Ni:r=t(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(t){var n=this,r=this;switch(this.state){case bi:setTimeout((function(){return n.finally(t)}),100);break;case Ai:case Ni:r=t()}return r instanceof e?r:this}}],[{key:"all",value:function(t){return new e((function(n,r){if(Array.isArray(t)||"string"==typeof t)if(t.length>0){for(var i=[],s=0;s0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),Ii();var r=!1;if((n.newInstance||!Oi||Oi&&n.appId!==Oi.getApplicationId()&&Oi.getConnectionState()===Oi.ConnectionState.CLOSED)&&(r=!0,Oi=this),r){try{if(!n.hasOwnProperty("appId"))return J.warn("Must be set appId."),Oi=null,null}catch(e){return J.warn("Must be set appId."),Oi=null,null}var i=Vn.create();Object.defineProperty(this,"_iid",{get:function(){return i}}),Ui[i]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new nt(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:kt.MessageTypeFilter},this.GroupChannelFilter=Bn,this.MessageFilter=He,this.GroupChannelCollection={GroupChannelOrder:ze},this.MessageCollection={MessageCollectionInitPolicy:Me},this.CollectionEventSource=be,this._currentUserId=null;var s={User:It,Member:Zn,RestrictedUser:er,GroupChannel:Xn,OpenChannel:or,UserMessage:fr,FileMessage:mr,AdminMessage:Er,GroupChannelListQuery:Or,MemberListQuery:Ur,GroupChannelParams:Qr,OpenChannelParams:Wr,BaseMessageParams:hr,UserMessageParams:pr,FileMessageParams:gr,ScheduledUserMessageParams:Jr,GroupChannelTotalUnreadMessageCountParams:Xr,MessageRetrievalParams:Zr,MessageListParams:$r,ThreadedMessageListParams:ei,MessageChangeLogsParams:ti,GroupChannelChangeLogsParams:ni,PollParams:ri,PollRetrievalParams:ii,MessageMetaArray:cr,UserEventHandler:ai,SessionHandler:rt,ChannelHandler:oi,ConnectionHandler:si,AppleCriticalAlertOptions:ur,Poll:fi,PollOption:gi},a={SessionManager:it,BaseChannel:kt,BaseMessage:St,UserListQuery:Ei,ApplicationUserListQuery:Nr,BannedUserListQuery:Sr,BlockedUserListQuery:Ir,FriendListQuery:Tr,MutedUserListQuery:kr,OpenChannelListQuery:Rr,OperatorListQuery:Pr,ParticipantListQuery:wr,MessageListQuery:Ci,PreviousMessageListQuery:xr,MessageSearchQuery:Hr,PublicGroupChannelListQuery:jr,PollListQuery:Kr,PollVoterListQuery:Yr,ScheduledUserMessage:vr,ThreadInfo:ci,ThreadInfoUpdateEvent:Cr,OGMetaData:di,OGImage:hi,Plugin:pi,Command:ot,Sender:$n,ReadStatus:li,Reaction:ui,ReactionEvent:vt,Emoji:rr,EmojiCategory:nr,EmojiContainer:tr,PollDetails:_i,PollUpdateEvent:br,PollVoteEvent:Ar,RestrictionInfo:mi,FileMessageQueue:Ht},o=new x(this._iid,l(l({},s),a));this.BaseMessage={ReplyType:St.ReplyType,getMessage:o.BaseMessage.getMessage.bind(o.BaseMessage)},Object.keys(o).forEach((function(e){s[e]&&(t[e]=o[e])}));var u={encrypt:function(e){return e},decrypt:function(e){return e}};U.create(i,{appId:n.appId,pinger:new Z(this),apiClient:new ue(this),wsAdapter:new et(this),commandHandler:new Pt(this),onlineDetector:new st(this),ackStateMap:{},subscribedUnreadMessageCount:{all:0,custom_types:{},ts:0},maxUnreadCountOfSuperGroupChannel:T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,nestdb:null,currentUserId:null,localCacheEnabled:"boolean"==typeof n.localCacheEnabled&&n.localCacheEnabled,localCacheLock:new X,debugCache:!1,encryption:u,store:new kn({encryption:u}),preference:null,auth:new F,appInfo:null,pingInterval:15e3,pongTimeout:5e3,connectedAt:0,extensions:{},supportedExtensionKeys:["sb_uikit","sb_syncmanager"],getUserAgentWithExtensions:function(e){var t=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",n=e.sb_uikit?"u".concat(e.sb_uikit):"";return"JS/c".concat(T.SDK_VERSION,"/").concat(t,"/").concat(n)},sessionManager:new o.SessionManager(this),stateChangeEnabled:!0,isInBackground:!1,closedByGoingBackground:!1,isErrorFirstInCallback:!1,autoResendQueue:[],isProcessingAutoResend:!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<=Ti&&(this._websocketResponseTimeout=e)},includePollDetails:!1};var d=pe.of(i);d.addObserver({onConnect:function(){t.isCacheEnabled&&!t.getIsProcessingAutoResend()&&(0===t.getAutoResendQueue().length?Xe._processPendingMessages(t).then((function(){Xe._processNextAutoResend(t)})):Xe._processNextAutoResend(t))},onDisconnect:function(){}})}return Oi}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 U.get(this._iid).container.appInfo}},{key:"isCacheEnabled",get:function(){return U.get(this._iid).container.localCacheEnabled}},{key:"ekey",get:function(){var e=U.get(this._iid).container.auth;return e?e.eKey:""}},{key:"getApplicationId",value:function(){return U.get(this._iid).get("appId")}},{key:"getCurrentUserId",value:function(){return this.currentUser?this.currentUser.userId:null}},{key:"getDebugMode",value:function(){return ki}},{key:"setDebugMode",value:function(e){ki=e,J.mode=e?J.Mode.DEBUG:J.Mode.PRODUCTION}},{key:"getErrorFirstCallback",value:function(){return U.get(this._iid).container.isErrorFirstInCallback}},{key:"setErrorFirstCallback",value:function(e){"boolean"==typeof e&&U.get(this._iid).set("isErrorFirstInCallback",e)}},{key:"getAutoResendQueue",value:function(){return U.get(this._iid).container.autoResendQueue}},{key:"getIsProcessingAutoResend",value:function(){return U.get(this._iid).container.isProcessingAutoResend}},{key:"setIsProcessingAutoResend",value:function(e){U.get(this._iid).set("isProcessingAutoResend",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=U.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=U.get(this._iid);return this.currentUser&&e.get("auth").hasSession()}},{key:"getLastConnectedAt",value:function(){var e=U.get(this._iid);return this.getConnectionState()===this.ConnectionState.OPEN&&this.currentUser?e.get("connectedAt"):0}},{key:"getMemoryStoreForDebugging",value:function(){var e=U.get(this._iid);return e.container.debugCache&&e.container.store instanceof Nn?e.container.store:null}},{key:"useMemoryAsDatabaseForDebugging",value:function(){var e=U.get(this._iid);e.container.debugCache=!0,e.container.store=new Nn}},{key:"useAsyncStorageAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Rn({AsyncStorage:e,encryption:t.container.encryption})}},{key:"initializeDatabase",value:function(e,t){var n=this,r=U.get(this._iid),i=r.container,s=i.appId,a=i.nestdb,o=i.store,l=i.localCacheEnabled;return oe(this._iid,(function(t){if(l)if(a)t(null);else{var i=r.container.nestdb=new jn({name:"sendbird=".concat(s,"-").concat(e,".db"),version:1,store:o});i.on("upgrade",(function(e,t){switch(e){case 0:i.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[_e.NAME_ALPHABETICAL,_e.CHRONOLOGICAL,_e.LATEST_LAST_MESSAGE]},{collectionName:"SucceededMessage",keyName:"messageId",keyHash:function(e,t){return Math.floor(parseInt(e)/t)},index:[ye.LATEST]},{collectionName:"UnsentMessage",keyName:"reqId",index:[ye.LATEST_UNSENT]}]).then((function(){return t()})).catch((function(e){throw e}));break;default:t()}})),i.on("error",(function(e){return t(e)})),i.on("success",(function(){r.container.currentUserId=e,new Et({iid:n._iid,collection:i.collection("GroupChannel")}),new Ae({iid:n._iid,collections:{succeeded:i.collection("SucceededMessage"),unsent:i.collection("UnsentMessage")}}),t(null)})),i.open()}else r.container.currentUserId=e,new Et({iid:n._iid,collection:null}),new Ae({iid:n._iid,collections:{succeeded:null,unsent:null}}),t(null)}),t)}},{key:"clearDatabase",value:function(e){var t=U.get(this._iid),n=t.container.nestdb;return oe(this._iid,(function(e){if(n){var r=null;n.close(),n.reset().then((function(){t.container.nestdb=null})).catch((function(e){r=e})).finally((function(){return e(r)}))}else e(null)}),e)}},{key:"connect",value:function(e,t,n,r,i){var s=this,a=U.get(this._iid),o=a.container,l=o.wsAdapter,u=o.onlineDetector,c=o.localCacheEnabled;a.remove("firstConnectedAt"),u&&u.start();var d=null,h=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new tt({type:"callback"})]),p=b(h,6);return d=p[0],e=p[1],t=p[2],n=p[3],r=p[4],i=p[5],oe(this._iid,(function(i){if(d)i(d,null);else if(s.customApiHost=n,s.customWsHost=r,s.connecting=!0,s.reconnecting=!1,s.isReconnectingOnError=!1,s.reconnectTimer&&(clearTimeout(s.reconnectTimer),s.reconnectTimer=null,s.onReconnectTimerCancel=null),s.getConnectionState()===s.ConnectionState.OPEN&&s.currentUser&&s.currentUser.userId===e)s.connecting=!1,i(null,s.currentUser);else if(c&&(s._currentUserId=e),s.connectionCallbacks.push(i),1===s.connectionCallbacks.length){l.disconnect({clearSession:!0,err:null},null);var o=a.container,u=o.nestdb,h=o.localCacheLock;u?l.connect(e,t):h.lock((function(n){s.initializeDatabase(e).then((function(){n(),l.connect(e,t)})).catch((function(e){a.container.localCacheEnabled=!1,n(),i(e,null)}))}))}}),i)}},{key:"reconnect",value:function(){var e=this,t=U.get(this._iid).container,n=t.wsAdapter,r=t.auth,i=t.localCacheLock;if(r.sessionKey&&this.currentUser){var s=!0;return n.reconnectCount>0&&(s=!1),i.lock((function(t){n.disconnect({clearSession:!1,err:new H("Connection has been canceled.",H.CONNECTION_CANCELED)},null),n.reconnectCount=0,n.reconnect(e.currentUser.userId,s),t()})),!0}return!1}},{key:"disconnect",value:function(e){var t=this;return oe(this._iid,(function(e){var n=U.get(t._iid).container,r=n.localCacheLock,i=n.wsAdapter,s=n.onlineDetector;s&&s.stop(),r.lock((function(n){i.disconnect({clearSession:!0,err:new H("Connection has been canceled.",H.CONNECTION_CANCELED)},(function(){t.clearDatabase((function(){n(),e(null)}))}))}))}),e)}},{key:"setBackgroundState",value:function(){var e=U.get(this._iid),t=e.container,n=t.wsAdapter,r=t.stateChangeEnabled;!t.isInBackground&&r&&(e.set("isInBackground",!0),this.getConnectionState()!==this.ConnectionState.CLOSED?(e.set("closedByGoingBackground",!0),n.disconnect({clearSession:!1,err:new H("Websocket connection failed.",H.WEBSOCKET_CONNECTION_FAILED)},null),pe.of(this._iid).invokeDisconnect()):e.set("closedByGoingBackground",!1))}},{key:"isInBackground",get:function(){return U.get(this._iid).container.isInBackground}},{key:"setForegroundState",value:function(){var e=U.get(this._iid),t=e.container,n=t.wsAdapter,r=t.stateChangeEnabled,i=t.isInBackground,s=t.closedByGoingBackground;i&&r&&(e.set("isInBackground",!1),s&&this.currentUser&&n.reconnect(this.currentUser.userId,!0))}},{key:"enableStateChange",value:function(){U.get(this._iid).set("enableStateChange",!0)}},{key:"disableStateChange",value:function(){U.get(this._iid).set("enableStateChange",!1)}},{key:"addExtension",value:function(e,t){var n=U.get(this._iid).container,r=n.extensions;n.supportedExtensionKeys.indexOf(e)>-1&&(r[e]=t)}},{key:"createUserListQuery",value:function(e){return new(0,x.get(this._iid).UserListQuery)(e)}},{key:"createApplicationUserListQuery",value:function(){return new(0,x.get(this._iid).ApplicationUserListQuery)}},{key:"createBlockedUserListQuery",value:function(){return new(0,x.get(this._iid).BlockedUserListQuery)}},{key:"createFriendListQuery",value:function(){return new(0,x.get(this._iid).FriendListQuery)}},{key:"createMessageSearchQuery",value:function(e,t){return new(0,x.get(this._iid).MessageSearchQuery)(e,t)}},{key:"sendCommand",value:function(e,t){var n=this;return oe(this._iid,(function(t){n.ConnectionManager.ready((function(r,i){if(r)t(r,null);else{var s=U.get(n._iid).container,a=s.wsAdapter,o=s.ackStateMap;if(null==a||null==a.client||a.client.getConnectionState()!==n.ConnectionState.OPEN||n.getConnectionState()!==n.ConnectionState.OPEN)return void t(new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),null);if(e.isAckRequired){var l=e.requestId,u={handler:t,timer:setTimeout((function(){t(new H("Command received no ack.",H.ACK_TIMEOUT),null),delete o[l]}),n.Options.websocketResponseTimeout)};o[l]=u,a.client.send(e,(function(e){e&&(clearTimeout(u.timer),t(e,null))}))}else a.client.send(e,t)}}),!1)}),t).catch((function(e){J.error(e)}))}},{key:"setSessionHandler",value:function(e){U.get(this._iid).container.sessionManager.setHandler(e)}},{key:"addUserEventHandler",value:function(e,t){t instanceof x.get(this._iid).UserEventHandler&&(this.userEventHandlers[e]=t)}},{key:"removeUserEventHandler",value:function(e){delete this.userEventHandlers[e]}},{key:"removeAllUserEventHandler",value:function(){this.userEventHandlers={}}},{key:"addChannelHandler",value:function(e,t){t instanceof x.get(this._iid).ChannelHandler&&(this.channelHandlers[e]=t)}},{key:"removeChannelHandler",value:function(e){delete this.channelHandlers[e]}},{key:"removeAllChannelHandlers",value:function(){this.channelHandlers={}}},{key:"addConnectionHandler",value:function(e,t){t instanceof x.get(this._iid).ConnectionHandler&&(this.connectionHandlers[e]=t)}},{key:"removeConnectionHandler",value:function(e){delete this.connectionHandlers[e]}},{key:"removeAllConnectionHandlers",value:function(){this.connectionHandlers={}}},{key:"updateCurrentUserInfo",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:t},(function(i,s){var a=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),t&&(r.currentUser.plainProfileUrl=t)),a=r.currentUser),n(i,a)}))}),n)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"file",nullable:!0}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:t},(function(t,i){var s=null;t||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url)),s=r.currentUser),n(t,s)}))}),n)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateCurrentUserInfo({preferredLanguages:e},(function(r,i){var s=null;r||(n.currentUser&&e&&(n.currentUser._preferredLanguages=e),s=n.currentUser),t(r,s)}))}),t)}},{key:"registerGCMPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,n.pushTokenRegistrationState.ERROR):n.currentUser?U.get(n._iid).container.apiClient.registerGCMPushToken({token:e},(function(e,r){var i=n.pushTokenRegistrationState.ERROR;e||(n.GCMPushToken="",i=n.pushTokenRegistrationState.SUCCESS),t(e,i)})):(n.GCMPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterGCMPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):n.currentUser?U.get(n._iid).container.apiClient.unregisterGCMPushToken({token:e},(function(e,n){t(e,null)})):(n.GCMPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterGCMPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllGCMPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"registerAPNSPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,n.pushTokenRegistrationState.ERROR):n.currentUser?U.get(n._iid).container.apiClient.registerAPNSPushToken({token:e},(function(e,r){var i=n.pushTokenRegistrationState.ERROR;e||(n.APNSPushToken="",i=n.pushTokenRegistrationState.SUCCESS),t(e,i)})):(n.APNSPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):n.currentUser?U.get(n._iid).container.apiClient.unregisterAPNSPushToken({token:e},(function(e,n){t(e,null)})):(n.APNSPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllAPNSPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"unregisterPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"array",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new tt({type:"callback"})]),o=b(a,5);s=o[0],e=o[1],t=o[2],n=o[3],r=o[4];var u=x.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(s){var h=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:c,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),p=b(h,4);s=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=t,d.includeEmpty=n,d.includeFrozen=!0;return oe(this._iid,(function(t){s?t(s,null):U.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:null,token:e},d)).then((function(e){var n=x.get(i._iid).GroupChannel,r=e.updated.map((function(e){return new n(e)})),s=e.deleted,a=e.has_more,o=e.next;t(null,{updatedChannels:r,deletedChannelUrls:s,hasMore:a,token:o})})).catch((function(e){t(e,null)}))}),r)}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"array",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new tt({type:"callback"})]),o=b(a,5);s=o[0],e=o[1],t=o[2],n=o[3],r=o[4];var u=x.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(s){var h=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:c,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),p=b(h,4);s=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=t,d.includeEmpty=n,d.includeFrozen=!0;return oe(this._iid,(function(t){s?t(s,null):U.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:e,token:null},d)).then((function(e){var n=x.get(i._iid).GroupChannel,r=e.updated.map((function(e){return new n(e)})),s=e.deleted,a=e.has_more,o=e.next;t(null,{updatedChannels:r,deletedChannelUrls:s,hasMore:a,token:o})})).catch((function(e){t(e,null)}))}),r)}},{key:"getChannelInvitationPreference",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getChannelInvitationPreference({},(function(t,n){var r=null;t||(r={autoAccept:n.auto_accept}),e(t,r)}))}),e)}},{key:"setChannelInvitationPreference",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.setChannelInvitationPreference({isAutoAccept:e},(function(e,n){var r=null;e||(r={autoAccept:n.auto_accept}),t(e,r)}))}),t)}},{key:"getDoNotDisturb",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getDoNotDisturb({},(function(t,n){var r=null;t||(r={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone}),e(t,r)}))}),e)}},{key:"setDoNotDisturb",value:function(e,t,n,r,i,s,a){var o=this,l=null,u=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new tt({type:"string"}),new tt({type:"callback"})]),c=b(u,8);return l=c[0],e=c[1],t=c[2],n=c[3],r=c[4],i=c[5],s=c[6],a=c[7],oe(this._iid,(function(a){l?a(l,null):U.get(o._iid).container.apiClient.setDoNotDisturb({doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s},(function(e,t){var n=null;e||(n={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}),a(e,n)}))}),a)}},{key:"getSnoozePeriod",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getSnoozePeriod({},(function(t,n){var r=null;t||(r={isSnoozeOn:n.snooze_enabled,startTs:n.snooze_start_ts,endTs:n.snooze_end_ts}),e(t,r)}))}),e)}},{key:"setSnoozePeriod",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"number",constraint:function(e){return e>0}}),new tt({type:"number",constraint:function(e){return e>0}}),new tt({type:"callback"})]),o=b(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.setSnoozePeriod({snoozeOn:e,startTs:t,endTs:n},(function(e,t){var n=null;e||(n={isSnoozeOn:t.snooze_enabled,startTs:t.snooze_start_ts,endTs:t.snooze_end_ts}),r(e,n)}))}),r)}},{key:"blockUser",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new tt({type:"callback"})]),i=b(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.blockUserWithUserId(e.userId,t)}},{key:"blockUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.blockUser({blockedUserId:e},(function(e,n){var r=null;e||(r=new It(n)),t(e,r)}))}),t)}},{key:"unblockUser",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new tt({type:"callback"})]),i=b(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.unblockUserWithUserId(e.userId,t)}},{key:"unblockUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unblockUser({unblockedUserId:e},(function(e,n){t(e,null)}))}),t)}},{key:"getPushTriggerOption",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getPushTriggerOption({},(function(t,n){e(t,n?n.push_trigger_option:null)}))}),e)}},{key:"setPushTriggerOption",value:function(e,t){var n=this;return oe(this._iid,(function(t){Object.keys(n.PushTriggerOption).map((function(e){return n.PushTriggerOption[e]})).indexOf(e)>-1?U.get(n._iid).container.apiClient.setPushTriggerOption({pushTriggerOption:e},(function(e,n){t(e,n?n.push_trigger_option:null)})):t(tt.error,null)}),t)}},{key:"getGroupChannelCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new tt({type:"callback"})]),o=b(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.getGroupChannelCount({memberStateFilter:e},(function(e,n){var r=null;e||(r=parseInt(n.group_channel_count)),t(e,r)}))}),t)}},{key:"getTotalUnreadChannelCount",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getTotalUnreadChannelCount({},(function(t,n){var r=null;t||(r=parseInt(n.unread_count)),e(t,r)}))}),e)}},{key:"getTotalUnreadMessageCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadMessageCountParams,a=null,o=tt.parse(arguments,[new tt({type:"object",optional:!0,defaultValue:null,constraint:function(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))||e instanceof s}}),new tt({type:"callback"})]),l=b(o,3);return a=l[0],e=l[1],t=l[2],oe(this._iid,(function(t){if(a)t(a,null);else{var r=i.SuperChannelFilter.ALL;if(e instanceof s){var o=e;e=o.channelCustomTypesFilter,r=o.superChannelFilter}U.get(n._iid).container.apiClient.getTotalUnreadMessageCount({customTypesFilter:e,superChannelFilter:r},(function(e,n){var r=null;e||(r=parseInt(n.unread_count)),t(e,r)}))}}),t)}},{key:"getUnreadItemCount",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.length>0&&e.every((function(e){return Object.keys(Xn.UnreadItemKey).map((function(e){return Xn.UnreadItemKey[e]})).indexOf(e)>-1}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){if(r)t(r,null);else{var i=e.filter((function(t,n){return e.indexOf(t)===n}));U.get(n._iid).container.apiClient.getUnreadItemCount({keys:i},(function(e,n){t(e,n)}))}}),t)}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=U.get(this._iid).container.subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=U.get(this._iid).container.subscribedUnreadMessageCount;if(Object.keys(e.custom_types).length>0){var t=0;return Object.keys(e.custom_types).forEach((function(n){t+=e.custom_types[n]})),t}return 0}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){if(e&&"string"==typeof e){var t=U.get(this._iid).container.subscribedUnreadMessageCount;return t.custom_types.hasOwnProperty(e)?t.custom_types[e]:0}return 0}},{key:"getMyPushTokensByToken",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new tt({type:"callback"})]),a=b(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.getPushTokens({ts:null,token:e,type:t},(function(e,t){if(e)n(e,null);else{var r=t.type;n(null,{deviceTokens:t.device_tokens,type:r?r.toLowerCase():"unknown",hasMore:t.has_more,token:t.token})}}))}),n)}},{key:"getPushTemplate",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getPushTemplate({},(function(t,n){var r=null;t||(r=n.name.toString()),e(t,r)}))}),e)}},{key:"setPushTemplate",value:function(e,t){var n=this;return oe(this._iid,(function(t){[n.PUSH_TEMPLATE_DEFAULT,n.PUSH_TEMPLATE_ALTERNATIVE].indexOf(e)>-1?U.get(n._iid).container.apiClient.setPushTemplate({templateName:e},(function(e,n){var r=null;e||(r=n.name.toString()),t(e,r)})):t(tt.error,null)}),t)}},{key:"markAsReadAll",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).GroupChannel,r=(new Date).getTime();r-n.markAsReadAllLastSentAt<1e3?e(new H("MarkAsRead rate limit exceeded.",H.MARK_AS_READ_RATE_LIMIT_EXCEEDED),null):(n.markAsReadAllLastSentAt=r,U.get(t._iid).container.apiClient.markAsReadAll({channelUrls:null},(function(i,s){i||Object.keys(n.cachedChannels).forEach((function(e){t.currentUser&&n.cachedChannels[e].updateReadReceipt(t.currentUser.userId,r),n.cachedChannels[e]._setGroupChannelUnreadCount(0,0)})),e(i,null)})))}),e)}},{key:"markAsReadWithChannelUrls",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){if(r)t(r,null);else{var i=(new Date).getTime();U.get(n._iid).container.apiClient.markAsReadAll({channelUrls:e},(function(r,s){r||e.forEach((function(e){Xn.cachedChannels[e]&&(n.currentUser&&Xn.cachedChannels[e].updateReadReceipt(n.currentUser.userId,i),Xn.cachedChannels[e]._setGroupChannelUnreadCount(0,0))})),t(r,null)}))}}),t)}},{key:"markAsDelivered",value:function(e){"string"==typeof e&&x.get(this._iid).GroupChannel.getChannel(e,T.INTERNAL_CALL,(function(e,t){e||t.markAsDelivered()}))}},{key:"getFriendChangeLogsByToken",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getFriendChangeLogsByToken({token:e},(function(e,r){var i=null;if(!e){var s=x.get(n._iid).User;i={updatedUsers:r.updated.map((function(e){return new s(e)})),deletedUserIds:r.deleted,hasMore:r.has_more,token:r.next}}t(e,i)}))}),t)}},{key:"uploadFriendDiscoveries",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.uploadFriendDiscoveries({discoveries:e},(function(e,n){t(e,n)}))}),t)}},{key:"deleteFriendDiscovery",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),i=b(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.deleteFriendDiscoveries([e],t)}},{key:"deleteFriendDiscoveries",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteFriendDiscoveries({discoveryKeys:e},(function(e,n){t(e,n)}))}),t)}},{key:"addFriends",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.addFriends({userIds:e},(function(e,r){var i=null;if(!e){var s=x.get(n._iid).User;i=r.users.map((function(e){return new s(e)}))}t(e,i)}))}),t)}},{key:"deleteFriend",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),i=b(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.deleteFriends([e],t)}},{key:"deleteFriends",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteFriends({userIds:e},(function(e,n){t(e,n)}))}),t)}},{key:"getAllEmoji",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=b(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.getAllEmoji((function(n,r){if(n)e(n,null);else{var i=new(0,x.get(t._iid).EmojiContainer)(r);e(null,i)}}))}),e)}},{key:"getEmojiCategory",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getEmojiCategory({categoryId:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).EmojiCategory)(r);t(null,i)}}))}),t)}},{key:"getEmoji",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getEmoji({emojiKey:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Emoji)(r);t(null,i)}}))}),t)}},{key:"getAllowFriendDiscovery",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=b(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.getAllowFriendDiscovery((function(t,n){var r=n.allow_friend_discovery;t?e(t,null):e(null,r)}))}),e)}},{key:"setAllowFriendDiscovery",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"callback"})]),s=b(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.setAllowFriendDiscovery({allowFriendDiscovery:e},(function(n,r){n?t(n,null):t(null,e)}))}),t)}},{key:"clearCachedMessages",value:function(e){var t=Ae.of(this._iid);return t?Promise.all(e.map((function(e){return t.clearByChannelUrl(e)}))):Promise.resolve([])}},{key:"_getCurrentUserDataKey",value:function(){return"sendbird:".concat(this._currentUserId,"@currentUserData")}},{key:"_populateVaultFromCurrentUserData",value:function(e){var t=U.get(this._iid),n=t.container.auth,r=x.get(this._iid).User,i=e.currentUser,s=e.maxUnreadCountOfSuperGroupChannel,a=e.profileImageEncryption,o=e.sessionKey,l=e.eKey,u=e.appInfo,c=e.connectedAt,d=e.firstConnectedAt,h=e.concurrentCallLimit,p=e.backOffDelay;i&&(this.currentUser=r.buildFromSerializedData(i)),s&&t.set("maxUnreadCountOfSuperGroupChannel",s),a&&t.set("profileImageEncryption",a),n?(o&&(n.sessionKey=o),l&&(n.ekey=l)):J.debug("Auth should have been created when populating current user data."),u&&t.set("appInfo",new $e(u)),c&&t.set("connectedAt",c),d&&t.set("firstConnectedAt",d),h&&t.set("concurrentCallLimit",h),p&&t.set("backOffDelay",p)}}],[{key:"version",get:function(){return T.SDK_VERSION}},{key:"LogLevel",get:function(){return J.supportedLogLevels}},{key:"getInstance",value:function(e){return e?Ui[e]:Oi}},{key:"getLogLevel",value:function(){return J.logLevel}},{key:"setLogLevel",value:function(e){var t=Object.values(J.supportedLogLevels);if(t.includes(e))J.logLevel=e;else{J.logLevel=J.defaultLogLevel;var n=t.map((function(e){return"'".concat(e,"'")})).join(", ");J.warn("`logLevel` parameter should be one of","".concat(n,","),"not `'".concat(e,"'`."),"Set to default log level","`".concat(J.defaultLogLevel,"`."))}}}]),e}();return Ri})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("axios"),require("form-data"),require("ws")):"function"==typeof define&&define.amd?define(["axios","form-data","ws"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).SendBird=t(e.axios,e.FormData,e.WebSocket)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e),s=r(t),a=r(n);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=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 s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}var T=function(){function e(){}return Object.defineProperty(e,"OS_VERSION",{get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SDK_VERSION",{get:function(){return"3.1.2"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SDK_MAJOR_VERSION",{get:function(){return e.SDK_VERSION.split(".")[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",{get:function(){return 100},enumerable:!1,configurable:!0}),Object.defineProperty(e,"INTERNAL_CALL",{get:function(){return"ic"},enumerable:!1,configurable:!0}),e}(),O={},U=function(){function e(e){this._container=e}return e.create=function(t,n){return O[t]=new e(n),O[t]},e.get=function(e){return e||(e=ki.getInstance()._iid),O[e]},Object.defineProperty(e.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),e.prototype.get=function(e){return this._container[e]},e.prototype.set=function(e,t){this._container[e]=t},e.prototype.remove=function(e){this._container.hasOwnProperty(e)&&delete this._container[e]},e}(),k=function(e,t){return(k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}k(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var M=function(){return(M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]1?o-1:0),u=1;u-1&&(K=t)}},{key:"supportedLogLevels",get:function(){return q}},{key:"logLevel",get:function(){return z[Q]},set:function(e){z.includes(e)||(e=Y),Q=z.indexOf(e)}},{key:"defaultLogLevel",get:function(){return Y}},{key:"isDisplayableLogLevel",value:function(e){var t=z.indexOf(e);return 0<=t&&t<=Q}},{key:"log",value:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i0){var e=this._queue.shift();this.lock(e)}}}]),e}(),Z=function(){function e(t){c(this,e),this.sb=t,this.mutex=new X,this.pingTimer=null,this.pingTimeoutTimer=null}return h(e,[{key:"ping",value:function(){var e=this,t=x.get(this.sb._iid).Command.bPing(),n=U.get(this.sb._iid).container,r=n.wsAdapter,i=n.pongTimeout;r.client.send(t),J.debug("`PING`"),this.pingTimeoutTimer=setTimeout((function(){J.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,t=U.get(this.sb._iid).container.pingInterval;this.mutex.lock((function(n){e.stop(),e.pingTimer=setInterval((function(){e.ping()}),t),n()}))}},{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(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ee=function(){return"undefined"==typeof window&&"undefined"!=typeof process&&("node"===process.title||void 0!==process.versions&&process.versions.node||"[object process]"===String(process))},te=[H.CONNECTION_REQUIRED,H.NETWORK_ERROR,H.ACK_TIMEOUT,H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED,H.FILE_UPLOAD_CANCEL_FAILED,H.REQUEST_CANCELED,500901,500910,900200],ne=[H.SESSION_TOKEN_EXPIRED,H.SESSION_TOKEN_REVOKED,H.USER_DEACTIVATED,H.NON_EXISTING_USER],re=[H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED],ie=function(){function e(){}return e.deepEqual=function(e,t){if(e!==t){var n=M({},e),r=M({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},e.isResendableError=function(e){return e>0&&te.indexOf(e)>=0},e.isAutoResendableError=function(e){return e>0&&re.indexOf(e)>=0},e.isNonAutoReconnectableError=function(e){return e>0&&ne.indexOf(e)>=0},e.isFile=function(e){var t="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t)if(ee()){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 t},e}();!function(e){e.FILE="file",e.BLOB="blob"}(D||(D={}));var se=function(){function e(){}var t;return t=e,e.convertFileToDataUrl=function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){return t(r.result)},r.onerror=function(e){return n(r.error)},r.readAsDataURL(e)}))},e.convertFileToArrayBuffer=function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){return t(r.result)},r.onerror=function(e){return n(r.error)},r.readAsArrayBuffer(e)}))},e.convertDataUrlToByteArray=function(e){for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],r=atob(t[1]),i=r.length,s=new Uint8Array(i);i--;)s[i]=r.charCodeAt(i);return[s,n]},e.convertDataURLtoFile=function(e,n){var r=t.convertDataUrlToByteArray(e),i=r[0],s=r[1];return new File([i],n,{type:s})},e.convertDataURLtoBlob=function(e){var n=t.convertDataUrlToByteArray(e),r=n[0],i=n[1];return new Blob([r],{type:i})},e.convertArrayBufferToFile=function(e,t){return new File([e],t)},e.isFile=function(e){return"File"in window&&e instanceof File},e.isBlob=function(e){return"Blob"in window&&e instanceof Blob},e.convertBlobToBuffer=function(n){return P(void 0,void 0,void 0,(function(){var r;return L(t,(function(t){switch(t.label){case 0:return[4,e.convertFileToArrayBuffer(n)];case 1:return r=t.sent(),[2,Buffer.from(r)]}}))}))},e}(),ae=function(){function e(e){var t=this;this.fields={},e&&Object.keys(e).forEach((function(n){t.fields[n]={value:e[n]},ie.isFile(e[n])&&(t.fields[n].filename=e[n].name)})),this.options={},this.internal=!1,this.upload={reqId:null,deleteRequest:null,progressHandler:null}}return e.prototype.add=function(e,t,n){void 0===n&&(n=null),this.fields[e]={value:t,filename:n}},e.prototype.remove=function(e){this.fields.hasOwnProperty(e)&&delete this.fields[e]},e.prototype.yield=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,l,u,c,d,h,p=this;return L(this,(function(f){switch(f.label){case 0:for(e=!1,t=Object.keys(this.fields),n=0,r=t;n0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.noSessionKey,r=void 0!==n&&n,i=t.accessToken,a=void 0===i?null:i,o=e instanceof s.default&&"function"==typeof e.getHeaders?e.getHeaders():{},l=U.get(this.sb._iid),u=l.container,c=u.appId,d=u.auth,h=u.extensions,p=u.getUserAgentWithExtensions;return o.SendBird="JS,".concat(T.OS_VERSION,",").concat(T.SDK_VERSION,",").concat(c),o["SB-User-Agent"]=encodeURIComponent(p(h)),!r&&d.sessionKey&&(o["Session-Key"]=d.sessionKey),a&&(o["App-Id"]=c,o["Access-Token"]=a),o["Request-Sent-Timestamp"]=(new Date).getTime().toString(),o}},{key:"_createQuery",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{var n=[];return Object.keys(t).forEach((function(e){var r=t[e];if(null!=r){var i="";i="object"===u(r)?Array.isArray(r)?r.map((function(e){return encodeURIComponent("string"==typeof e?e.trim():e)})).join(","):encodeURIComponent(JSON.stringify(r)):encodeURIComponent(r),n.push("".concat(e,"=").concat(i))}})),n.length>0?"".concat(e,"?").concat(n.join("&")):e}catch(t){return J.debug("createWithEncodedGetParams is failed. - ",t),e}}},{key:"_request",value:function(e,t,n,r){var a=this;this.checkRouting((function(o,l){if(o)r(new H("Request failed.",H.REQUEST_FAILED),null);else{var u=a._buildUrl({apiHost:l.apiHost,url:t,params:n});(n?n.yield():Promise.resolve({})).then((function(o){var l=a._createHeader(o,n?n.options:{}),c=[{level:J.supportedLogLevels.DEBUG,messages:["url:",t]},{level:J.supportedLogLevels.DEBUG,messages:["data:",o]}],d=null;switch(e){case"GET":d=a._createQuery(u,o);break;case"POST":case"PUT":d=u;break;case"DELETE":d=a._createQuery(u,o)}var h=null;if("undefined"==typeof ServiceWorker||"undefined"==typeof ServiceWorkerRegistration||"undefined"!=typeof ServiceWorkerContainer||ee()||"function"!=typeof fetch)switch(e){case"GET":h=i.default.get(d,{headers:l,validateStatus:a._validateStatus});break;case"POST":var p=null;if(o instanceof s.default){var f=i.default.CancelToken.source();p=f.token;var _=a.cls.FileMessageQueue,g=n.upload.reqId;g&&(c.push({level:J.supportedLogLevels.DEBUG,messages:["request id:",g]}),_.uploadRequest[g]=f)}h=i.default.post(d,"function"==typeof o.getBuffer?o.getBuffer():o,{headers:l,validateStatus:a._validateStatus,cancelToken:p,onUploadProgress:function(e){n.upload.progressHandler&&n.upload.progressHandler(e,n.upload.reqId)}});break;case"PUT":h=i.default.put(d,o,{headers:l,validateStatus:a._validateStatus});break;case"DELETE":h=i.default.delete(d,{headers:l,validateStatus:a._validateStatus})}else{var y={method:e,headers:l};switch(e){case"GET":break;case"POST":if(o instanceof s.default){if("function"==typeof AbortController){var m=new AbortController,E=m.signal;y.signal=E;var v=a.cls.FileMessageQueue,b=n.upload.reqId;b&&(c.push({level:J.supportedLogLevels.DEBUG,messages:["request id:",b]}),v.uploadRequest[b]=m)}y.body="function"==typeof o.getBuffer?o.getBuffer():o}else l["Content-Type"]="application/json; charset=utf-8",y.body=JSON.stringify(o);break;case"PUT":o instanceof s.default?y.body="function"==typeof o.getBuffer?o.getBuffer():o:(l["Content-Type"]="application/json; charset=utf-8",y.body=JSON.stringify(o))}h=fetch(d,y).then((function(e){return e.json().then((function(t){if(!a._validateStatus(e.status))throw{request:{isAbort:!1},response:{data:t}};return Promise.resolve({data:t})}))}))}J.group("".concat(e," request"),c),c=[],h.then((function(t){try{var i=t.data;"POST"===e&&"function"==typeof n.upload.deleteRequest&&n.upload.deleteRequest(),c.push({level:J.supportedLogLevels.DEBUG,messages:["data:",i]}),r(null,i)}catch(e){throw{code:le,rawError:e}}})).catch((function(i){if(i.code===le)throw i.rawError;"POST"===e&&"function"==typeof n.upload.deleteRequest&&n.upload.deleteRequest();var s=a._handleError(i);if(c.push({level:J.supportedLogLevels.DEBUG,messages:["error:",s]}),t&&n)if(n.options&&n.options.isSessionRefresh)r(s,null);else{var o=U.get(a.sb._iid).container.sessionManager;o.isSessionError(s)?o.refreshSessionIfExpiredError(s).then((function(){return r(new H("Session is refreshed successfully.",H.SESSION_REFRESH_SUCCESS),null)})).catch((function(e){return r(new H("Session refresh failed.",H.SESSION_REFRESH_FAILED),null)})):r(s,null)}else r(s,null)})).finally((function(){return J.group("".concat(e," response"),c)}))}))}}))}},{key:"_validateStatus",value:function(e){return e>=200&&e<400}},{key:"_handleError",value:function(e){var t=e.request,n=e.response;if(t){if(t.isAbort||t.aborted)return new H("Request has been canceled.",H.REQUEST_CANCELED);if(n){var r=n.data,i=r?r.message:"Request failed.",s=r?r.code:H.REQUEST_FAILED;return new H(i,s)}return new H("Request failed.",H.REQUEST_FAILED)}return new H("There was a network error.",H.NETWORK_ERROR)}},{key:"get",value:function(e,t,n){this._request("GET",e,t,n)}},{key:"dummyCall",value:function(e){this._request("GET",null,null,e)}},{key:"post",value:function(e,t,n){this._request("POST",e,t,n)}},{key:"put",value:function(e,t,n){this._request("PUT",e,t,n)}},{key:"delete",value:function(e,t,n){this._request("DELETE",e,t,n)}},{key:"refreshSessionKey",value:function(t,n){var r=this,i=t.accessToken;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_SESSION_KEY.replace("%s",encodeURIComponent(s.userId)),o=new ae;o.options.isSessionRefresh=!0,o.options.noSessionKey=!0,o.options.accessToken=i,r.post(a,o,n)}}))}},{key:"updateCurrentUserInfo",value:function(t,n){var r=this,i=t.nickname,s=t.profileUrl,a=t.profileImage,o=t.preferredLanguages;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=e.Path.USERS_USERID.replace("%s",encodeURIComponent(l.userId)),c=new ae;i&&c.add("nickname",i),s&&c.add("profile_url",s),a&&c.add("profile_file",a,a.name),o&&c.add("preferred_languages",o),r.put(u,c,n)}}))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.ts,s=t.token,a=t.customTypes,o=t.includeEmpty,l=t.includeFrozen;r.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.USERS_USERID_MY_GROUP_CHANNEL_CHANGELOGS.replace("%s",encodeURIComponent(u.userId)),d=new ae({show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0});s&&d.add("token",s),i&&d.add("change_ts",i),a&&a.length>0&&d.add("custom_types",a),"boolean"==typeof o&&d.add("show_empty",o),"boolean"==typeof l&&d.add("show_frozen",l),r.get(c,d,n)}}))}),n)}},{key:"getChannelInvitationPreference",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"getGroupChannelCount",value:function(t,n){var r=this,i=t.memberStateFilter;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=r.cls.GroupChannel,o=e.Path.USERS_USERID_GROUP_CHANNEL_COUNT.replace("%s",encodeURIComponent(s.userId)),l="";switch(i){case a.MemberStateFilter.JOINED:l="joined";break;case a.MemberStateFilter.INVITED:l="invited";break;case a.MemberStateFilter.INVITED_BY_FRIEND:l="invited_by_friend";break;case a.MemberStateFilter.INVITED_BY_NON_FRIEND:l="invited_by_non_friend";break;default:l="all"}var u=new ae({state:l});r.get(o,u,n)}}))}},{key:"getUnreadItemCount",value:function(t,n){var r=this,i=t.keys;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_UNREAD_ITEM_COUNT.replace("%s",encodeURIComponent(s.userId)),o=new ae({item_keys:i});r.get(a,o,n)}}))}},{key:"getTotalUnreadMessageCount",value:function(t,n){var r=this,i=t.customTypesFilter,s=t.superChannelFilter;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_USERID_UNREAD_MESSAGE_COUNT.replace("%s",encodeURIComponent(a.userId)),l=new ae({super_mode:s});null!==i&&i.length>0&&l.add("custom_types",i),r.get(o,l,n)}}))}},{key:"getTotalUnreadChannelCount",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_UNREAD_CHANNEL_COUNT.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"searchMessages",value:function(t,n){var r=this,i=t.keyword,s=t.limit,a=t.reverse,o=t.exactMatch,l=t.channelUrl,u=t.channelCustomType,c=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.order,p=t.nextToken,f=t.advancedQuery,_=t.targetFields;this.sb.ConnectionManager.ready((function(t,g){if(t)n(t,null);else{var y=e.Path.SEARCH_MESSAGE,m=new ae({limit:s,reverse:a,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),_&&Array.isArray(_)&&m.add("target_fields",_),r.get(y,m,n)}}))}},{key:"markAsReadAll",value:function(t,n){var r=this,i=t.channelUrls;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_MARKASREADALL.replace("%s",encodeURIComponent(s.userId)),o=new ae;i&&o.add("channel_urls",i),r.put(a,o,n)}}))}},{key:"markAsDelivered",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MARKASDELIVERED.replace("%s",encodeURIComponent(i)),l=new ae;s&&l.add("user_id",s),r.put(o,l,n)}}))}},{key:"setChannelInvitationPreference",value:function(t,n){var r=this,i=t.isAutoAccept;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_GROUP_CHANNEL_INVITATION_PREFERENCE.replace("%s",encodeURIComponent(s.userId)),o=new ae({auto_accept:i});r.put(a,o,n)}}))}},{key:"blockUser",value:function(t,n){var r=this,i=t.blockedUserId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_BLOCK.replace("%s",encodeURIComponent(s.userId)),o=new ae({target_id:i});r.post(a,o,n)}}))}},{key:"unblockUser",value:function(t,n){var r=this,i=t.unblockedUserId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_BLOCK_TARGETID.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"getPushTriggerOption",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setPushTriggerOption",value:function(t,n){var r=this,i=t.pushTriggerOption;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(s.userId)),o=new ae({push_trigger_option:i});r.put(a,o,n)}}))}},{key:"getPushTokens",value:function(t,n){var r=this,i=t.ts,s=t.token,a=t.type;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSH_DEVICE_TOKENS.replace("%s",encodeURIComponent(o.userId)).replace("%s",encodeURIComponent(a)),u=new ae;s&&u.add("token",s),i&&u.add("created_ts",i),r.get(l,u,n)}}))}},{key:"getPushTemplate",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setPushTemplate",value:function(t,n){var r=this,i=t.templateName;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_TEMPLATE.replace("%s",encodeURIComponent(s.userId)),o=new ae({name:i});r.put(a,o,n)}}))}},{key:"getDoNotDisturb",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setDoNotDisturb",value:function(t,n){var r=this,i=t.doNotDisturbOn,s=t.startHour,a=t.startMin,o=t.endHour,l=t.endMin,u=t.timezone;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(c.userId)),h=new ae({do_not_disturb:i,start_hour:s,start_min:a,end_hour:o,end_min:l,timezone:u});r.put(d,h,n)}}))}},{key:"getSnoozePeriod",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(i.userId));r.get(s,null,n)}}))}},{key:"setSnoozePeriod",value:function(t,n){var r=this,i=t.snoozeOn,s=t.startTs,a=t.endTs;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSHPREFERENCE.replace("%s",encodeURIComponent(o.userId)),u=new ae({snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:a});r.put(l,u,n)}}))}},{key:"registerGCMPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(s.userId)),o=new ae({gcm_reg_token:i,always_push:!0});r.post(a,o,n)}}))}},{key:"unregisterGCMPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_GCM_TOKEN.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"unregisterAllGCMPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_GCM.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"registerAPNSPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(s.userId)),o=new ae({apns_device_token:i,always_push:!0});r.post(a,o,n)}}))}},{key:"unregisterAPNSPushToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSH_APNS_TOKEN.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"unregisterAllAPNSPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH_APNS.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"unregisterAllPushTokens",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_PUSH.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"loadFriendList",value:function(t,n){var r=this,i=t.token,s=t.limit;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.FRIENDS.replace("%s",encodeURIComponent(a.userId)),l=new ae({limit:s,token:i});r.get(o,l,n)}}))}},{key:"getFriendChangeLogsByToken",value:function(t,n){var r=this,i=t.token;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_CHANGE_LOGS.replace("%s",encodeURIComponent(s.userId)),o=new ae;i&&o.add("token",i),r.get(a,o,n)}}))}},{key:"addFriends",value:function(t,n){var r=this,i=t.userIds;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS.replace("%s",encodeURIComponent(s.userId)),o=new ae({user_ids:i});r.post(a,o,n)}}))}},{key:"deleteFriends",value:function(t,n){var r=this,i=t.userIds;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS.replace("%s",encodeURIComponent(s.userId)),o=new ae({user_ids:i});r.delete(a,o,n)}}))}},{key:"uploadFriendDiscoveries",value:function(t,n){var r=this,i=t.discoveries;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_DISCOVERIES.replace("%s",encodeURIComponent(s.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 ae({friend_discoveries:o});r.put(a,l,n)}}))}},{key:"deleteFriendDiscoveries",value:function(t,n){var r=this,i=t.discoveryKeys;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.FRIENDS_DISCOVERIES.replace("%s",encodeURIComponent(s.userId)),o=new ae({friend_discovery_keys:i});r.delete(a,o,n)}}))}},{key:"loadUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.userIdsFilter,o=t.metaDataKeyFilter,l=t.metaDataValuesFilter,u=t.nicknameStartsWithFilter;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.USERS,h=new ae({token:i,limit:s});a&&a.length>0&&h.add("user_ids",a),o&&l&&l.length>0&&(h.add("metadatakey",o),h.add("metadatavalues_in",l)),u&&h.add("nickname_startswith",u),r.get(d,h,n)}}))}},{key:"loadBlockedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.userIdsFilter;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_BLOCK.replace("%s",encodeURIComponent(o.userId)),u=new ae({token:i,limit:s});a&&a.length>0&&u.add("user_ids",a),r.get(l,u,n)}}))}},{key:"createUserMetaData",value:function(t,n){var r=this,i=t.metaData;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(s.userId)),o=new ae({metadata:i});r.post(a,o,n)}}))}},{key:"updateUserMetaData",value:function(t,n){var r=this,i=t.metaData,s=t.upsert;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(a.userId)),l=new ae({metadata:i,upsert:s});r.put(o,l,n)}}))}},{key:"deleteUserMetaData",value:function(t,n){var r=this,i=t.metaDataKey;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_METADATA_KEY.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"deleteAllUserMetaData",value:function(t,n){var r=this;this.sb.ConnectionManager.ready((function(t,i){if(t)n(t,null);else{var s=e.Path.USERS_USERID_METADATA.replace("%s",encodeURIComponent(i.userId));r.delete(s,null,n)}}))}},{key:"getMessageChangeLogs",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channelUrl,s=t.ts,a=t.timestamp,o=t.token,l=t.isOpenChannel,u=t.includeMetaArray,c=t.includeReaction,d=t.includeReactions,h=t.includeReplies,p=t.includeParentMessageText,f=t.includeThreadInfo,_=t.replyType,g=t.includeParentMessageInfo,y=t.includePollDetails;r.sb.ConnectionManager.ready((function(t,m){if(t)n(t,null);else{var E=l?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_CHANGELOGS.replace("%s",encodeURIComponent(i)),v=new ae;o&&v.add("token",o),s&&v.add("change_ts",s),a&&v.add("change_ts",a),"boolean"==typeof u&&v.add("with_sorted_meta_array",u),"boolean"==typeof d?v.add("include_reactions",d):v.add("include_reactions","boolean"==typeof c&&c),"boolean"==typeof f&&v.add("include_thread_info",f),"string"==typeof _?v.add("include_reply_type",_):v.add("include_reply_type","boolean"==typeof h&&h?r.cls.BaseMessage.ReplyType.ALL:r.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof g?v.add("include_parent_message_info",g):v.add("include_parent_message_info","boolean"==typeof p&&p),"boolean"==typeof y&&v.add("include_poll_details",y),r.get(E,v,n)}}))}),n)}},{key:"getMyMutedInfo",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.get(l,null,n)}}))}},{key:"loadBannedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl,o=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=o?e.Path.OPENCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_BAN.replace("%s",encodeURIComponent(a)),c=new ae({token:i,limit:s});r.get(u,c,n)}}))}},{key:"loadMutedUserList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl,o=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=o?e.Path.OPENCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MUTE.replace("%s",encodeURIComponent(a)),c=new ae({token:i,limit:s});r.get(u,c,n)}}))}},{key:"getMessageList",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channel,s=t.token,a=t.tokenType,o=t.isInclusive,l=t.prevResultSize,u=void 0===l?0:l,c=t.nextResultSize,d=void 0===c?0:c,h=t.shouldReverse,p=t.messageType,f=t.customType,_=t.customTypes,g=t.senderUserIds,y=t.includeMetaArray,m=t.includeReaction,E=t.includeReactions,v=t.includeReplies,b=t.includeParentMessageText,C=t.includeThreadInfo,A=t.replyType,N=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,I=t.includePollDetails,T=t.rootMessageId,O=t.parentMessageId;r.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var c=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",i.url),U=new ae({is_sdk:String(!0),prev_limit:String(u),next_limit:String(d),include:String(o),reverse:String(h)});"timestamp"===a?U.add("message_ts",s):"messageId"===a&&U.add("message_id",String(s)),p&&U.add("message_type",String(p)),Array.isArray(_)&&(0===_.length&&("string"==typeof f?_.push(f):_.push("*")),U.add("custom_types",_)),Array.isArray(g)&&g.length>0&&U.add("sender_ids",g),"boolean"==typeof y&&U.add("with_sorted_meta_array",y),"boolean"==typeof E?U.add("include_reactions",E):U.add("include_reactions","boolean"==typeof m&&m),"boolean"==typeof C&&U.add("include_thread_info",C),"string"==typeof A?U.add("include_reply_type",A):U.add("include_reply_type","boolean"==typeof v&&v?r.cls.BaseMessage.ReplyType.ALL:r.cls.BaseMessage.ReplyType.NONE),"boolean"==typeof N?U.add("include_parent_message_info",N):U.add("include_parent_message_info","boolean"==typeof b&&b),"boolean"==typeof S&&i.isOpenChannel()&&U.add("show_subchannel_messages_only",S),"boolean"==typeof I&&U.add("include_poll_details",I),T&&U.add("root_message_id",T),O&&U.add("parent_message_id",O),r.get(c,U,n)}}))}),n)}},{key:"checkMessageHugeGap",value:function(t,n){var r=this;return oe(this.sb._iid,(function(n){var i=t.channelUrl;t.channelType;var s=t.messageType,a=void 0===s?"":s,o=t.customTypes,l=void 0===o?["*"]:o,u=t.senderUserIds,c=void 0===u?[]:u,d=t.includeReactions,h=void 0===d||d,p=t.includeMetaArray,f=void 0!==p&&p,_=t.showSubchannelMessagesOnly,g=void 0!==_&&_,y=t.threshold,m=t.previous,E=t.next,v="".concat(e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_GAP.replace("%s",encodeURIComponent(i))),b=new ae({huge_gap_threshold:y,prev_start_ts:m.from,prev_end_ts:m.to,prev_cache_count:m.cachedCount,next_start_ts:E.from,next_end_ts:E.to,next_cache_count:E.cachedCount,reverse:!0,custom_types:l,message_type:a,include_reactions:h,with_sorted_meta_array:f,show_subchannel_messages_only:g});Array.isArray(c)&&c.length>0&&b.add("sender_ids",c),r.get(v,b,n)}),n)}},{key:"translateUserMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId,o=t.translationTargetLanguages;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_TRANSLATION.replace("%s",encodeURIComponent(i)).replace("%s",a),c=new ae({target_langs:o});r.post(u,c,n)}}))}},{key:"getMessage",value:function(t,n){var r=this,i=t.channel,s=t.messageId,a=t.includeMetaArray,o=t.includeReactions,l=t.includeParentMessageText,u=t.includeThreadInfo,c=t.includeParentMessageInfo,d=t.includePollDetails;this.sb.ConnectionManager.ready((function(t,h){if(t)n(t,null);else{var p=i.isOpenChannel()?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i.url)).replace("%s",encodeURIComponent(s)),f=new ae({is_sdk:String(!0)});"boolean"==typeof a&&f.add("with_sorted_meta_array",a),"boolean"==typeof o&&f.add("include_reactions",o),"boolean"==typeof u&&f.add("include_thread_info",u),"boolean"==typeof c?f.add("include_parent_message_info",c):f.add("include_parent_message_info","boolean"==typeof l&&l),"boolean"==typeof d&&f.add("include_poll_details",d),r.get(p,f,n)}}))}},{key:"deleteMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a));r.delete(l,null,n)}}))}},{key:"muteUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.description,o=t.seconds,l=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,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 ae({user_id:s});o&&(o>0||-1!==o)&&d.add("seconds",o),a&&d.add("description",a),r.post(c,d,n)}}))}},{key:"unmuteUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_MUTE_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,n)}}))}},{key:"banUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.description,o=t.seconds,l=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,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 ae({user_id:s});a&&d.add("description",a),d.add("seconds",String(o)),r.post(c,d,n)}}))}},{key:"unbanUser",value:function(t,n){var r=this,i=t.channelUrl,s=t.userId,a=t.isGroupChannel;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=a?e.Path.GROUPCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s)):e.Path.OPENCHANNELS_CHANNELURL_BAN_USERID.replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(s));r.delete(l,null,n)}}))}},{key:"getMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.keys;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new ae({keys:a});r.get(l,u,n)}}))}},{key:"createMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaCounter;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),u=new ae({metacounter:a});r.post(l,u,n)}}))}},{key:"updateMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaCounter,o=t.upsert,l=t.mode;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)),d=new ae({metacounter:a,upsert:o,mode:l});r.put(c,d,n)}}))}},{key:"deleteMetaCounter",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.key;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a);r.delete(l,null,n)}}))}},{key:"deleteAllMetaCounters",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=s?e.Path.OPENCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METACOUNTER.replace("%s",encodeURIComponent(i));r.delete(o,null,n)}}))}},{key:"getMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.keys;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new ae({keys:a,include_ts:!0});r.get(l,u,n)}}))}},{key:"createMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaData;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),u=new ae({metadata:a,include_ts:!0});r.post(l,u,n)}}))}},{key:"updateMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.metaData,o=t.upsert;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),c=new ae({metadata:a,upsert:o,include_ts:!0});r.put(u,c,n)}}))}},{key:"deleteMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.key;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a):e.Path.GROUPCHANNELS_CHANNELURL_METADATA_KEY.replace("%s",encodeURIComponent(i)).replace("%s",a),u=new ae({include_ts:!0});r.delete(l,u,n)}}))}},{key:"deleteAllMetaData",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=s?e.Path.OPENCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_METADATA.replace("%s",encodeURIComponent(i)),l=new ae({include_ts:!0});r.delete(o,l,n)}}))}},{key:"loadOperatorList",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.token,o=t.limit;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=s?e.Path.OPENCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_OPERATORS.replace("%s",encodeURIComponent(i)),c=new ae({token:a,limit:o});r.get(u,c,n)}}))}},{key:"getOpenChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.internalCall;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),l=new ae({});l.internal=s===T.INTERNAL_CALL,r.get(o,l,n)}}))}},{key:"loadOpenChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.nameKeyword,o=t.urlKeyword,l=t.customTypes,u=t.includeFrozen,c=t.includeMetaData;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.OPENCHANNELS,p=new ae({token:i,limit:s});a&&p.add("name_contains",a),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,n)}}))}},{key:"loadParticipantList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.channelUrl;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.OPENCHANNELS_CHANNELURL_PARTICIPANTS.replace("%s",encodeURIComponent(a)),u=new ae({token:i,limit:s});r.get(l,u,n)}}))}},{key:"createOpenChannel",value:function(t,n){var r=this,i=t.name,s=t.coverUrlOrImage,a=t.data,o=t.operatorUserIds,l=t.customType,u=t.channelUrl;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.OPENCHANNELS,h=new ae;"string"==typeof s&&h.add("cover_url",s),ie.isFile(s)&&h.add("cover_file",s),null!==u&&"string"==typeof u&&h.add("channel_url",u),null!==i&&"string"==typeof i&&h.add("name",i),a&&h.add("data",a),o&&(Array.isArray(o)?h.add("operators",o):h.add("operators",[o])),l&&h.add("custom_type",l),r.post(d,h,n)}}))}},{key:"updateOpenChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.name,a=t.coverUrlOrImage,o=t.data,l=t.operatorUserIds,u=t.customType;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),h=new ae;"string"==typeof a&&h.add("cover_url",a),ie.isFile(a)&&h.add("cover_file",a,a.name),null!==s&&"string"==typeof s&&h.add("name",s),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,n)}}))}},{key:"deleteOpenChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.OPENCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"getGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.showMember,a=t.internalCall;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i)),u=new ae({show_member:s,show_read_receipt:!0,show_delivery_receipt:!0});u.internal=a===T.INTERNAL_CALL,r.get(l,u,n)}}))}},{key:"loadGroupChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.includeEmpty,o=t.order,l=t.userIdsFilter,u=t.nicknameContainsFilter,c=t.channelNameContainsFilter,d=t.channelUrlsFilter,h=t.customTypesFilter,p=t.customTypeStartsWithFilter,f=t.memberStateFilter,_=t.superChannelFilter,g=t.publicChannelFilter,y=t.unreadChannelFilter,m=t.metadataOrderKeyFilter,E=t.metadataKey,v=t.metadataValues,b=t.metadataValueStartsWith,C=t.hiddenChannelFilter,A=t.searchFilter,N=t.includeFrozen,S=t.includeMetaData;return oe(this.sb._iid,(function(t){r.sb.ConnectionManager.ready((function(n,I){if(n)t(n,null);else{var T=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(I.userId)),O=new ae({token:i,limit:s,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(a),member_state_filter:f});h&&h.length>0&&O.add("custom_types",h),u&&O.add("members_nickname_contains",u),c&&O.add("name_contains",c),A&&A.hasOwnProperty("search_query")&&A.hasOwnProperty("search_fields")&&(O.add("search_query",A.search_query),O.add("search_fields",A.search_fields)),l&&l.userIds&&l.userIds.length>0&&(l.includeMode?(O.add("members_include_in",l.userIds),O.add("query_type",l.queryType.toUpperCase())):O.add("members_exactly_in",l.userIds)),d&&d.length>0&&O.add("channel_urls",d),O.add("super_mode",_),O.add("public_mode",g),O.add("unread_filter",y),m&&O.add("metadata_order_key",m),E&&O.add("metadata_key",E),v&&v.length>0&&O.add("metadata_values",v),b&&O.add("metadata_value_startswith",b),p&&O.add("custom_type_startswith",p),C&&O.add("hidden_mode",C),"boolean"==typeof N&&O.add("show_frozen",N),"boolean"==typeof S&&O.add("show_metadata",S),r.get(T,O,t)}}))}),n)}},{key:"loadPublicGroupChannelList",value:function(t,n){var r=this,i=t.token,s=t.limit,a=t.includeEmpty,o=t.order,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,d=t.customTypeStartsWithFilter,h=t.superChannelFilter,p=t.membershipFilter,f=t.metadataOrderKeyFilter,_=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,m=t.includeFrozen,E=t.includeMetaData;this.sb.ConnectionManager.ready((function(t,v){if(t)n(t,null);else{var b=r.cls.GroupChannel,C=e.Path.GROUPCHANNELS,A=new ae({token:i,limit:s,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:String(a),public_mode:b.PublicChannelFilter.PUBLIC,public_membership_mode:p});c&&c.length>0&&A.add("custom_types",c),l&&A.add("name_contains",l),u&&u.length>0&&A.add("channel_urls",u),A.add("super_mode",h),f&&A.add("metadata_order_key",f),_&&A.add("metadata_key",_),g&&g.length>0&&A.add("metadata_values",g),y&&A.add("metadata_value_startswith",y),d&&A.add("custom_type_startswith",d),"boolean"==typeof m&&A.add("show_frozen",m),"boolean"==typeof E&&A.add("show_metadata",E),r.get(C,A,n)}}))}},{key:"createGroupChannel",value:function(t,n){var r=this,i=t.isDistinct,s=t.isSuper,a=t.isBroadcast,o=t.isPublic,l=t.channelUrl,u=t.isDiscoverable,c=t.isStrict,d=t.name,h=t.data,p=t.customType,f=t.coverUrl,_=t.coverImage,g=t.accessCode,y=t.isEphemeral,m=t._invitedUserIds,E=void 0===m?[]:m,v=t.operatorUserIds,b=t.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(t,m){if(t)n(t,null);else{var C=e.Path.GROUPCHANNELS,N=new ae({user_ids:[m.userId].concat(A(E)).filter((function(e,t,n){return t===n.indexOf(e)}))});null!==f&&"string"==typeof f&&N.add("cover_url",f),ie.isFile(_)&&N.add("cover_file",_,_.name),null!==l&&N.add("channel_url",l),null!==i&&N.add("is_distinct",i),null!==s&&N.add("is_super",s),null!==a&&N.add("is_broadcast",a),null!==o&&N.add("is_public",o),null!==u&&N.add("is_discoverable",u),null!==c&&N.add("strict",c),null!==y&&N.add("is_ephemeral",y),g&&N.add("access_code",g),null!==d&&"string"==typeof d&&N.add("name",d),h&&N.add("data",h),p&&N.add("custom_type",p),Array.isArray(v)&&v.length>0&&N.add("operator_ids",v),null!==b&&b>-1&&N.add("message_survival_seconds",b),r.post(C,N,n)}}))}},{key:"updateGroupChannel",value:function(t,n){var r=this,i=t.isDistinct,s=t.isPublic,a=t.channelUrl,o=t.isDiscoverable,l=t.name,u=t.data,c=t.customType,d=t.coverUrl,h=t.coverImage,p=t.accessCode,f=t.operatorUserIds,_=t.messageSurvivalSeconds;this.sb.ConnectionManager.ready((function(t,g){if(t)n(t,null);else{var y=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(a)),m=new ae;null!==i&&m.add("is_distinct",i),null!==s&&m.add("is_public",s),null!==o&&m.add("is_discoverable",o),null!==p&&m.add("access_code",p),null!==d&&"string"==typeof d&&m.add("cover_url",d),ie.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!==_&&_>-1&&m.add("message_survival_seconds",_),r.put(y,m,n)}}))}},{key:"addOperators",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=void 0!==s&&s,o=t.operatorUserIds;this.sb.ConnectionManager.ready((function(t,s){if(!t){var l=(a?e.Path.OPENCHANNELS_CHANNELURL_OPERATORS:e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS).replace("%s",encodeURIComponent(i)),u=new ae({operator_ids:o});r.post(l,u,n)}}))}},{key:"removeOperators",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=void 0!==s&&s,o=t.operatorUserIds;this.sb.ConnectionManager.ready((function(t,s){if(!t){var l=(a?e.Path.OPENCHANNELS_CHANNELURL_OPERATORS:e.Path.GROUPCHANNELS_CHANNELURL_OPERATORS).replace("%s",encodeURIComponent(i)),u=new ae({operator_ids:o});r.delete(l,u,n)}}))}},{key:"inviteToGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.userIds;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_INVITE.replace("%s",encodeURIComponent(i)),l=new ae({user_ids:s});r.post(o,l,n)}}))}},{key:"acceptInvitation",value:function(t,n){var r=this,i=t.channelUrl,s=t.accessCode;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_ACCEPT_INVITATION.replace("%s",encodeURIComponent(i)),l=new ae({user_id:a.userId});s&&l.add("access_code",s),r.put(o,l,n)}}))}},{key:"declineInvitation",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_DECLINE_INVITATION.replace("%s",encodeURIComponent(i)),o=new ae({user_id:s.userId});r.put(a,o,n)}}))}},{key:"joinGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.accessCode;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.GROUPCHANNELS_CHANNELURL_JOIN.replace("%s",encodeURIComponent(i)),l=new ae({user_id:a.userId});s&&l.add("access_code",s),r.put(o,l,n)}}))}},{key:"leaveGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_LEAVE.replace("%s",encodeURIComponent(i)),o=new ae({user_id:s.userId});r.put(a,o,n)}}))}},{key:"hideGroupChannel",value:function(t,n){var r=this,i=t.channelUrl,s=t.hidePreviousMessages,a=t.allowAutoUnhide;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace("%s",encodeURIComponent(i)),u=new ae({user_id:o.userId,hide_previous_messages:s,allow_auto_unhide:a});r.put(l,u,n)}}))}},{key:"unhideGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL_HIDE.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"freeze",value:function(t,n){var r=this,i=t.channelUrl,s=t.isGroupChannel,a=t.freezing;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=s?e.Path.GROUPCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)):e.Path.OPENCHANNELS_CHANNELURL_FREEZE.replace("%s",encodeURIComponent(i)),u=new ae({freeze:a});r.put(l,u,n)}}))}},{key:"deleteGroupChannel",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_CHANNELURL.replace("%s",encodeURIComponent(i));r.delete(a,null,n)}}))}},{key:"loadMemberList",value:function(t,n){var r=this,i=t.channelUrl,s=t.token,a=t.limit,o=t.mutedMemberFilter,l=t.order,u=t.memberStateFilter,c=t.nicknameStartsWithFilter;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.GROUPCHANNELS_MEMBERS.replace("%s",encodeURIComponent(i)),p=new ae({token:s,limit:a,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,n)}}))}},{key:"report",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.reportCategory,o=t.reportingUserId,l=t.reportDescription;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.REPORT_CHANNELS.replace("%s",encodeURIComponent(s?"open_channels":"group_channels")).replace("%s",encodeURIComponent(i)),d=new ae({report_category:a});null!=o&&d.add("reporting_user_id",o),null!=l&&d.add("report_description",l),r.post(c,d,n)}}))}},{key:"reportUser",value:function(t,n){var r=this,i=t.offendingUserId,s=t.channelUrl,a=t.isOpenChannel,o=t.reportCategory,l=t.reportingUserId,u=t.reportDescription;this.sb.ConnectionManager.ready((function(t,c){if(t)n(t,null);else{var d=e.Path.REPORT_USERS.replace("%s",encodeURIComponent(i)),h=new ae({channel_url:s,channel_type:a?"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,n)}}))}},{key:"reportMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.messageId,o=t.reportCategory,l=t.reportingUserId,u=t.reportDescription,c=t.offendingUserId;this.sb.ConnectionManager.ready((function(t,d){if(t)n(t,null);else{var h=e.Path.REPORT_MESSAGES.replace("%s",encodeURIComponent(s?"open_channels":"group_channels")).replace("%s",encodeURIComponent(i)).replace("%s",encodeURIComponent(a)),p=new ae({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,n)}}))}},{key:"sendUserMessage",value:function(t,n){var r=this,i=t.channelUrl,s=t.isOpenChannel,a=t.message,o=t.data,l=t.customType,u=t.translationTargetLanguages,c=t.metaArrays,d=t.mentionType,h=t.mentionedUserIds,p=t.pushNotificationDeliveryOption,f=t.rootMessageId,_=t.parentMessageId,g=t.appleCriticalAlertOptions,y=t.pollId,m=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,E){if(t)n(t,null);else{var v=r.cls.FileMessageParams,b=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),C=new ae({message_type:"MESG",user_id:E.userId,message:a,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!==v.PushNotificationDeliveryOption.DEFAULT&&C.add("push_option",p),f&&C.add("root_message_id",f),_&&C.add("parent_message_id",_),g&&C.add("apple_critical_alert_options",g.serialize()),"number"==typeof y?C.add("poll_id",y):null===y&&C.add("poll_id",-1),m&&C.add("reply_to_channel",m),r.post(b,C,n)}}))}},{key:"sendFileMessage",value:function(t,n){var r=this,i=t.reqId,s=t.channelUrl,a=t.isOpenChannel,o=t.fileUrl,l=t.fileName,u=t.fileSize,c=t.fileType,d=t.data,h=t.customType,p=t.thumbnailSizes,f=t.requireAuth,_=t.metaArrays,g=t.mentionType,y=t.mentionedUserIds,m=t.pushNotificationDeliveryOption,E=t.rootMessageId,v=t.parentMessageId,b=t.appleCriticalAlertOptions,C=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,A){if(t)n(t,null);else{var N=r.cls.FileMessageParams,S=a?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(s)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(s)),I=new ae({message_type:"FILE",user_id:A.userId,url:o,mention_type:g,mentioned_user_ids:[],req_id:i});null!=l&&I.add("file_name",l),null!=u&&I.add("file_size",u),null!=c&&I.add("file_type",c),null!=d&&I.add("custom_field",d),null!=h&&I.add("custom_type",h),p&&I.add("thumbnails",p),f&&I.add("require_auth",f),_&&_.length>0&&I.add("sorted_metaarray",_.map((function(e){return e.encode()}))),g===r.cls.BaseMessageParams.MentionType.CHANNEL?I.add("mentioned_user_ids",[]):Array.isArray(y)&&y.length>0&&I.add("mentioned_user_ids",y),m&&m!==N.PushNotificationDeliveryOption.DEFAULT&&I.add("push_option",m),E&&I.add("root_message_id",E),v&&I.add("parent_message_id",v),b&&I.add("apple_critical_alert_options",b.serialize()),C&&I.add("reply_to_channel",C),r.post(S,I,n)}}))}},{key:"uploadFile",value:function(t,n){var r=this,i=t.file,s=t.thumbnailSizes,a=t.channelUrl,o=t.progressHandler,l=t.reqId;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=U.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 ae;if(h.add("file",i,i.name),a&&"string"==typeof a&&h.add("channel_url",a),s)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,n)}}))}},{key:"getMyPushTriggerOption",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s",encodeURIComponent(s.userId)).replace("%s",encodeURIComponent(i));r.get(a,null,n)}}))}},{key:"setMyPushTriggerOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pushTriggerOption,a=t.enable;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.USERS_USERID_PUSHPREFERENCE_CHANNELURL.replace("%s",encodeURIComponent(o.userId)).replace("%s",encodeURIComponent(i)),u=new ae;s&&u.add("push_trigger_option",s),"boolean"==typeof a&&u.add("enable",a),r.put(l,u,n)}}))}},{key:"setMyCountPreference",value:function(t,n){var r=this,i=t.channelUrl,s=t.countPreference;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.USERS_COUNT_PREFERENCE.replace("%s",encodeURIComponent(a.userId)).replace("%s",encodeURIComponent(i)),l=new ae({count_preference:s});r.put(o,l,n)}}))}},{key:"resetMyHistory",value:function(t,n){var r=this,i=t.channelUrl;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.GROUPCHANNELS_RESET_USER_HISTORY.replace("%s",encodeURIComponent(i));r.put(a,null,n)}}))}},{key:"addReaction",value:function(t,n){var r=this,i=t.isGroupChannel,s=t.channelUrl,a=t.messageId,o=t.key;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=i?e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)),c=new ae({reaction:o});r.post(u,c,n)}}))}},{key:"deleteReaction",value:function(t,n){var r=this,i=t.isGroupChannel,s=t.channelUrl,a=t.messageId,o=t.key;this.sb.ConnectionManager.ready((function(t,l){if(t)n(t,null);else{var u=i?e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)):e.Path.OPENCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION.replace("%s",encodeURIComponent(s)).replace("%s",encodeURIComponent(a)),c=new ae({reaction:o});r.delete(u,c,n)}}))}},{key:"getAllEmoji",value:function(t){var n=this;this.sb.ConnectionManager.ready((function(r,i){r?t(r,null):n.get(e.Path.EMOJI_CATEGORIES,null,t)}))}},{key:"getEmojiCategory",value:function(t,n){var r=this,i=t.categoryId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.EMOJI_CATEGORIES_CATEGORYID.replace("%s",i);r.get(a,null,n)}}))}},{key:"getEmoji",value:function(t,n){var r=this,i=t.emojiKey;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.EMOJIS_EMOJIKEY.replace("%s",i);r.get(a,null,n)}}))}},{key:"getAllowFriendDiscovery",value:function(t){var n=this;this.sb.ConnectionManager.ready((function(r,i){if(r)t(r,null);else{var s=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(i.userId));n.get(s,null,t)}}))}},{key:"setAllowFriendDiscovery",value:function(t,n){var r=this,i=t.allowFriendDiscovery;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.USERS_USERID_ALLOW_FRIEND_DISCOVERY.replace("%s",encodeURIComponent(s.userId)),o=new ae;"boolean"==typeof i&&o.add("allow_friend_discovery",i),r.put(a,o,n)}}))}},{key:"getPollList",value:function(t,n){var r=this,i=t.channelUrl,s=t.token,a=t.limit;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS,u=new ae({channel_url:i});s&&u.add("token",s),a&&u.add("limit",a),r.get(l,u,n)}}))}},{key:"getPoll",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.showPartialVoters;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID.replace("%s",s),u=new ae({channel_url:i});"boolean"==typeof a&&u.add("show_partial_voter_list",a),r.get(l,u,n)}}))}},{key:"createPoll",value:function(t,n){var r=this,i=t.title,s=t.options,a=t.data,o=t.isAnonymous,l=t.allowUserSuggestion,c=t.allowMultipleVotes,d=t.closeAt;this.sb.ConnectionManager.ready((function(t,h){if(t)n(t,null);else{var p=e.Path.POLLS,f=new ae({title:i,options:s});"object"===u(a)&&f.add("data",a),"boolean"==typeof o&&f.add("is_anonymous",o),"boolean"==typeof l&&f.add("allow_user_suggestion",l),"boolean"==typeof c&&f.add("allow_multiple_votes",c),"number"==typeof d&&f.add("close_at",d),r.post(p,f,n)}}))}},{key:"updatePoll",value:function(t,n){var r=this,i=t.pollId,s=t.title,a=t.options,o=t.data,l=t.isAnonymous,c=t.allowUserSuggestion,d=t.allowMultipleVotes,h=t.closeAt;this.sb.ConnectionManager.ready((function(t,p){if(t)n(t,null);else{var f=e.Path.POLLS_POLLID.replace("%s",i),_=new ae;"string"==typeof s&&_.add("title",s),Array.isArray(a)&&_.add("options",a),"object"===u(o)&&_.add("data",o),"boolean"==typeof l&&_.add("is_anonymous",l),"boolean"==typeof c&&_.add("allow_user_suggestion",c),"boolean"==typeof d&&_.add("allow_multiple_votes",d),"number"==typeof h&&_.add("close_at",h),r.put(f,_,n)}}))}},{key:"deletePoll",value:function(t,n){var r=this,i=t.pollId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.POLLS_POLLID.replace("%s",i);r.delete(a,null,n)}}))}},{key:"votePoll",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionIds;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_VOTE.replace("%s",s),u=new ae({channel_url:i});Array.isArray(a)&&u.add("option_ids",a),r.put(l,u,n)}}))}},{key:"closePoll",value:function(t,n){var r=this,i=t.pollId;this.sb.ConnectionManager.ready((function(t,s){if(t)n(t,null);else{var a=e.Path.POLLS_POLLID_CLOSE.replace("%s",i);r.put(a,null,n)}}))}},{key:"getPollOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionId;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",s).replace("%s",a),u=new ae({channel_url:i});r.get(l,u,n)}}))}},{key:"addPollOption",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.text;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS.replace("%s",s),u=new ae({channel_url:i,text:a});r.post(l,u,n)}}))}},{key:"updatePollOption",value:function(t,n){var r=this,i=t.pollId,s=t.optionId,a=t.text;this.sb.ConnectionManager.ready((function(t,o){if(t)n(t,null);else{var l=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",i).replace("%s",s),u=new ae({text:a});r.put(l,u,n)}}))}},{key:"deletePollOption",value:function(t,n){var r=this,i=t.pollId,s=t.optionId;this.sb.ConnectionManager.ready((function(t,a){if(t)n(t,null);else{var o=e.Path.POLLS_POLLID_OPTIONS_OPTIONID.replace("%s",i).replace("%s",s);r.delete(o,null,n)}}))}},{key:"getPollOptionVoterList",value:function(t,n){var r=this,i=t.channelUrl,s=t.pollId,a=t.optionId,o=t.token,l=t.limit;this.sb.ConnectionManager.ready((function(t,u){if(t)n(t,null);else{var c=e.Path.POLLS_POLLID_OPTIONS_OPTIONID_VOTERS.replace("%s",s).replace("%s",a),d=new ae({channel_url:i});o&&d.add("token",o),l&&d.add("limit",l),r.get(c,d,n)}}))}}],[{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_MESSAGES_GAP:"/group_channels/%s/messages_gap",GROUPCHANNELS_CHANNELURL_SCHEDULED_MESSAGES:"/group_channels/%s/scheduled_messages",GROUPCHANNELS_CHANNELURL_MEMBERS:"/group_channels/%s/members",GROUPCHANNELS_CHANNELURL_METADATA:"/group_channels/%s/metadata",GROUPCHANNELS_CHANNELURL_METADATA_KEY:"/group_channels/%s/metadata/%s",GROUPCHANNELS_CHANNELURL_METACOUNTER:"/group_channels/%s/metacounter",GROUPCHANNELS_CHANNELURL_METACOUNTER_KEY:"/group_channels/%s/metacounter/%s",GROUPCHANNELS_RESET_USER_HISTORY:"/group_channels/%s/reset_user_history",GROUPCHANNELS_OPERATORS:"/group_channels/%s/operators",GROUPCHANNELS_MEMBERS:"/group_channels/%s/members",GROUPCHANNELS_CHANNELURL_BAN:"/group_channels/%s/ban",GROUPCHANNELS_CHANNELURL_BAN_USERID:"/group_channels/%s/ban/%s",GROUPCHANNELS_CHANNELURL_MUTE:"/group_channels/%s/mute",GROUPCHANNELS_CHANNELURL_MUTE_USERID:"/group_channels/%s/mute/%s",GROUPCHANNELS_CHANNELURL_FREEZE:"/group_channels/%s/freeze",GROUPCHANNELS_CHANNELURL_MESSAGES_MESSAGEID_REACTION:"/group_channels/%s/messages/%s/reactions",STORAGE_FILE:"/storage/file",STORAGE_PROFILE:"/storage/profile_image",FRIENDS:"/users/%s/friends",FRIENDS_CHANGE_LOGS:"/users/%s/friends/changelogs",FRIENDS_DISCOVERIES:"/users/%s/friend_discoveries",SEARCH_MESSAGE:"/search/messages",REPORT_USERS:"/report/users/%s",REPORT_CHANNELS:"/report/%s/%s",REPORT_MESSAGES:"/report/%s/%s/messages/%s",EMOJIS_EMOJIKEY:"/emojis/%s",EMOJI_CATEGORIES:"/emoji_categories",EMOJI_CATEGORIES_CATEGORYID:"/emoji_categories/%s",POLLS:"/polls",POLLS_POLLID:"/polls/%s",POLLS_POLLID_VOTE:"/polls/%s/vote",POLLS_POLLID_CLOSE:"/polls/%s/close",POLLS_POLLID_OPTIONS:"/polls/%s/options",POLLS_POLLID_OPTIONS_OPTIONID:"/polls/%s/options/%s",POLLS_POLLID_OPTIONS_OPTIONID_VOTERS:"/polls/%s/options/%s/voters"}}}]),e}(),ce=function(){function e(t,n){c(this,e),this.sb=t,this.ws=null,this.wsHost=null,this.WebSocket=null,this.handler=n||new e.ConnectionHandler,this.explicitDisconnect=!1,this.lastActiveMillis=0;try{this.WebSocket="undefined"==typeof WebSocket?a.default:WebSocket}catch(e){this.WebSocket=WebSocket}}return h(e,[{key:"connect",value:function(e,t,n){var r=this;J.debug("`WebSocketClient.connect` called.");var i=U.get(this.sb._iid).container,s=i.pinger,a=i.auth,o=i.extensions,l=i.getUserAgentWithExtensions,u=i.sessionManager;this.wsHost=n;try{var c="/?p=JS&pv="+encodeURIComponent(T.OS_VERSION)+"&sv="+encodeURIComponent(T.SDK_VERSION)+"&ai="+encodeURIComponent(this.sb.getApplicationId());if(a.sessionKey?c+="&key="+encodeURIComponent(a.sessionKey):c+="&user_id="+encodeURIComponent(e)+"&access_token="+encodeURIComponent(t),c+="&active=1",c+="&SB-User-Agent="+encodeURIComponent(l(o)),c+="&Request-Sent-Timestamp="+(new Date).getTime().toString(),c+="&include_extra_data="+encodeURIComponent(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"].join(",")),u.handler&&(c+="&expiring_session=1"),this.sb.Options.includePollDetails&&(c+="&include_poll_details=1"),c+="&use_local_cache=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){J.debug("`window` object does not exist.")}var d=!1;this.ws.onopen=function(e){J.debug("`WebSocket.onopen` called."),r.handler.onOpen(e)},this.ws.onmessage=function(e){r.active();for(var t=e.data.split("\n"),n=0;n-1&&this._observers.splice(t,1)},e}(),fe=function(){},_e={NAME_ALPHABETICAL:["name","-pk"],CHRONOLOGICAL:["-createdAt","-pk"],LATEST_LAST_MESSAGE:["-lastMessageCreatedAt","-createdAt","-pk"]},ge={LATEST:["channelUrl","-createdAt","-messageId"],LATEST_UNSENT:["channelUrl","sendingStatus","createdAt"]},ye=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,i=Math.floor((n+r)/2);n0)r=i,i=Math.floor((n+r)/2);else{if(!(s<0))return i;n=i+1,i=Math.floor((n+r)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length},me=function(e){var t=e.channel,n=e.ts,r=e.prevLimit,i=void 0===r?0:r,s=e.nextLimit,a=void 0===s?0:s,o=e.filter,l={channel:t,token:n,tokenType:"timestamp",isInclusive:!0,prevResultSize:i,nextResultSize:a,shouldReverse:!1,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeReplies:!0,includeParentMessageText:!0,showSubchannelMessagesOnly:!0};if(o){var u=o.messageType,c=o.customTypes,d=o.senderUserIds;u&&(l.messageType=u),c.length>0&&(l.customTypes=c),d.length>0&&(l.senderUserIds=d)}return l},Ee=function(e,t,n){if(n.length>0){var r=n.map((function(e){return e.createdAt}));t.includes("prev")&&(e.top=Math.min.apply(Math,w([e.top],r,!1))),t.includes("next")&&(e.bottom=Math.max.apply(Math,w([e.bottom],r,!1)))}},ve=function(e){return new Promise((function(t,n){setTimeout((function(){return t()}),e)}))},be={};!function(e){e.SUCCEEDED="succeeded",e.UNSENT="unsent"}(de||(de={}));var Ce,Ae=function(){function e(e){var t=e.iid,n=e.collections;this._iid=t,this._collections=n,be[t]=this}return e.of=function(e){return be[e]},e.prototype._serialize=function(e){return e.serialize()},e.prototype._deserialize=function(e){if(e){var t=M(M({},e),{messageId:parseInt(e.messageId)}),n=x.get(this._iid),r=n.UserMessage,i=n.FileMessage,s=n.AdminMessage;if("user"===t.messageType)return r.buildFromSerializedData(t);if("file"===t.messageType)return i.buildFromSerializedData(t);if("admin"===t.messageType)return s.buildFromSerializedData(t)}return null},e.deserialize=function(e,t){if(t){var n=M(M({},t),{messageId:parseInt(t.messageId)}),r=x.get(e),i=r.UserMessage,s=r.FileMessage,a=r.AdminMessage;if("user"===n.messageType)return i.buildFromSerializedData(n);if("file"===n.messageType)return s.buildFromSerializedData(n);if("admin"===n.messageType)return a.buildFromSerializedData(n)}return null},Object.defineProperty(e.prototype,"_localCacheEnabled",{get:function(){return U.get(this._iid).get("localCacheEnabled")},enumerable:!1,configurable:!0}),e.prototype._fetch=function(e,t,n){return P(this,void 0,void 0,(function(){var r,i,s=this;return L(this,(function(a){switch(a.label){case 0:return this._localCacheEnabled?(r={where:function(r){if(!r)return!1;if(e&&r.channelUrl!==e)return!1;if(n.backward){if(r.createdAt<=n.token)return!1}else if(r.createdAt>=n.token)return!1;return!!t.match(s._deserialize(r))},index:"UnsentMessage"===n.collection.name?ge.LATEST_UNSENT:ge.LATEST,backward:n.backward},[4,n.collection.query(r)]):[3,3];case 1:return[4,a.sent().fetch({limit:n.limit})];case 2:return i=a.sent(),[2,Promise.all(i.map((function(e){return P(s,void 0,void 0,(function(){var t,r,i;return L(this,(function(s){switch(s.label){case 0:return t=this._deserialize(e),(r=e.messageParams)&&r.file?(i=t._messageParams,[4,n.collection.getBlob(r.file)]):[3,2];case 1:i._file=s.sent(),s.label=2;case 2:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},e.fetch=function(t,n,r){return P(this,void 0,void 0,(function(){var i,s,a=this;return L(this,(function(o){switch(o.label){case 0:return i={where:function(i){if(!i)return!1;if(r.backward){if(i.createdAt<=r.token)return!1}else if(i.createdAt>=r.token)return!1;return!!n.match(e.deserialize(t,i))},index:"UnsentMessage"===r.collection.name?ge.LATEST_UNSENT:ge.LATEST,backward:r.backward},[4,r.collection.query(i)];case 1:return[4,o.sent().fetch({limit:r.limit})];case 2:return s=o.sent(),[2,Promise.all(s.map((function(n){return P(a,void 0,void 0,(function(){var i,s,a;return L(this,(function(o){switch(o.label){case 0:return i=e.deserialize(t,n),(s=n.messageParams)&&s.file?(a=i._messageParams,[4,r.collection.getBlob(s.file)]):[3,2];case 1:a.file=o.sent(),o.label=2;case 2:return[2,i]}}))}))})))]}}))}))},e.prototype.get=function(e,t){return P(this,void 0,void 0,(function(){var n,r;return L(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?(n=this.getMessageCollectionByType(t),r=this._deserialize,[4,n.getByKey(e)]):[3,2];case 1:return[2,r.apply(this,[i.sent()])];case 2:return[2,null]}}))}))},e.prototype.getMessageCollectionByType=function(e){return e?this._collections[e]:this._collections.succeeded},e.prototype.getPreviousAndNextMessages=function(e,t,n,r,i){return void 0===r&&(r=30),P(this,void 0,void 0,(function(){var s,a;return L(this,(function(o){switch(o.label){case 0:return[4,this.getPreviousMessages(e,t,n,r/2,i)];case 1:return s=o.sent(),[4,this.getNextMessages(e,t,n,r/2,i)];case 2:return a=o.sent(),[2,function(e){for(var t=[],n={},r=0,i=e;ri.createdAt||i.createdAt>r)&&t.match(a._deserialize(i)))},index:ge.LATEST},[4,this.getMessageCollectionByType(i).query(s)]):[3,3];case 1:return[4,o.sent().count()];case 2:return[2,o.sent()];case 3:return[2,0]}}))}))},e.prototype.upsert=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i=this;return L(this,(function(s){switch(s.label){case 0:return this._localCacheEnabled?(n=this.getMessageCollectionByType(t),[4,Promise.all(e.map((function(e){return P(i,void 0,void 0,(function(){var t,r;return L(this,(function(i){switch(i.label){case 0:return(t=e.serialize())?((t=M({},t)).messageParams&&(t.messageParams=M({},t.messageParams)),e.sendingStatus&&"succeeded"!==e.sendingStatus?t.messageId="unsent-"+e.reqId:t.messageId=""+e.messageId,e.isFileMessage()&&e._messageParams&&e._messageParams.file?[4,n.saveBlob(e._messageParams.file,e.reqId)]:[3,2]):[3,2];case 1:r=i.sent(),t.messageParams.file=r,i.label=2;case 2:return[2,t]}}))}))})))]):[3,3];case 1:return r=s.sent(),[4,n.upsertMany(r)];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e,t){return P(this,void 0,void 0,(function(){return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return n.sent(),[4,this.getMessageCollectionByType(t).removeIf({messageId:{"/in":e.map((function(e){return""+e}))}})];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.removeUnsentMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return t=e.channelUrl,n=e.sendingStatus,r=e.reqIds,i=[],this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return o.sent(),s=this.getMessageCollectionByType(de.UNSENT),a={channelUrl:{"=":t}},n&&(a.sendingStatus={"=":n}),r&&r.length>0&&(a.reqId={"/in":r}),[4,s.removeIf(a)];case 2:i=o.sent(),o.label=3;case 3:return[2,i]}}))}))},e.prototype.removeFailedMessages=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s;return L(this,(function(a){switch(a.label){case 0:return n=[],this._localCacheEnabled?[4,ve(500)]:[3,3];case 1:return a.sent(),r=this.getMessageCollectionByType(de.UNSENT),i=ki.getInstance(this._iid),s={channelUrl:{"=":e},sendingStatus:{"=":i.MessageSendingStatus.FAILED}},t&&t.length>0&&(s.reqId={"/in":t}),[4,r.removeIf(s)];case 2:n=a.sent(),a.label=3;case 3:return[2,n]}}))}))},e.prototype.clearByChannelUrl=function(e){return P(this,void 0,void 0,(function(){var t=this;return L(this,(function(n){switch(n.label){case 0:return[4,Promise.all(Object.keys(de).map((function(n){var r=t.getMessageCollectionByType(de[n]),i={channelUrl:{"=":e}};return r.removeIf(i)})))];case 1:return n.sent(),[2]}}))}))},e.prototype.clear=function(e){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this.getMessageCollectionByType(e).clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAll=function(){return P(this,void 0,void 0,(function(){var e=this;return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,Promise.all(Object.keys(de).map((function(t){return e.clear(de[t])})))]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAbove=function(e,t){return P(this,void 0,void 0,(function(){return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?[4,this.getMessageCollectionByType(t).removeIf({createdAt:{"<":e}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},e}();!function(e){e[e.EVENT_CHANNEL_CHANGED=0]="EVENT_CHANNEL_CHANGED",e[e.EVENT_USER_RECEIVED_INVITATION=1]="EVENT_USER_RECEIVED_INVITATION",e[e.EVENT_USER_DECLINED_INVITATION=2]="EVENT_USER_DECLINED_INVITATION",e[e.EVENT_USER_JOINED=3]="EVENT_USER_JOINED",e[e.EVENT_USER_LEFT=4]="EVENT_USER_LEFT",e[e.EVENT_CHANNEL_ENTER=5]="EVENT_CHANNEL_ENTER",e[e.EVENT_CHANNEL_EXIT=6]="EVENT_CHANNEL_EXIT",e[e.EVENT_CHANNEL_FROZEN=7]="EVENT_CHANNEL_FROZEN",e[e.EVENT_CHANNEL_UNFROZEN=8]="EVENT_CHANNEL_UNFROZEN",e[e.EVENT_CHANNEL_HIDDEN=9]="EVENT_CHANNEL_HIDDEN",e[e.EVENT_CHANNEL_UNHIDDEN=10]="EVENT_CHANNEL_UNHIDDEN",e[e.EVENT_TYPING_STATUS_UPDATED=11]="EVENT_TYPING_STATUS_UPDATED",e[e.EVENT_OPERATOR_UPDATED=12]="EVENT_OPERATOR_UPDATED",e[e.EVENT_CHANNEL_METADATA_UPDATED=13]="EVENT_CHANNEL_METADATA_UPDATED",e[e.EVENT_CHANNEL_METADATA_DELETED=14]="EVENT_CHANNEL_METADATA_DELETED",e[e.EVENT_CHANNEL_METACOUNTER_UPDATED=15]="EVENT_CHANNEL_METACOUNTER_UPDATED",e[e.EVENT_CHANNEL_METACOUNTER_DELETED=16]="EVENT_CHANNEL_METACOUNTER_DELETED",e[e.EVENT_CHANNEL_DELETED=17]="EVENT_CHANNEL_DELETED",e[e.EVENT_USER_MUTED=18]="EVENT_USER_MUTED",e[e.EVENT_USER_UNMUTED=19]="EVENT_USER_UNMUTED",e[e.EVENT_USER_BANNED=20]="EVENT_USER_BANNED",e[e.EVENT_USER_UNBANNED=21]="EVENT_USER_UNBANNED",e[e.EVENT_MESSAGE_RECEIVED=22]="EVENT_MESSAGE_RECEIVED",e[e.EVENT_MESSAGE_SENT=23]="EVENT_MESSAGE_SENT",e[e.EVENT_MESSAGE_UPDATED=24]="EVENT_MESSAGE_UPDATED",e[e.EVENT_MESSAGE_DELETED=25]="EVENT_MESSAGE_DELETED",e[e.EVENT_READ_RECEIPT_UPDATED=26]="EVENT_READ_RECEIPT_UPDATED",e[e.EVENT_DELIVERY_RECEIPT_UPDATED=27]="EVENT_DELIVERY_RECEIPT_UPDATED",e[e.EVENT_MENTION=28]="EVENT_MENTION",e[e.EVENT_REACTION_UPDATED=29]="EVENT_REACTION_UPDATED",e[e.EVENT_THREAD_INFO_UPDATED=30]="EVENT_THREAD_INFO_UPDATED",e[e.CHANNEL_BACKGROUND=1e3]="CHANNEL_BACKGROUND",e[e.CHANNEL_CHANGELOG=1001]="CHANNEL_CHANGELOG",e[e.MESSAGE_BACKGROUND=1002]="MESSAGE_BACKGROUND",e[e.MESSAGE_FILL=1003]="MESSAGE_FILL",e[e.MESSAGE_CHANGELOG=1004]="MESSAGE_CHANGELOG",e[e.LOCAL_MESSAGE_PENDING_CREATED=2e3]="LOCAL_MESSAGE_PENDING_CREATED",e[e.LOCAL_MESSAGE_FAILED=2001]="LOCAL_MESSAGE_FAILED",e[e.LOCAL_MESSAGE_CANCELED=2002]="LOCAL_MESSAGE_CANCELED",e[e.LOCAL_MESSAGE_RESEND_STARTED=2003]="LOCAL_MESSAGE_RESEND_STARTED",e[e.MESSAGE_COLLECTION_FILTER_MISMATCH=2004]="MESSAGE_COLLECTION_FILTER_MISMATCH"}(Ce||(Ce={}));var Ne,Se={},Ie=function(){function e(){this._observers=[]}return e.of=function(t){return Se[t]||(Se[t]=new e),Se[t]},e.prototype.addObserver=function(e){this._observers.push(e)},e.prototype.removeObserver=function(e){var t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)},e.prototype.send=function(e){for(var t=0,n=this._observers;t0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=JSON.parse(window.localStorage[n._resolversKey]),t=n._localResolversData.map((function(e){return e.key})),r=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(n._resolversKey,JSON.stringify(r)),n._localAcquiredKeys.forEach((function(e){return n.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if($())return this.numLocks-Oe[this._holdersKey].length;var e=JSON.parse(window.localStorage[this._holdersKey]);return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return $()?Ue[this._resolversKey].length:JSON.parse(window.localStorage[this._resolversKey]).length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=JSON.parse(window.localStorage[this._resolversKey]);return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){return $()?ke[this._chainProcessStateKey]:JSON.parse(window.localStorage[this._chainProcessStateKey])},e.prototype._setProcessChainAcquireRunning=function(e){$()?ke[this._chainProcessStateKey]=e:window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e))},e.prototype._processChainResolve=function(){return P(this,void 0,void 0,(function(){var e;return L(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,(n=this._backOffDelay,P(void 0,void 0,void 0,(function(){return L(this,(function(e){return[2,new Promise((function(e){return setTimeout(e,n)}))]}))})))]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),$()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}var n}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=Ve.BACKGROUND_SYNC_CLOSE),P(this,void 0,void 0,(function(){var t,n=this;return L(this,(function(r){return $()?[2,new Promise((function(t){var r={key:Te(),resolver:function(e){return t(e)},priority:e};switch(e){case Ve.USER_CALL:case Ve.FILL:case Ve.BACKGROUND_SYNC_OPEN:for(var i=Ue[n._resolversKey],s=-1,a=0;ai[a].priority&&(s=a);if(s>=0){Ue[n._resolversKey].splice(s,0,r);break}case Ve.BACKGROUND_SYNC_CLOSE:Ue[n._resolversKey].push(r)}n._processChainResolve()}))]:(t=JSON.parse(window.localStorage[this._resolversKey]),[2,new Promise((function(r){var i=Te(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e};switch(e){case Ve.USER_CALL:case Ve.FILL:case Ve.BACKGROUND_SYNC_OPEN:for(var o=-1,l=0;lt[l].priority&&(o=l);if(o>=0){t.splice(o,0,s),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._localResolversData.splice(o,0,a);break}case Ve.BACKGROUND_SYNC_CLOSE:t.push(s),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._localResolversData.push(a)}n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(JSON.parse(window.localStorage[this._holdersKey]),$()){if((t=Oe[this._holdersKey].indexOf(e))>=0)return Oe[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else{var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=w([],n,!0);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var i=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(i),!0}}return!1},e.prototype._tryResolve=function(){if(JSON.parse(window.localStorage[this._holdersKey]),$()){if(Oe[this._holdersKey].length=2e3},enumerable:!1,configurable:!0}),e}(),De=function(){function e(e,t){this._source=e,this._sendingStatus=t}return Object.defineProperty(e.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFromEvent",{get:function(){return this._source>=2e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendingStatus",{get:function(){return this._sendingStatus},enumerable:!1,configurable:!0}),e}(),He=function(){function e(){this.messageType="",this.customTypes=[],this.senderUserIds=[],this.sendingStatus=null}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){if(this.messageType&&this.messageType!==e.messageType)return!1;if(this.customTypes.length>0&&!this.customTypes.includes(e.customType))return!1;if(this.senderUserIds.length>0){if(!e.isUserMessage()&&!e.isFileMessage())return!1;if(!this.senderUserIds.includes(e.sender.userId))return!1}return!this.sendingStatus||this.sendingStatus===e.sendingStatus},e}(),Fe=function(){function e(e){var t=e.top,n=e.bottom;this.top=t,this.bottom=n}return e.prototype.include=function(e){return this.top<=e&&e<=this.bottom},e.prototype.overlap=function(e){return this.include(e.top)||this.include(e.bottom)},e}(),Ge={},xe=function(){function e(e){var t=this,n=e.iid,r=e.channel,i=e.limit,s=void 0===i?Ye:i;this._prevSync=null,this._nextSync=null,this._syncRange=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:-1}),this._isPrevSyncComplete=!1,this._isNextSyncComplete=!1,this._iid=n,this._channel=r,this._limit=s;var a,o,l=x.get(this._iid).BaseChannel,u=U.get(this._iid),c=u.get("currentUserId"),d=u.get("store"),h=u.get("apiClient"),p=Ae.of(this._iid),f=Ie.of(this._iid),_=(a=c,o=this._channel.url,"sendbird:"+a+"@channel/"+o+"/message/sync"),g=u.container.concurrentCallLimit,y=u.container.backOffDelay;this._prevSync=new Le(_,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,a,o,u,c=this;return L(this,(function(g){switch(g.label){case 0:return e={hasNext:!0,nextParams:null},[4,d.get(_)];case 1:return(t=g.sent())&&t.isPrevSyncComplete?[3,5]:(t&&(this._syncRange=t.range,this._isPrevSyncComplete=t.isPrevSyncComplete),n=me({channel:this._channel,ts:this._syncRange.top,prevLimit:this._limit}),[4,h.getMessageList(n)]);case 2:return i=g.sent(),s=i.messages.map((function(e){return l.buildMessage(e,c._channel)})),a=this.getMinCreatedAt(s),this._syncRange.top=Math.min(this._syncRange.top,a),this._syncRange.bottom<0&&(this._syncRange.bottom=this.getMaxCreatedAt(s)),this._isPrevSyncComplete=s.lengtht&&(t=n)})),t},e}(),je={},Be=function(){function e(e){var t=this,n=e.iid,r=e.channel;this._token=0,this._sync=null,this._iid=n,this._channel=r;var i,s,a=x.get(this._iid).BaseChannel,o=U.get(this._iid),l=o.get("currentUserId"),u=o.get("store"),c=o.get("apiClient"),d=o.container.localCacheEnabled,h=Ae.of(this._iid),p=Ie.of(this._iid),f=(i=l,s=this._channel.url,"sendbird:"+i+"@channel/"+s+"/message/changelogs");this._sync=new Le(f,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,l,_,g=this;return L(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:""},d?[4,u.get(f)]:[3,2];case 1:return n=y.sent(),[3,3];case 2:n=null,y.label=3;case 3:return t=n,this._token=t?t.token:o.get("firstConnectedAt")/1e3,i={channelUrl:this._channel.url,isOpenChannel:this._channel.isOpenChannel(),includeMetaArray:!1,includeReactions:!0,includeReplies:!0,includeParentMessageText:!0,includeThreadInfo:!0},"number"==typeof this._token?i.timestamp=this._token:i.token=this._token,[4,c.getMessageChangeLogs(i)];case 4:return s=y.sent(),l={updatedMessages:s.updated.map((function(e){return a.buildMessage(e,g._channel)})),deletedMessageIds:s.deleted.map((function(e){return parseInt(e.message_id)}))},e.hasNext=s.has_more,e.nextParams=this._token=s.next,J.debug("Message collection changelog sync update messages count: ",l.updatedMessages.length),J.debug("Message collection changelog sync deleted message ids count: ",l.deletedMessageIds.length),d?[4,h.upsert(l.updatedMessages)]:[3,8];case 5:return y.sent(),[4,h.remove(l.deletedMessageIds)];case 6:return y.sent(),[4,u.set({key:f,value:{token:this._token},generation:1})];case 7:y.sent(),y.label=8;case 8:return _={source:Ce.MESSAGE_CHANGELOG,payload:M({channel:r},l)},p.send(_),[2,e]}}))}))}))}return e.of=function(t,n){return je[t]||(je[t]={}),je[t][n.url]||(je[t][n.url]=new e({iid:t,channel:n})),je[t][n.url]},e.prototype.resume=function(){J.debug("Message collection changelog sync has resumed."),this._sync.resume(null,!0)},e.prototype.pause=function(){J.debug("Message collection changelog sync has paused."),this._sync.stop()},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(Me||(Me={}));var Ve,Ke=function(){function e(){this._onCacheResult=null,this._onApiResult=null}return e.prototype.invokeCacheResult=function(e,t){this._onCacheResult(e,t)},e.prototype.invokeApiResult=function(e,t){this._onApiResult(e,t)},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),qe=function(){function e(){}return e.prototype.isNetworkConnected=function(){return!("undefined"==typeof navigator||!navigator.onLine)},e.ready=function(){return P(this,void 0,void 0,(function(){return L(this,(function(e){return"undefined"!=typeof navigator&&navigator&&"boolean"==typeof navigator.onLine?[2,navigator.onLine]:[2,new Promise((function(e,t){i.default.get("https://www.google.com").then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}();!function(e){e[e.BACKGROUND_SYNC_CLOSE=0]="BACKGROUND_SYNC_CLOSE",e[e.BACKGROUND_SYNC_OPEN=1]="BACKGROUND_SYNC_OPEN",e[e.FILL=2]="FILL",e[e.USER_CALL=3]="USER_CALL"}(Ve||(Ve={}));var ze,Ye=100,Qe=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:0}),We=new Map,Je=function(e){return"sendbird@message/fill/"+e+"/"+Te()},Xe=function(){function e(e){var t=this,n=e.iid,r=e.channel,i=e.startingPoint,s=e.filter,a=e.limit,o=void 0===a?100:a;this._hugeGapCheckTimer=null,this._messages=[],this._syncRange=new Fe(M({},Qe)),this._hasPrevious=!0,this._hasNext=!0,this._unsentMessages=[],this._iid=n,this._channel=r,this._startingPoint=i,this._filter=s,this._limit=o,this._syncLimit=Math.max(o,Ye),this._eventObserver={onevent:function(e){return P(t,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onMessagesAdded:fe,onMessagesUpdated:fe,onMessagesDeleted:fe,onChannelUpdated:fe,onChannelDeleted:fe,onHugeGapDetected:fe};var l=U.get(this._iid);this._localCacheEnabled=l.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=xe.of(this._iid,this._channel,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=Be.of(this._iid,this._channel),this._connectionObserver={onConnect:function(){t._checkHugeGap(),t._localCacheEnabled&&t._backgroundSync.resume(),t._changelogSync.resume()},onDisconnect:function(){return P(t,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,qe.ready()];case 1:return e.sent()||(this._previousFillSync.stop(),this._nextFillSync.stop(),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},this._previousFillSync=new Le(Je("prev"),(function(e){return P(t,void 0,void 0,(function(){var t,n,r;return L(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages({ts:e,prevLimit:this._syncLimit})];case 1:return(t=i.sent()).length>0?(n=Math.min.apply(Math,t.map((function(e){return e.createdAt}))),this._syncRange.top=Math.min(this._syncRange.top,n),r=new De(Ce.MESSAGE_FILL,t[0].sendingStatus),this._addMessagesToView(t,{context:r}),[2,{hasNext:t.length=n,nextParams:this._syncRange.top}]):[2,{hasNext:!1,nextParams:0}]}}))}))})),this._nextFillSync=new Le(Je("next"),(function(e){return P(t,void 0,void 0,(function(){var t,n,r;return L(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages({ts:e,nextLimit:this._syncLimit})];case 1:return(t=i.sent()).length>0?(n=Math.max.apply(Math,t.map((function(e){return e.createdAt}))),this._syncRange.bottom=Math.max(this._syncRange.bottom,n),r=new De(Ce.MESSAGE_FILL,t[0].sendingStatus),this._addMessagesToView(t,{context:r}),[2,{hasNext:t.length0){this._removeUnsentMessagesFromView([o]);var u=new De(t,o[0].sendingStatus);this._addMessagesToView(o,{context:u})}if(l&&l.length>0)if((p=this._removeMessagesFromView(l,{})).length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}}break;case Ce.LOCAL_MESSAGE_PENDING_CREATED:case Ce.LOCAL_MESSAGE_RESEND_STARTED:case Ce.LOCAL_MESSAGE_CANCELED:var c=r,d=(a=c.channel,c.message);u=new De(t,d.sendingStatus);a.url===this._channel.url&&this._upsertUnsentMessagesToView([d],{context:u});break;case Ce.EVENT_MESSAGE_SENT:var h=r;a=h.channel,d=h.message;if(a.url===this._channel.url){var p=this._removeUnsentMessagesFromView([d]);if(this._hasNext){if(p.length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,a,p)}}else{this._addMessagesToView([d],{});var u=new De(t,d.sendingStatus);p.length>0?this._eventHandler.onMessagesUpdated(u,a,[d]):this._eventHandler.onMessagesAdded(u,a,[d])}}break;case Ce.EVENT_MESSAGE_RECEIVED:var f=r;a=f.channel,d=f.message;if(a.url===this._channel.url&&!this._hasNext){u=new De(t,d.sendingStatus);this._addMessagesToView([d],{context:u})}break;case Ce.LOCAL_MESSAGE_FAILED:var _=r;a=_.channel,d=_.message;if(a.url===this._channel.url&&d.sendingStatus===i.MessageSendingStatus.FAILED){u=new De(t,d.sendingStatus);this._upsertUnsentMessagesToView([d],{context:u})}break;case Ce.EVENT_MESSAGE_UPDATED:var g=r;a=g.channel,d=g.message;if(a.url===this._channel.url){u=new De(t,d.sendingStatus);this._addMessagesToView([d],{context:u,isUpdateOnly:!0})}break;case Ce.EVENT_MESSAGE_DELETED:var y=r,m=(a=y.channel,y.messageId);if(a.url===this._channel.url)if(We.delete(m),(p=this._removeMessagesFromView([m],{})).length>0){u=new De(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}break;case Ce.EVENT_DELIVERY_RECEIPT_UPDATED:case Ce.EVENT_READ_RECEIPT_UPDATED:if((a=r.channel).isGroupChannel()){o=[];for(var E=0,v=this._messages;E0?We.set(d.messageId,T):We.delete(d.messageId))}if(o.length>0){u=new De(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}break;case Ce.EVENT_USER_LEFT:var b=U.get(this._iid),C=r,A=(a=C.channel,C.user),N=b.get("currentUserId");if(A.userId!==N){o=[];for(var S=0,I=this._messages;S0?We.set(d.messageId,T):We.delete(d.messageId))}if(o.length>0){u=new De(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}else{u=new we(t);this._eventHandler.onChannelDeleted(u,a.url)}break;case Ce.EVENT_CHANNEL_CHANGED:case Ce.EVENT_USER_RECEIVED_INVITATION:case Ce.EVENT_USER_JOINED:case Ce.EVENT_CHANNEL_FROZEN:case Ce.EVENT_CHANNEL_UNFROZEN:case Ce.EVENT_CHANNEL_HIDDEN:case Ce.EVENT_CHANNEL_UNHIDDEN:case Ce.EVENT_USER_MUTED:case Ce.EVENT_USER_UNMUTED:case Ce.EVENT_TYPING_STATUS_UPDATED:case Ce.EVENT_OPERATOR_UPDATED:case Ce.EVENT_CHANNEL_METADATA_UPDATED:case Ce.EVENT_CHANNEL_METADATA_DELETED:case Ce.EVENT_CHANNEL_METACOUNTER_UPDATED:case Ce.EVENT_CHANNEL_METACOUNTER_DELETED:a=r.channel,u=new we(t);this._eventHandler.onChannelUpdated(u,a);break;case Ce.EVENT_CHANNEL_DELETED:a=r.channel,u=new we(t);this._eventHandler.onChannelDeleted(u,a.url)}},e.prototype._createRemoteMessageParams=function(e){var t=e.prevLimit,n=void 0===t?0:t,r=e.nextLimit,i=void 0===r?0:r,s=new(0,x.get(this._iid).MessageListParams);return s.isInclusive=!0,s.prevResultSize=n,s.nextResultSize=i,s.includeMetaArray=!0,s.includeReactions=!0,s.includeThreadInfo=!0,s.includeReplies=!0,s.includeParentMessageText=!0,s},e.prototype._getRemoteMessages=function(e){var t=e.ts,n=e.prevLimit,r=void 0===n?0:n,i=e.nextLimit,s=void 0===i?0:i;return P(this,void 0,void 0,(function(){var e,n,i,a;return L(this,(function(o){switch(o.label){case 0:return e=[],r>0?(i=this._createRemoteMessageParams({prevLimit:r,nextLimit:0}),[4,this._channel.getMessagesByTimestamp(t,i)]):[3,2];case 1:n=o.sent(),e=e.concat(n),this._hasPrevious=n.length>=r,o.label=2;case 2:return s>0?(i=this._createRemoteMessageParams({prevLimit:0,nextLimit:s}),[4,this._channel.getMessagesByTimestamp(t,i)]):[3,4];case 3:a=o.sent(),e=e.concat(a),this._hasNext=a.length>=s,o.label=4;case 4:return e.length>0?[4,this._upsertRemotelyFetchedMessages(e)]:[3,6];case 5:o.sent(),o.label=6;case 6:return[2,e]}}))}))},e.prototype._upsertRemotelyFetchedMessages=function(e,t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){var n,r,i,s;return L(this,(function(a){switch(a.label){case 0:return n=t.context,r=void 0===n?null:n,i=Ae.of(this._iid),s=e.map((function(e){return e.reqId})),[4,i.removeUnsentMessages({channelUrl:this.channel.url,reqIds:s})];case 1:return a.sent(),this._removeUnsentMessagesFromView(e,{context:r}),[4,i.upsert(e,de.SUCCEEDED)];case 2:return a.sent(),this._addMessagesToView(e,{context:r}),[2]}}))}))},e.prototype._checkHugeGap=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_=this;return L(this,(function(g){switch(g.label){case 0:return g.trys.push([0,12,,13]),e=x.get(this._iid).BaseChannel,t=U.get(this._iid),n=t.get("apiClient"),this._messages.length>0?(r=Ae.of(this._iid),i={from:this._messages[0].createdAt,to:Math.min(this._syncRange.top,this._messages[this._messages.length-1].createdAt),cachedCount:0},s=i,[4,r.countBetween(this._channel.url,this._filter,i.from,i.to)]):[3,8];case 1:return s.cachedCount=g.sent(),a={from:Math.max(this._syncRange.bottom,this._messages[0].createdAt),to:this._messages[this._messages.length-1].createdAt,cachedCount:0},o=a,[4,r.countBetween(this._channel.url,this._filter,a.from,a.to)];case 2:return o.cachedCount=g.sent(),l={iid:this._iid,channelUrl:this._channel.url,channelType:this._channel.channelType,filter:this._filter,previous:i,next:a},[4,n.checkMessageHugeGap(M(M({},l),l.filter))];case 3:return u=g.sent(),(c={isHugeGap:!!u.is_huge_gap,previousMessages:u.prev_messages.map((function(t){return e.buildMessage(t,_._channel)}))||[],previousHasMore:!!u.prev_hasmore,nextMessages:u.next_messages.map((function(t){return e.buildMessage(t,_._channel)}))||[],nextHasMore:!!u.next_hasmore}).isHugeGap?[3,6]:(h=w(w([],c.previousMessages,!0),c.nextMessages,!0),J.debug("Message collection non-huge gap message fill count: ",h.length),h.length>0?(p=new De(Ce.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,5]);case 4:g.sent(),this._extendSyncRange(["prev"],c.previousMessages),this._extendSyncRange(["next"],c.nextMessages),c.previousHasMore&&this._previousFillSync.run(this._syncRange.top),c.nextHasMore&&this._nextFillSync.run(this._syncRange.bottom),g.label=5;case 5:return[3,7];case 6:setTimeout((function(){return _._eventHandler.onHugeGapDetected()}),10),g.label=7;case 7:return[3,11];case 8:return d=Math.floor(this._syncLimit/2),[4,this._getRemoteMessages({ts:this._startingPoint,prevLimit:d,nextLimit:d})];case 9:return(h=g.sent()).length>0?(p=new De(Ce.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,11];case 10:g.sent(),this._extendSyncRange(["prev","next"],this._messages),g.label=11;case 11:return[3,13];case 12:return f=g.sent(),J.warn("Message collection huge gap checker error: ",f),this._hugeGapCheckTimer=setTimeout((function(){_._hugeGapCheckTimer=null,_._checkHugeGap()}),3e3),[3,13];case 13:return[2]}}))}))},e.prototype._extendSyncRange=function(e,t){if(t.length>0){var n=t.map((function(e){return e.createdAt}));e.includes("prev")&&(this._syncRange.top=Math.min.apply(Math,w([this._syncRange.top],n,!1))),e.includes("next")&&(this._syncRange.bottom=Math.max.apply(Math,w([this._syncRange.bottom],n,!1)))}},e.prototype._addMessagesToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=t.isUpdateOnly,s=void 0!==i&&i,a=[],o=[],l=[],u=0,c=e;u=0)o.push(d),this._messages[h]=d;else if(!s){var f=ye(this._messages,d);a.push(d),this._messages.splice(f,0,d)}}else h>=0&&(l.push(d),this._messages.splice(h,1))}r&&(a.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,a),o.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,o),l.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,l))},e.prototype._removeMessagesFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0){var u=this._messages[l];i.push(u),this._messages.splice(l,1)}}return r&&i.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,i),i},e.prototype._upsertUnsentMessagesToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=[],a=[],o=0,l=e;o=0)s.push(u),this._unsentMessages[c]=u;else{var d=ye(this._unsentMessages,u);i.push(u),this._unsentMessages.splice(d,0,u)}else c>=0&&(this._unsentMessages.splice(c,1),a.push(u))}r&&(i.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,i),s.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,s),a.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,a))},e.prototype._removeUnsentMessagesFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0){var u=this._unsentMessages[l];i.push(u),this._unsentMessages.splice(l,1)}}return r&&i.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,i),i},e.prototype._removeFailedMessagesFromView=function(e){var t=ki.getInstance(this._iid),n=[],r=[],i=this._unsentMessages.map((function(e){return e.reqId}));if(e)for(var s=0,a=e;s=0&&this._unsentMessages[l].sendingStatus===t.MessageSendingStatus.FAILED?n.push(this._unsentMessages[l]):r.push(this._unsentMessages[l])}else for(var u=0,c=this._unsentMessages;u0){e.getIsProcessingAutoResend()||(J.debug("Auto-resend queue started."),e.setIsProcessingAutoResend(!0));var n=t[0];J.debug("Processing auto-resend for message request id: ",n.reqId),x.get(e._iid).GroupChannel.getChannel(n.channelUrl,T.INTERNAL_CALL,(function(t,r){var i;if(e.getErrorFirstCallback()&&(r=(i=[t,r])[0],t=i[1]),r)throw r;n.isUserMessage()?t._autoResendUserMessage(n):n.isFileMessage()&&t._autoResendFileMessage(n)}))}else J.debug("Auto-resend queue finished."),e.setIsProcessingAutoResend(!1)}catch(t){J.warn("Process auto-resend error: ",t),e.setIsProcessingAutoResend(!1)}},e._completeCurrentAndProcessNextAutoResend=function(e,t){if(e.isCacheEnabled&&t._isAutoResendRegistered){var n=e.getAutoResendQueue();if(t.sendingStatus===e.MessageSendingStatus.SUCCEEDED||t.sendingStatus===e.MessageSendingStatus.FAILED&&!ie.isAutoResendableError(t.errorCode))n.length>0&&t.reqId===n[0].reqId&&(n.shift(),this._processNextAutoResend(e));else if(t.sendingStatus===e.MessageSendingStatus.PENDING){if(n.length>0&&n.map((function(e){return e.reqId})).indexOf(t.reqId)>-1)return;n.push(t),!e.getIsProcessingAutoResend()&&n.length>0&&this._processNextAutoResend(e)}}},e._processPendingMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p,f,_;return L(this,(function(g){switch(g.label){case 0:return t=Ae.of(e._iid),n=Ie.of(e._iid),r=U.get(e._iid),(i=new He).sendingStatus=e.MessageSendingStatus.PENDING,s=r.container.nestdb,a=s.collection("UnsentMessage"),[4,t.getAllUnsentMessages(i,a)];case 1:o=g.sent(),l=0,u=o,g.label=2;case 2:return l0?Math.min.apply(Math,this._messages.map((function(e){return e.createdAt}))):Number.MAX_SAFE_INTEGER,[4,qe.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadPrevious() from the cache."),[4,Ae.of(this._iid).getPreviousMessages(this._channel.url,this._filter,e,this._limit)]);case 2:return t=n.sent(),this._addMessagesToView(t),[2,t];case 3:return J.debug("Message collection loadPrevious() from the server."),[4,this._getRemoteMessages({ts:e,prevLimit:this._limit})];case 4:return t=n.sent(),this._addMessagesToView(t),Ee(this._syncRange,["prev"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return P(this,void 0,void 0,(function(){var e,t;return L(this,(function(n){switch(n.label){case 0:return this._hasNext?(e=this._messages.length>0?Math.max.apply(Math,this._messages.map((function(e){return e.createdAt}))):0,[4,qe.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadNext() from the cache."),[4,Ae.of(this._iid).getNextMessages(this._channel.url,this._filter,e,this._limit)]);case 2:return t=n.sent(),this._addMessagesToView(t),[2,t];case 3:return J.debug("Message collection loadNext() from the server."),[4,this._getRemoteMessages({ts:e,nextLimit:this._limit})];case 4:return t=n.sent(),this._addMessagesToView(t),Ee(this._syncRange,["next"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.removeFailedMessages=function(e){return P(this,void 0,void 0,(function(){var t,n,r,i;return L(this,(function(s){switch(s.label){case 0:return t=ki.getInstance(this._iid),n=Ae.of(this._iid),r=e.map((function(e){return e.reqId})),[4,n.removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:t.MessageSendingStatus.FAILED,reqIds:r})];case 1:return i=s.sent(),this._removeFailedMessagesFromView(e),[2,i]}}))}))},e.prototype.removeAllFailedMessages=function(){return P(this,void 0,void 0,(function(){var e;return L(this,(function(t){switch(t.label){case 0:return e=ki.getInstance(this._iid),[4,Ae.of(this._iid).removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:e.MessageSendingStatus.FAILED})];case 1:return t.sent(),this._removeFailedMessagesFromView(),[2]}}))}))},e.prototype.dispose=function(){this._localCacheEnabled&&(this._previousFillSync.stop(),this._nextFillSync.stop(),this._backgroundSync.pause()),this._changelogSync.pause(),pe.of(this._iid).removeObserver(this._connectionObserver),this._hugeGapCheckTimer&&(clearTimeout(this._hugeGapCheckTimer),this._hugeGapCheckTimer=null),Ie.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setMessageCollectionHandler=function(e){this._eventHandler=e},e}(),Ze=1048576,$e=function(){function e(e){void 0===e&&(e={}),this._emojiHash=e.emoji_hash||"",this._uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ze:Number.MAX_VALUE,this._useReaction=!!e.use_reaction,this._applicationAttributes=e.application_attributes||[],this._premiumFeatureList=e.premium_feature_list||[],this._disableSupergroupMack=e.disable_supergroup_mack||!1}return Object.defineProperty(e.prototype,"emojiHash",{get:function(){return this._emojiHash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uploadSizeLimit",{get:function(){return this._uploadSizeLimit},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingReaction",{get:function(){return this._useReaction},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"applicationAttributes",{get:function(){return this._applicationAttributes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"premiumFeatureList",{get:function(){return this._premiumFeatureList},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSupergroupMackDisabled",{get:function(){return this._disableSupergroupMack},enumerable:!1,configurable:!0}),e.prototype._objectify=function(){var e={};return e.emoji_hash=this._emojiHash,this._uploadSizeLimit!==Number.MAX_VALUE&&(e.file_upload_size_limit=this._uploadSizeLimit/Ze),e.use_reaction=this._useReaction,e.application_attributes=this._applicationAttributes,e.premium_feature_list=this._premiumFeatureList,e.disable_supergroup_mack=this._disableSupergroupMack,e},e}(),et=function(){function e(t){c(this,e),this.sb=t,this.cls=x.get(this.sb._iid),this.client=new ce(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,t){var n=this,r=U.get(this.sb._iid).container,i=r.auth,s=r.apiClient,a=r.commandHandler;i.sessionToken=t||null;var o=this.cls.GroupChannel,l=null,u=new ce.ConnectionHandler;this.client=new ce(this.sb,u),u.onMessage=function(e){a.onRawCommandReceived(e)},this.sb.loginHandler=function(e,t){if(n.sb.connecting=!1,n.sb.reconnecting=!1,e)n.disconnect({clearSession:!0,err:e},null);else{clearInterval(n.sb.globalTimer);var r=function(){o.cachedChannels&&Object.keys(o.cachedChannels).forEach((function(e){var t=o.cachedChannels[e];t.invalidateTypingStatus()&&Object.keys(n.sb.channelHandlers).forEach((function(e){n.sb.channelHandlers[e].onTypingStatusUpdated(t)}))}))};r(),n.sb.globalTimer=setInterval((function(){return r()}),1e3),n.flushConnectionCallbacks(null,t),n.sb.ConnectionManager.processAllReadyHandler(null)}},u.onOpen=function(){n.connectCount=0,n.sb.loginTimer=setTimeout((function(){n.sb.loginTimer=null,n.sb.onLoginTimerCancel=null,n.flushConnectionCallbacks(new H("Connection timeout.",H.LOGIN_TIMEOUT),null),n.sb.disconnect(null)}),n.sb.Options.websocketResponseTimeout),n.sb.onLoginTimerCancel=function(){n.connectCount=0,n.flushConnectionCallbacks(new H("Connection has been canceled.",H.REQUEST_FAILED),null)},n.sb.connecting=!1},u.onError=function(r){J.debug("Connect: `WebSocketClient.ConnectionHandler.onError` called.",r),i.sessionKey?(n.sb.isReconnectingOnError=!0,n.sb.ConnectionManager.errorAllReadyHandler(),n.reconnect(e,!0),n.sb.connecting=!1):n.connectCount1&&void 0!==arguments[1])||arguments[1],r=U.get(this.sb._iid),i=r.container,s=i.auth,a=i.apiClient,o=i.commandHandler,l=i.ackStateMap,u=i.sessionManager,c=this.cls.OpenChannel;if(this.sb.connecting=!1,this.sb.reconnecting=!0,this.sb.reconnectTimer)J.debug("Reconnect: still reconnecting.");else{if(this.reconnectCount+=1,this.reconnectCount<=1){if(n){Object.keys(l).forEach((function(e){var t=l[e];t&&(clearTimeout(t.timer),(0,t.handler)(new H("Command received no ack.",H.ACK_TIMEOUT),null));delete l[e]}));var d=pe.of(this.sb._iid);d.invokeDisconnect(),Object.keys(this.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].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||!s.sessionKey||this.reconnectParams.retryCount>0&&this.reconnectCount>this.reconnectParams.retryCount)return this.disconnect({clearSession:!1,err:new H("Websocket connection failed.",H.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,Object.keys(this.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].onReconnectFailed()})),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1,void this.sb.ConnectionManager.errorAllReadyHandler();this.sb.onReconnectTimerCancel=function(){t.reconnectCount=0},this.sb.reconnectTimer=setTimeout((function(){t.sb.reconnectTimer=null,t.sb.onReconnectTimerCancel=null,t.client&&t.client.disconnect(!0);var n=new ce.ConnectionHandler;t.client=new ce(t.sb,n),t.sb.loginHandler=function(n,r){n?u.isSessionError(n)?u.refreshSessionIfExpiredError(n).then((function(){clearTimeout(t.sb.reconnectTimer),t.sb.reconnectTimer=null,t.reconnectCount=0,t.reconnect(e,!1)})).catch((function(){})):(clearTimeout(t.sb.reconnectTimer),t.sb.reconnectTimer=null,t.reconnect(e,!1)):(t.reconnectCount=0,t.sb.connecting=!1,t.sb.reconnecting=!1,t.sb.isReconnectingOnError=!1,pe.of(t.sb._iid).invokeConnect(),Object.keys(t.sb.connectionHandlers).forEach((function(e){t.sb.connectionHandlers[e].onReconnectSucceeded()})),t.sb.ConnectionManager.processAllReadyHandler(null),t.sb.isReconnectingOnError&&Object.keys(t.sb.ConnectionManager.networkHandlers).forEach((function(e){t.sb.ConnectionManager.networkHandlers[e].onReconnected()})),Object.keys(c.enteredChannels).forEach((function(e){c.enteredChannels[e].enter((function(n,r){if(n){var i=t.cls.FileMessageQueue;delete c.enteredChannels[e],i.delete(e)}}))})))},n.onOpen=function(){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),t.sb.loginTimer=setTimeout((function(){J.debug("Reconnect: `loginTimer` timeout."),t.sb.loginTimer=null,t.reconnect(e,!0)}),t.sb.Options.websocketResponseTimeout),t.sb.onLoginTimerCancel=null},n.onMessage=function(e){o.onRawCommandReceived(e)},n.onError=function(n){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",n),t.sb.isReconnectingOnError=!0,t.sb.ConnectionManager.errorAllReadyHandler(),t.reconnect(e,!0)},n.onClose=function(){J.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),t.sb.reconnecting=!1},a.checkRouting((function(n,r){n?t.reconnect(e,!0):(t.sb.getCurrentApiHost()!==r.apiHost&&a.get("/",null,(function(){})),t.client.connect(e,null,r.wsHost))}))}),this.reconnectDelay)}}},{key:"disconnect",value:function(e,t){var n=U.get(this.sb._iid),r=n.container.ackStateMap,i=this.cls,s=i.GroupChannel,a=i.OpenChannel,o=e.clearSession,l=e.err;this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.onLoginTimerCancel&&(this.sb.onLoginTimerCancel(),this.sb.onLoginTimerCancel=null),this.sb.loginTimer=null),this.sb.reconnectTimer&&(clearTimeout(this.sb.reconnectTimer),this.sb.onReconnectTimerCancel&&(this.sb.onReconnectTimerCancel(),this.sb.onReconnectTimerCancel=null),this.sb.reconnectTimer=null),this.client&&(this.reconnectCount=0,this.client.disconnect(!0),this.client=null),o&&(a.clearEnteredChannels(),a.clearCache(),s.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),Object.keys(r).forEach((function(e){clearTimeout(r[e].timer)})),this.sb.currentUser=null,n.set("ackStateMap",{}),n.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),n.set("auth",new F)),l&&(this.flushConnectionCallbacks(l,null),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1),t&&t(null,null)}},{key:"flushConnectionCallbacks",value:function(e,t){var n=this,r=U.get(this.sb._iid).container,i=r.store,s=r.localCacheEnabled,a=this.sb.connectionCallbacks;if(this.sb.connectionCallbacks=[],e)if(s){var o=this.sb._getCurrentUserDataKey();ie.isNonAutoReconnectableError(e.code)?i.remove(o).catch((function(e){return J.debug("Sendbird connect store remove error: ",e)})).finally((function(){return a.forEach((function(t){return t(e,null)}))})):i.get(o).then((function(e){n.sb._populateVaultFromCurrentUserData(e)})).catch((function(e){J.debug("Sendbird connect store fetch error: ",e)})).finally((function(){n.sb.currentUser?a.forEach((function(t){return t(e,n.sb.currentUser)})):a.forEach((function(t){return t(e,null)}))}))}else a.forEach((function(t){return t(e,null)}));else pe.of(this.sb._iid).invokeConnect(),s?i.set({key:this.sb._getCurrentUserDataKey(),value:this._createCurrentUserData(t),generation:1}).catch((function(e){return J.debug("Sendbird connect store write error: ",e)})).finally((function(){return a.forEach((function(e){return e(null,n.sb.currentUser)}))})):a.forEach((function(e){return e(null,t)}))}},{key:"_createCurrentUserData",value:function(e){var t=U.get(this.sb._iid).container,n=t.auth,r=t.maxUnreadCountOfSuperGroupChannel,i=t.profileImageEncryption,s=t.appInfo,a=t.connectedAt,o=t.firstConnectedAt,l=t.concurrentCallLimit,u=t.backOffDelay,c={currentUser:(e||this.sb.currentUser).serialize(),maxUnreadCountOfSuperGroupChannel:T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,profileImageEncryption:!1};return n.sessionKey&&(c.sessionKey=n.sessionKey),n.eKey&&(c.eKey=n.eKey),r&&(c.maxUnreadCountOfSuperGroupChannel=r),i&&(c.profileImageEncryption=i),s&&(c.appInfo=s._objectify()),a&&o&&(c.connectedAt=a,c.firstConnectedAt=o),l&&u&&(c.concurrentCallLimit=l,c.backOffDelay=u),c}}]),e}(),tt=function(){function e(t){var n=t.type,r=t.nullable,i=void 0!==r&&r,s=t.optional,a=void 0!==s&&s,o=t.optionalIf,l=void 0===o?null:o,u=t.ignoreIf,d=void 0===u?null:u,h=t.defaultValue,p=void 0===h?null:h,f=t.constraint,_=void 0===f?null:f;c(this,e),this.type=n,this.nullable=i,this.optional=a,this.optionalIf=l,this.ignoreIf=d,this.defaultValue=p,this.constraint=_}return h(e,[{key:"isMatchingType",value:function(e){var t=function(t,n){return"string"==typeof n?u(t)===n||"array"===n&&Array.isArray(t)||"file"===n&&ie.isFile(t)||"null"===n&&null===t||"date"===n&&t instanceof Date:"function"==typeof n?t instanceof n:"object"===u(n)&&Object.keys(n).map((function(e){return n[e]})).indexOf(e)>-1};return t(e,this.type)||Array.isArray(this.type)&&this.type.some((function(n){return t(e,n)}))||this.nullable&&null===e}}],[{key:"parse",value:function(t,n){for(t=e.toArray(t);t.length>0&&void 0===t[t.length-1];)t.pop();var r=!1,i=null;"callback"===n[n.length-1].type&&("function"==typeof t[t.length-1]&&(i=t.pop()),n.pop(),r=!0);var s=[],a=null,o=0;return n.forEach((function(n){"function"==typeof n.ignoreIf&&n.ignoreIf(t)?s.push(n.hasOwnProperty("defaultValue")?n.defaultValue:null):n.isMatchingType(t[o])?(n.nullable&&null===t[o]||!n.constraint||n.constraint(t[o])||(a=e.error),s.push(t[o]),o++):n.optional||"function"==typeof n.optionalIf&&n.optionalIf(t)?s.push(n.hasOwnProperty("defaultValue")?n.defaultValue:null):(a=e.error,s.push(t[o]),o++)})),r&&i&&s.push(i),t.length!==o&&(a=e.error),[a].concat(s)}},{key:"error",get:function(){return new H("Invalid parameter.",H.INVALID_PARAMETER)}},{key:"toArray",value:function(e){for(var t=[],n=0;n1&&void 0!==arguments[1])||arguments[1],n=U.get(this.sb._iid),r=n.container,i=r.auth,s=r.isInBackground;t&&i.hasSession()?e&&(this.sb.currentUser?e(null,this.sb.currentUser):(this.addReadyHandler(e),this.errorAllReadyHandler()),this.sb.getConnectionState()!==this.sb.ConnectionState.CLOSED||s||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 t=this.sb.currentUser,n=this.readyHandlers;this.readyHandlers=[],n.forEach((function(n){n&&"function"==typeof n&&n(e,t)}))}}},{key:"errorAllReadyHandler",value:function(){var e=U.get(this.sb._iid).container.auth;this.processAllReadyHandler(e&&e.hasSession()?new H("WebSocket connection must be made first.",H.WEBSOCKET_CONNECTION_CLOSED):new H("Connection should be made first.",H.CONNECTION_REQUIRED))}},{key:"NetworkHandler",value:function(){this.onReconnected=function(){}}},{key:"addNetworkHandler",value:function(e,t){this.networkHandlers[e]=t}},{key:"removeNetworkHandler",value:function(e){delete this.networkHandlers[e]}},{key:"removeAllNetworkHandler",value:function(){this.networkHandlers={}}},{key:"authenticate",value:function(e){var t=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 n=setTimeout((function(){n=null,t.authCount--,0===t.authCount&&0===t.sb.connectionCallbacks.length&&(t.sb.connecting=!1),t.errorAllReadyHandler(),e(new H("Connection should be made first.",H.CONNECTION_REQUIRED),null)}),this.authenticateTimer);this.authInfoRequester((function(r){if(n){clearTimeout(n),n=null,t.authCount--;var i=function(n,r){t.sb.connecting=!1,e(n,null)};r&&r.hasOwnProperty("userId")?r.accessToken?r.apiHost&&r.wsHost?t.sb.connect(r.userId,r.accessToken,r.apiHost,r.wsHost,i):t.sb.connect(r.userId,r.accessToken,i):r.apiHost&&r.wsHost?t.sb.connect(r.userId,r.apiHost,r.wsHost,i):t.sb.connect(r.userId,i):e(tt.error,null)}}))}else e(tt.error,null)}}]),e}(),rt=function(){this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,t){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},it=function(){function e(){c(this,e),this.handler=null,this.resolvers=[]}return h(e,[{key:"_refreshSessionToken",value:function(){var t=this;return new Promise((function(n,r){var i=null,s=function(){i&&(clearTimeout(i),i=null)},a=function(){i&&(s(),r(e.sessionTokenRequestFailedError))};i=setTimeout((function(){return a()}),3e4),t.handler.onSessionTokenRequired((function(e){i&&(s(),n(e))}),a)}))}},{key:"_refreshSessionKey",value:function(){var t=this;return new Promise((function(n,r){var i=U.get(t._iid).container,s=i.auth,a=i.wsAdapter;s.sessionToken?a.isConnected?t._refreshSessionKeyByCommand().then((function(){return n()})).catch((function(e){e.isSessionTokenExpiredError?r(e):t._refreshSessionKeyByApi().then((function(){return n()})).catch((function(e){return r(e)}))})):t._refreshSessionKeyByApi().then((function(){return n()})).catch((function(e){return r(e)})):r(e.sessionTokenNotFoundError)}))}},{key:"_refreshSessionKeyByCommand",value:function(){var t=this;return new Promise((function(n,r){var i=ki.getInstance(t._iid),s=U.get(t._iid).container.auth,a=x.get(t._iid).Command,o=a.bSessionRefresh({token:s.sessionToken,requestId:a.generateRequestId()});i.sendCommand(o,(function(t,a){if(!i.getErrorFirstCallback()){var o=[t,a];a=o[0],t=o[1]}t?r(t):a?a.hasOwnProperty("error")?r(e.sessionKeyRefreshFailedError):(a.hasOwnProperty("new_key")&&(s.sessionKey=a.new_key),n()):r(e.sessionKeyRefreshFailedError)}))}))}},{key:"_refreshSessionKeyByApi",value:function(){var t=this;return new Promise((function(n,r){!function i(s){if(s<3){var a=U.get(t._iid).container,o=a.auth,l=a.apiClient,u={};o.sessionToken&&(u.accessToken=o.sessionToken),l.refreshSessionKey(u,(function(e,t){if(e)e.isSessionTokenExpiredError||e.isSessionTokenRevokedError?r(e):i(s+1);else{var a=t.key;o.sessionKey=a,n()}}))}else r(e.sessionKeyRefreshFailedError)}(0)}))}},{key:"_handleSessionToken",value:function(t){var n=this;t?(U.get(this._iid).container.auth.sessionToken=t,this._refreshSessionKey().then((function(){return n._handleSessionRefreshSuccess()})).catch((function(){return n._handleSessionRefreshError(e.sessionTokenRequestFailedError)}))):this._handleSessionClosed(e.sessionTokenRequestFailedError)}},{key:"_handleSessionRefreshSuccess",value:function(){this.handler.onSessionRefreshed(),this._flushResolvers(null)}},{key:"_handleSessionRefreshError",value:function(e){this._cancelConnection(),this.handler.onSessionError(e),this._flushResolvers(e)}},{key:"_handleSessionClosed",value:function(e){this._cancelConnection(),this.handler.onSessionClosed(),this._flushResolvers(e)}},{key:"_cancelConnection",value:function(){var e=ki.getInstance(this._iid);e.reconnecting&&(Object.keys(e.connectionHandlers).forEach((function(t){e.connectionHandlers[t].onReconnectFailed()})),e.reconnecting=!1),e.disconnect()}},{key:"_flushResolvers",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=0;n2&&void 0!==arguments[2]?arguments[2]:null;switch(c(this,e),this.command=t,this.requestId=r,arguments.length){case 1:if(!t||t.length<=4)this.command="NOOP",this.payload="{}";else if(this.decode(t),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()),n.req_id=this.requestId||"",this.payload=JSON.stringify(n)}}return h(e,[{key:"isRequestIdCommand",get:function(){return this.isAckRequired||"EROR"===this.command}},{key:"isAckRequired",get:function(){return"LOGI"===this.command||"MESG"===this.command||"FILE"===this.command||"ENTR"===this.command||"EXIT"===this.command||"READ"===this.command||"MEDI"===this.command||"FEDI"===this.command}},{key:"encode",value:function(){return this.command+this.payload+"\n"}},{key:"decode",value:function(e){e=e.trim(),this.command=e.substring(0,4),this.payload=e.substring(4)}},{key:"getJsonElement",value:function(){return JSON.parse(this.payload)}}],[{key:"bSessionRefresh",value:function(e){return new this("LOGI",{token:e.token},e.requestId)}},{key:"bPing",value:function(){return new this("PING",{id:(new Date).getTime(),active:1})}},{key:"bMessage",value:function(e){var t=e.channelUrl,n=e.message,r=e.data,i=e.customType,s=e.metaArrays,a=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,_=e.rootMessageId,g=void 0===_?null:_,y=e.parentMessageId,m=void 0===y?null:y,E=e.pollId,v=e.isReplyToChannel,b=void 0!==v&&v,C=x.get(this._iid),A=C.UserMessageParams,N=C.BaseMessageParams,S={};return S.channel_url=t,S.message=n,S.data=r,s&&s.length>0&&(S.metaarray=s.map((function(e){return e.encode()}))),a&&(S.mention_type=a),S.mentioned_user_ids=[],a===N.MentionType.CHANNEL?S.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(S.mentioned_user_ids=o),i&&(S.custom_type=i),l&&l.length>0&&(S.target_langs=l),u&&u!==A.PushNotificationDeliveryOption.DEFAULT&&(S.push_option=u),c&&(S.apple_critical_alert_options=c.serialize()),f&&(S.silent=f),g&&(S.root_message_id=g),m&&(S.parent_message_id=m),"number"==typeof E?S.poll_id=E:null===E&&(S.poll_id=-1),b&&(S.reply_to_channel=b),new this("MESG",S,h)}},{key:"bFile",value:function(e){var t=e.channelUrl,n=e.url,r=e.name,i=e.type,s=e.size,a=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,_=e.requestId,g=void 0===_?null:_,y=e.silent,m=void 0!==y&&y,E=e.rootMessageId,v=void 0===E?null:E,b=e.parentMessageId,C=void 0===b?null:b,A=e.isReplyToChannel,N=void 0!==A&&A,S=x.get(this._iid),I=S.BaseMessageParams,T=S.FileMessageParams,O={};return O.channel_url=t,O.url=n,O.name=r||"",O.type=i||"",O.size=s||0,O.custom=a,o&&(O.custom_type=o),l&&(O.thumbnails=l),u&&(O.require_auth=u),c&&c.length>0&&(O.metaarray=c.map((function(e){return e.encode()}))),d&&(O.mention_type=d),O.mentioned_user_ids=[],d===I.MentionType.CHANNEL?O.mentioned_user_ids=[]:Array.isArray(h)&&h.length>0&&(O.mentioned_user_ids=h),p&&p!==T.PushNotificationDeliveryOption.DEFAULT&&(O.push_option=p),f&&(O.apple_critical_alert_options=f.serialize()),m&&(O.silent=m),v&&(O.root_message_id=v),C&&(O.parent_message_id=C),N&&(O.reply_to_channel=N),new this("FILE",O,g)}},{key:"bUpdateUserMessage",value:function(e){var t=e.channelUrl,n=e.messageId,r=e.appleCriticalAlertOptions,i=e.message,s=void 0===i?null:i,a=e.data,o=void 0===a?null:a,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,_=void 0===f?null:f,g=e.pollId,y=x.get(this._iid).BaseMessageParams,m={};return m.channel_url=t,m.msg_id=n,null!=s&&void 0!==s&&(m.message=s),null!=o&&void 0!==o&&(m.data=o),null!=u&&void 0!==u&&(m.custom_type=u),d&&(m.mention_type=d),d===y.MentionType.CHANNEL?m.mentioned_user_ids=[]:Array.isArray(p)&&p.length>0&&(m.mentioned_user_ids=p),_&&(m.metaarray=_),r&&(m.apple_critical_alert_options=r.serialize()),"number"==typeof g?m.poll_id=g:null===g&&(m.poll_id=-1),new this("MEDI",m)}},{key:"bUpdateFileMessage",value:function(e){var t=e.channelUrl,n=e.messageId,r=e.appleCriticalAlertOptions,i=e.data,s=void 0===i?null:i,a=e.customType,o=void 0===a?null:a,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=x.get(this._iid).BaseMessageParams,_={};return _.channel_url=t,_.msg_id=n,null!=s&&void 0!==s&&(_.data=s),null!=o&&void 0!==o&&(_.custom_type=o),u&&(_.mention_type=u),u===f.MentionType.CHANNEL?_.mentioned_user_ids=[]:Array.isArray(d)&&d.length>0&&(_.mentioned_user_ids=d),p&&(_.metaarray=p),r&&(_.apple_critical_alert_options=r.serialize()),new this("FEDI",_)}},{key:"bRead",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("READ",n)}},{key:"bMessageAck",value:function(e){var t=e.channelUrl,n=e.messageId,r={};return r.channel_url=t,r.msg_id=n,new this("MACK",r)}},{key:"bTypeStart",value:function(e){var t=e.channelUrl,n=e.time,r={};return r.channel_url=t,r.time=n,new this("TPST",r)}},{key:"bTypeEnd",value:function(e){var t=e.channelUrl,n=e.time,r={};return r.channel_url=t,r.time=n,new this("TPEN",r)}},{key:"bEnter",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("ENTR",n)}},{key:"bExit",value:function(e){var t=e.channelUrl,n={};return n.channel_url=t,new this("EXIT",n)}},{key:"generateRequestId",value:function(){return at++,String(at)}}]),e}(),lt={},ut=function(){function e(e){var t=this,n=e.iid,r=e.limit,i=void 0===r?gt:r;this._token="",this._sync=null,this._syncRange=new Fe({top:Number.MAX_SAFE_INTEGER,bottom:0}),this._completed=!1,this._pkIndex=Date.now(),this._iid=n,this._limit=i;var s=x.get(this._iid).GroupChannel,a=U.get(this._iid),o=a.get("currentUserId"),l=a.get("apiClient"),u=a.get("store"),c=Et.of(this._iid),d=Ie.of(this._iid),h="sendbird:"+o+"@groupchannel/sync";this._sync=new Le(h,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,r,i,a,o=this;return L(this,(function(p){switch(p.label){case 0:return e={hasNext:!0,nextParams:""},[4,u.get(h)];case 1:return(t=p.sent())&&t.completed?[3,5]:(t&&(this._token=t.token,this._syncRange=t.range,this._pkIndex=t.primaryKeyIndex),n={token:this._token,limit:this._limit,includeEmpty:!0,order:"chronological"},[4,l.loadGroupChannelList(n)]);case 2:return r=p.sent(),i=r.channels.map((function(e){return r.ts&&(e.ts=r.ts),e.cached_primary_key=o._pkIndex--,s.upsert(e)})),this._syncRange.top=Math.min(this._syncRange.top,Math.min.apply(Math,i.map((function(e){return e.createdAt})))),this._syncRange.bottom=Math.max(this._syncRange.bottom,Math.max.apply(Math,i.map((function(e){return e.createdAt})))),e.hasNext=i.length>=this._limit,e.nextParams=this._token=r.next,this._token||(e.hasNext=!1),this._completed=!e.hasNext,J.debug("Group channel collection background sync fetched channels count: ",i.length),[4,c.upsert(i)];case 3:return p.sent(),[4,u.set({key:h,value:{token:this._token,range:this._syncRange,completed:this._completed,primaryKeyIndex:this._pkIndex},generation:1})];case 4:return p.sent(),a={source:Ce.CHANNEL_BACKGROUND,payload:{channels:i}},d.send(a),[3,6];case 5:J.debug("Group channel collection background sync has finished."),e.hasNext=!1,p.label=6;case 6:return[2,e]}}))}))}))}return e.of=function(t,n){return void 0===n&&(n=gt),lt[t]||(lt[t]=new e({iid:t,limit:n})),lt[t]},Object.defineProperty(e.prototype,"range",{get:function(){return this._syncRange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){return this._completed},enumerable:!1,configurable:!0}),e.prototype.resume=function(){J.debug("Group channel collection background sync has resumed."),this._sync.resume("")},e.prototype.pause=function(){J.debug("Group channel collection background sync has paused."),this._sync.stop()},e}(),ct={},dt=function(){function e(e){var t=this,n=e.iid;this._token=0,this._sync=null,this._pkIndex=Date.now(),this._iid=n;var r=x.get(this._iid).GroupChannel,i=U.get(this._iid);this._token=i.get("firstConnectedAt")/1e3;var s=i.get("currentUserId"),a=i.get("store"),o=i.get("apiClient"),l=i.container.localCacheEnabled,u=Et.of(this._iid),c=Ie.of(this._iid),d="sendbird:"+s+"@groupchannel/changelogs";this._sync=new Le(d,(function(e){return P(t,void 0,void 0,(function(){var e,t,n,i,s,h,p,f=this;return L(this,(function(_){switch(_.label){case 0:return e={hasNext:!0,nextParams:""},l?[4,a.get(d)]:[3,2];case 1:return n=_.sent(),[3,3];case 2:n=null,_.label=3;case 3:return(t=n)&&(this._token=t.token,this._pkIndex=t.primaryKeyIndex),i={},"number"==typeof this._token?i.ts=this._token:i.token=this._token,[4,o.getMyGroupChannelChangeLogs(i)];case 4:return s=_.sent(),h={updatedChannels:s.updated.map((function(e){return e.cached_primary_key=f._pkIndex--,new r(e)})),deletedChannelUrls:s.deleted},e.hasNext=s.has_more,e.nextParams=this._token=s.next,J.debug("Group channel collection changelog sync update channels count: ",h.updatedChannels.length),J.debug("Group channel collection changelog sync deleted channel urls count: ",h.deletedChannelUrls.length),l?[4,u.upsert(h.updatedChannels)]:[3,8];case 5:return _.sent(),[4,u.remove(h.deletedChannelUrls)];case 6:return _.sent(),[4,a.set({key:d,value:{token:this._token,primaryKeyIndex:this._pkIndex},generation:1})];case 7:_.sent(),_.label=8;case 8:return p={source:Ce.CHANNEL_CHANGELOG,payload:h},c.send(p),[2,e]}}))}))}))}return e.of=function(t){return ct[t]||(ct[t]=new e({iid:t})),ct[t]},e.prototype.resume=function(){J.debug("Group channel collection changelog sync has resumed."),this._sync.resume(0,!0)},e.prototype.pause=function(){J.debug("Group channel collection changelog sync has paused."),this._sync.stop()},e}(),ht=function(e,t){for(var n=0;n0){for(var r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(a<0))return s;r=s+1,s=Math.floor((r+i)/2)}}return _t(e[s],t,n)>0?s:s+1}return e.length},ft=function(e,t){return t-e},_t=function(e,t,n){switch(n){case ze.LATEST_LAST_MESSAGE:if(e.lastMessage&&!t.lastMessage)return-1;if(!e.lastMessage&&t.lastMessage)return 1;if(e.lastMessage&&t.lastMessage){var r=e.lastMessage.createdAt;if(0===(s=t.lastMessage.createdAt-r)){var i=e.createdAt;0===(s=t.createdAt-i)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey))}return s}r=e.createdAt;return 0===(s=t.createdAt-r)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ze.CHRONOLOGICAL:return 0===(s=t.createdAt-e.createdAt)&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ze.CHANNEL_NAME_ALPHABETICAL:var s;return 0===(s=e.name.localeCompare(t.name))&&(s=ft(e.cachedPrimaryKey,t.cachedPrimaryKey)),s}},gt=40;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical"}(ze||(ze={}));var yt=function(){function e(e){var t=this,n=e.iid,r=e.filter,i=e.order,s=e.limit,a=void 0===s?20:s;this._channels=[],this._token=null,this._hasMore=!0,this._iid=n,this._filter=r,this._order=i,this._limit=a,this._syncLimit=Math.max(a,gt),this._eventObserver={onevent:function(e){return P(t,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onChannelsAdded:fe,onChannelsUpdated:fe,onChannelsDeleted:fe};var o=U.get(this._iid);this._localCacheEnabled=o.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=ut.of(this._iid,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=dt.of(this._iid),Ie.of(this._iid).addObserver(this._eventObserver),this._connectionStateObserver={onConnect:function(){t._localCacheEnabled&&t._backgroundSync.resume(),t._changelogSync.resume()},onDisconnect:function(){return P(t,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,qe.ready()];case 1:return e.sent()||(this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},pe.of(this._iid).addObserver(this._connectionStateObserver)}return e.prototype._handleEvent=function(e){var t=this,n=e.source,r=e.payload,i=U.get(this._iid),s=new we(n);switch(n){case Ce.CHANNEL_BACKGROUND:break;case Ce.CHANNEL_CHANGELOG:var a=r,o=a.updatedChannels,l=a.deletedChannelUrls,u=o.filter((function(e){return t._filter.match(e)}));this._addChannelsToView(u,{context:s}),this._removeChannelsFromView(l,{context:s});break;case Ce.EVENT_USER_DECLINED_INVITATION:var c=i.get("currentUserId"),d=r,h=d.channel;d.invitee.userId===c?this._removeChannelsFromView([h.url],{context:s}):this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case Ce.EVENT_USER_LEFT:c=i.get("currentUserId");var p=r;h=p.channel;p.user.userId===c?this._removeChannelsFromView([h.url],{context:s}):this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case Ce.EVENT_USER_BANNED:case Ce.EVENT_USER_UNBANNED:break;case Ce.EVENT_USER_MUTED:case Ce.EVENT_USER_UNMUTED:case Ce.EVENT_TYPING_STATUS_UPDATED:case Ce.EVENT_OPERATOR_UPDATED:case Ce.EVENT_CHANNEL_METADATA_UPDATED:case Ce.EVENT_CHANNEL_METADATA_DELETED:case Ce.EVENT_CHANNEL_METACOUNTER_UPDATED:case Ce.EVENT_CHANNEL_METACOUNTER_DELETED:h=e.payload.channel;this._addChannelsToView([h],{context:s});break;case Ce.EVENT_READ_RECEIPT_UPDATED:case Ce.EVENT_USER_RECEIVED_INVITATION:case Ce.EVENT_USER_JOINED:case Ce.EVENT_CHANNEL_FROZEN:case Ce.EVENT_CHANNEL_UNFROZEN:case Ce.EVENT_CHANNEL_HIDDEN:case Ce.EVENT_CHANNEL_UNHIDDEN:case Ce.EVENT_CHANNEL_CHANGED:h=e.payload.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case Ce.EVENT_CHANNEL_DELETED:var f=r.channelUrl;this._removeChannelsFromView([f],{context:s})}},e.prototype._getRemoteChannels=function(){return P(this,void 0,void 0,(function(){var e,t,n,r;return L(this,(function(i){switch(i.label){case 0:return e=x.get(this._iid).GroupChannel,t=U.get(this._iid),[4,t.get("apiClient").loadGroupChannelList(M(M({},this._filter),{order:this._order,token:this._token,limit:this._limit,userIdsFilter:this._filter.userIdsFilter,searchFilter:(s=this._filter.searchFilter,s.searchQuery&&s.searchFields?{search_query:s.searchQuery,search_fields:s.searchFields.join(",").toLocaleLowerCase()}:{})}))];case 1:return n=i.sent(),r=n.channels.map((function(t){return"number"==typeof n.ts&&(t.ts=n.ts),e.upsert(t)})),[4,Et.of(this._iid).upsert(r)];case 2:return i.sent(),[2,[r,n.next]]}var s}))}))},e.prototype._addChannelsToView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=[],a=0,o=e;a0&&this._eventHandler.onChannelsAdded(r,i),s.length>0&&this._eventHandler.onChannelsUpdated(r,s))},e.prototype._removeChannelsFromView=function(e,t){void 0===t&&(t={});for(var n=t.context,r=void 0===n?null:n,i=[],s=0,a=e;s=0&&(i.push(this._channels[l].url),this._channels.splice(l,1))}return r&&i.length>0&&this._eventHandler.onChannelsDeleted(r,i),i},Object.defineProperty(e.prototype,"channelList",{get:function(){return this._channels},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),e.prototype.loadMore=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i;return L(this,(function(s){switch(s.label){case 0:return this._hasMore?[4,qe.ready()]:[3,5];case 1:return s.sent()?[3,3]:(J.debug("Group channel collection loadMore() from the cache."),e=Et.of(this._iid),t=e.getNextContainerToken(this._order,this._channels),[4,e.getNextChannels(this._filter,this._order,t,this._limit)]);case 2:return r=s.sent(),this._addChannelsToView(r),[2,r];case 3:return J.debug("Group channel collection loadMore() from the server."),[4,this._getRemoteChannels()];case 4:return n=s.sent(),r=n[0],i=n[1],this._token=i,this._token||(this._hasMore=!1),this._addChannelsToView(r),[2,r];case 5:return[2,[]]}}))}))},e.prototype.dispose=function(){pe.of(this._iid).removeObserver(this._connectionStateObserver),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause(),Ie.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setGroupChannelCollectionHandler=function(e){this._eventHandler=e},e.GroupChannelOrder=ze,e}(),mt={},Et=function(){function e(e){var t=e.iid,n=e.collection,r=void 0===n?null:n;this._collection=null,this._pkIndex=Date.now(),this._lastFetchedPrimaryKey=Date.now(),this._iid=t,this._collection=r,mt[t]=this}return e.of=function(e){return mt[e]},e.prototype._serialize=function(e){var t=this._createPk();return e.cachedPrimaryKey=t,M(M({},e.serialize()),{lastMessageCreatedAt:e.lastMessage?e.lastMessage.createdAt:e.createdAt,pk:t})},e.prototype._deserialize=function(e){return e?x.get(this._iid).GroupChannel.buildFromSerializedData(e):null},Object.defineProperty(e.prototype,"_localCacheEnabled",{get:function(){return U.get(this._iid).get("localCacheEnabled")},enumerable:!1,configurable:!0}),e.prototype._createPk=function(){return this._pkIndex--},e.prototype._fetch=function(e,t,n){return P(this,void 0,void 0,(function(){var r,i,s,a,o,l,u,c=this;return L(this,(function(d){switch(d.label){case 0:if(!this._localCacheEnabled)return[3,3];switch(r=_e.LATEST_LAST_MESSAGE,t){case ze.CHANNEL_NAME_ALPHABETICAL:r=_e.NAME_ALPHABETICAL;break;case ze.CHRONOLOGICAL:r=_e.CHRONOLOGICAL;break;case ze.LATEST_LAST_MESSAGE:r=_e.LATEST_LAST_MESSAGE}return i=n.containerToken,s=i.lastMessageCreatedAt,a=i.createdAt,o=i.name,l=i.lastFetchedPrimaryKey,u={where:function(n){switch(t){case ze.LATEST_LAST_MESSAGE:if(n.lastMessage){if(n.lastMessageCreatedAt>s)return!1;if(n.lastMessageCreatedAt===s&&ft(l,n.pk)>=0)return!1}else{if(n.createdAt>a)return!1;if(n.createdAt===a&&ft(l,n.pk)>=0)return!1}break;case ze.CHANNEL_NAME_ALPHABETICAL:var r=n.name.localeCompare(o);if(r<0)return!1;if(0===r&&ft(l,n.pk)>=0)return!1;break;case ze.CHRONOLOGICAL:if(n.createdAt>a)return!1;if(n.createdAt===a&&ft(l,n.pk)>=0)return!1}return e.match(c._deserialize(n))},index:r},[4,this._collection.query(u)];case 1:return[4,d.sent().fetch({limit:n.limit})];case 2:return[2,d.sent().map((function(e){return c._deserialize(e)}))];case 3:return[2,[]]}}))}))},e.prototype.getNextContainerToken=function(e,t){switch(e){case ze.LATEST_LAST_MESSAGE:return t.length>0?{lastMessageCreatedAt:(n=t[t.length-1]).lastMessage?n.lastMessage.createdAt:null,createdAt:n.createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{lastMessageCreatedAt:Number.MAX_SAFE_INTEGER,createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ze.CHRONOLOGICAL:return t.length>0?{createdAt:(n=t[t.length-1]).createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ze.CHANNEL_NAME_ALPHABETICAL:var n;return t.length>0?{name:(n=t[t.length-1]).name,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{name:"",lastFetchedPrimaryKey:this._lastFetchedPrimaryKey}}},e.prototype.get=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return this._localCacheEnabled?(t=this._deserialize,[4,this._collection.getByKey(e)]):[3,2];case 1:return[2,t.apply(this,[n.sent()])];case 2:return[2,null]}}))}))},e.prototype.getNextChannels=function(e,t,n,r){return void 0===r&&(r=100),P(this,void 0,void 0,(function(){return L(this,(function(i){switch(i.label){case 0:return[4,this._fetch(e,t,{containerToken:n,limit:r})];case 1:return[2,i.sent()]}}))}))},e.prototype.upsert=function(e){return P(this,void 0,void 0,(function(){var t,n=this;return L(this,(function(r){switch(r.label){case 0:return this._localCacheEnabled?(t=e.map((function(e){return n._serialize(e)})),[4,this._collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},e.prototype.remove=function(e){return P(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this._collection.removeIf({url:{"/in":e}})]:[3,3];case 1:return t.sent(),[4,ki.getInstance(this._iid).clearCachedMessages(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return P(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return this._localCacheEnabled?[4,this._collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e}(),vt=function(){function e(){this.messageId=null,this.userId=null,this.key=null,this.operation="",this.updatedAt=null}return e.createFromJson=function(e){var t=parseInt(e.msg_id),n=e.user_id,r=e.operation,i=e.reaction,s=e.updated_at;if(t&&"string"==typeof n&&"string"==typeof r&&["add","delete"].indexOf(r.toLowerCase())>=0&&"string"==typeof i&&i&&"number"==typeof s){var a=new this;return a.messageId=t,a.userId=n,a.key=i,a.operation=r.toLowerCase(),a.updatedAt=s,a}return null},e}(),bt=function(e){return Object.keys(e).forEach((function(t){e[t]&&"object"==typeof e[t]&&bt(e[t])})),Object.freeze(e)},Ct=function(){function e(){}return e.serialize=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),bt(n)},e.serializeWithoutFreeze=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},e.deserialize=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},e}(),At={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Nt=new WeakMap,St=function(){function e(t){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.mentionedUserIds=[],this.sendingStatus=null,Nt.set(this,0),this.parentMessageId=0,this.parentMessageText=null,this.threadInfo=null,this.isReplyToChannel=!1,this.parentMessage=null,this.ogMetaData=null,this.isOperatorMessage=!1,this.appleCriticalAlertOptions=null,this.reqId="",this._isAutoResendRegistered=!1,t&&this.__update(t)}return h(e,[{key:"serialize",value:function(e){var t=this;return Ct.serialize(this,(function(n){n.hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender),n.hasOwnProperty("_isAutoResendRegistered")&&(n.isAutoResendRegistered=n._isAutoResendRegistered,delete n._isAutoResendRegistered),t.appleCriticalAlertOptions&&(n.appleCriticalAlertOptions=t.appleCriticalAlertOptions.serialize()),e&&e(n)}))}},{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 ie.deepEqual(this,e)}},{key:"isOpenChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"isGroupChannel",value:function(){var e=x.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 t=this,n=ki.getInstance(this._iid),r=x.get(this._iid),i=r.User,s=r.BaseChannel,a=r.BaseMessageParams,o=r.BaseMessage,u=r.Reaction,c=r.MessageMetaArray,d=r.ThreadInfo,h=r.OGMetaData,p=r.AppleCriticalAlertOptions;e.hasOwnProperty("msg_id")&&e.msg_id&&(this.messageId=parseInt(e.msg_id)),e.hasOwnProperty("message_id")&&e.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):"",e.hasOwnProperty("silent")&&(this.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):s.CHANNEL_TYPE_GROUP;var f=e.hasOwnProperty("metaarray")?e.metaarray:{},_=e.hasOwnProperty("metaarray_key_order")?e.metaarray_key_order:Object.keys(f).sort((function(e,t){return e.localeCompare(t)}));this.metaArrays=[];for(var g=0;g<_.length;g++){var y=_[g];this.metaArrays.push(new c(y,f[y]||[]))}if(e.hasOwnProperty("sorted_metaarray")){var m=e.sorted_metaarray;Array.isArray(m)&&(this.metaArrays=m.map((function(e){return new c(e.key,e.value)})))}if(this.reactions=[],e.hasOwnProperty("reactions")&&Array.isArray(e.reactions))for(var E=0;E0?n.MessageSendingStatus.SUCCEEDED:n.MessageSendingStatus.FAILED,e.hasOwnProperty("sending_status")&&(this.sendingStatus=e.sending_status),e.hasOwnProperty("root_message_id")&&e.root_message_id&&Nt.set(this,parseInt(e.root_message_id)),e.hasOwnProperty("parent_message_id")&&e.parent_message_id&&(this.parentMessageId=parseInt(e.parent_message_id)),this.threadInfo=new d(e.thread_info),this.isReplyToChannel=!!e.hasOwnProperty("is_reply_to_channel")&&e.is_reply_to_channel,e.hasOwnProperty("parent_message_info")){var b=l({},e.parent_message_info);e.parent_message_info.hasOwnProperty("file")&&(b.require_auth=!!e.parent_message_info.file.require_auth);var C={channelType:this.channelType,channelUrl:this.channelUrl};switch(this.parentMessage=s.buildMessage(b,C),this.parentMessage.messageType){case o.MESSAGE_TYPE_USER:this.parentMessageText=this.parentMessage.message;break;case o.MESSAGE_TYPE_FILE:this.parentMessageText=this.parentMessage.name}}e.hasOwnProperty("og_tag")&&(this.ogMetaData=new h(e.og_tag)),e.hasOwnProperty("is_op_msg")&&(this.isOperatorMessage=e.is_op_msg),e.hasOwnProperty("apple_critical_alert_options")&&(this.appleCriticalAlertOptions=new p(e.apple_critical_alert_options)),e.hasOwnProperty("is_auto_resend_registered")&&(this._isAutoResendRegistered=e.is_auto_resend_registered),this.reqId=e.hasOwnProperty("req_id")?e.req_id:""}},{key:"getMetaArraysByKeys",value:function(e){return Array.isArray(e)?this.metaArrays.filter((function(t){return e.indexOf(t.key)>-1})):[]}},{key:"metaArray",get:function(){var e={};return this.metaArrays.forEach((function(t){e[t.key]=t.value})),e},set:function(e){if("object"===u(e)&&e){var t=x.get(this._iid).MessageMetaArray,n=[];Object.keys(e).forEach((function(r){n.push(new t(r,e[r]))})),this.metaArrays=n}}},{key:"sender",get:function(){var e=ki.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.deepEqual(this._sender.metaData,r.metaData)||(this._sender.metaData=r.metaData))}}return this._sender},set:function(e){this._sender=e}},{key:"getMetaArrayByKeys",value:function(e){var t={};return this.getMetaArraysByKeys(e).forEach((function(e){t[e.key]=e.value})),t}},{key:"applyReactionEvent",value:function(e){var t=this,n=x.get(this._iid),r=n.Reaction,i=null,s=tt.parse(arguments,[new tt({type:vt,constraint:function(e){return parseInt(e.messageId)===parseInt(t.messageId)}})]),a=C(s,2);if(i=a[0],e=a[1],!i){for(var o=!1,l=0;l-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 t=this.plainProfileUrl.replace("profile_images/","");return t===this.plainProfileUrl?"":t}return""},e.prototype.createMetaData=function(e,t){var n,r=this,i=null;return n=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new tt({type:"callback"})]),i=n[0],e=n[1],t=n[2],oe(this._iid,(function(t){i?t(i,null):U.get(r._iid).container.apiClient.createUserMetaData({metaData:e},(function(e,n){e||r._updateMetaData(n),t(e,n)}))}),t)},e.prototype.updateMetaData=function(e,t,n){var r,i=this,s=null;return r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),s=r[0],e=r[1],t=r[2],n=r[3],oe(this._iid,(function(n){s?n(s,null):U.get(i._iid).container.apiClient.updateUserMetaData({metaData:e,upsert:t},(function(e,t){e||i._updateMetaData(t),n(e,t)}))}),n)},e.prototype.deleteMetaData=function(e,t){var n,r=this,i=null;return n=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),i=n[0],e=n[1],t=n[2],oe(this._iid,(function(t){if(i)t(i,null);else{var n={};n[e]="",U.get(r._iid).container.apiClient.deleteUserMetaData({metaDataKey:e},(function(e,i){e||r._updateMetaData(n,!0),t(e,i)}))}}),t)},e.prototype.deleteAllMetaData=function(e){var t=this;return oe(this._iid,(function(e){var n=t.metaData;U.get(t._iid).container.apiClient.deleteAllUserMetaData({},(function(r,i){r||t._updateMetaData(n,!0),e(r,i)}))}),e)},Object.defineProperty(e,"NON_AVAILABLE",{get:function(){return"nonavailable"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ONLINE",{get:function(){return"online"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"OFFLINE",{get:function(){return"offline"},enumerable:!1,configurable:!0}),e}(),Tt={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Ot=new WeakMap,Ut=new WeakMap,kt=function(){function e(t){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,Ot.set(this,{}),Ut.set(this,""),t&&this.__update(t)}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 It(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),e.hasOwnProperty("cached_primary_key")&&(this.cachedPrimaryKey=e.cached_primary_key)}},{key:"_addOrUpdateCachedMetaData",value:function(e,t){var n=Ot.get(this);Object.keys(e).forEach((function(r){var i=n[r],s=e[r];i?t>i.updatedAt&&(i.value=s,i.updatedAt=t,i.isRemoved=!1):n[r]={value:s,updatedAt:t,isRemoved:!1}}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var n=Ot.get(this);e.forEach((function(e){var r=n[e];r?t>r.updatedAt&&(r.isRemoved=!0,r.updatedAt=t):n[e]={value:null,updatedAt:t,isRemoved:!0}}))}},{key:"_refreshMetaData",value:function(e,t){var n={};Object.keys(e).forEach((function(r){n[r]={value:e[r],updatedAt:t,isRemoved:!1}})),Ot.set(this,n)}},{key:"cachedPrimaryKey",get:function(){return Ut.get(this)},set:function(e){Ut.set(this,e)}},{key:"isGroupChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){var e=x.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"createOperatorListQuery",value:function(){return new(0,x.get(this._iid).OperatorListQuery)(this)}},{key:"createMessageListQuery",value:function(){return new(0,x.get(this._iid).MessageListQuery)(this)}},{key:"createPreviousMessageListQuery",value:function(){return new(0,x.get(this._iid).PreviousMessageListQuery)(this)}},{key:"createPollListQuery",value:function(){return new(0,x.get(this._iid).PollListQuery)({channelUrl:this.url})}},{key:"createPollVoterListQuery",value:function(e,t){return new(0,x.get(this._iid).PollVoterListQuery)({channelUrl:this.url,pollId:e,optionId:t})}},{key:"serialize",value:function(){var e=this;return Ct.serialize(this,(function(t){if(null!==t.lastMessage&&"object"===u(t.lastMessage)){var n=t.lastMessage;n.hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender,t.lastMessage=n)}t.hasOwnProperty("_messageOffsetTimestamp")&&(t.messageOffsetTimestamp=t._messageOffsetTimestamp,delete t._messageOffsetTimestamp),e.cachedPrimaryKey&&(t.cachedPrimaryKey=e.cachedPrimaryKey)}))}},{key:"getMessageChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:e,token:null,isOpenChannel:i.isOpenChannel(),includeMetaArray:t,includeReactions:n}).then((function(e){var t=x.get(i._iid).BaseChannel,n={updatedMessages:e.updated.map((function(e){return t.buildMessage(e,i)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getMessageChangeLogsByToken",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.getMessageChangeLogs({channelUrl:i.url,ts:null,token:e,isOpenChannel:i.isOpenChannel(),includeMetaArray:t,includeReactions:n}).then((function(e){var t=x.get(i._iid).BaseChannel,n={updatedMessages:e.updated.map((function(e){return t.buildMessage(e,i)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=i.MessageChangeLogsParams,o=null,u=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=C(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,ts:null,token:e,isOpenChannel:r.isOpenChannel()},t)).then((function(e){var t={updatedMessages:e.updated.map((function(e){return s.buildMessage(e,r)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};n(null,t)})).catch((function(e){n(e,null)}))}),n)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=i.MessageChangeLogsParams,o=null,u=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=C(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.getMessageChangeLogs(l({channelUrl:r.url,timestamp:e,token:null,isOpenChannel:r.isOpenChannel()},t)).then((function(e){var t={updatedMessages:e.updated.map((function(e){return s.buildMessage(e,r)})),deletedMessageIds:e.deleted.map((function(e){return parseInt(e.message_id)})),hasMore:e.has_more,token:e.next};n(null,t)})).catch((function(e){n(e,null)}))}),n)}},{key:"getMyMutedInfo",value:function(e){var t=this;return oe(this._iid,(function(e){var n=ki.getInstance(t._iid);U.get(t._iid).container.apiClient.getMyMutedInfo({channelUrl:t.url,userId:n.currentUser?n.currentUser.userId:null,isGroupChannel:t.isGroupChannel()},(function(t,n){var r=null;t||(r={isMuted:n.is_muted,startAt:n.start_at,endAt:n.end_at,remainingDuration:n.remaining_duration,description:n.description}),e(t,r)}))}),e)}},{key:"_parseMessageListParams",value:function(e){for(var t=x.get(this._iid),n=t.MessageListParams,r=new n,i=null,s=!1,a=0,o=0,l=!1,u="",c="",d=null,h=!1,p=!1,f=null,_=arguments.length,g=new Array(_>1?_-1:0),y=1;y<_;y++)g[y-1]=arguments[y];switch(e){case"prev":var m=tt.parse(g,[new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),E=C(m,11);i=E[0],s=E[2],a=E[3],l=E[4],u=E[5],c=E[6],d=E[7],h=E[8],p=E[9],f=E[10];break;case"next":var v=tt.parse(g,[new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),b=C(v,11);i=b[0],s=b[2],o=b[3],l=b[4],u=b[5],c=b[6],d=b[7],h=b[8],p=b[9],f=b[10];break;case"prevnext":var A=tt.parse(g,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"string"}),new tt({type:"string"}),new tt({type:"array",optional:!0}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),N=C(A,11);i=N[0],a=N[2],o=N[3],l=N[4],u=N[5],c=N[6],d=N[7],h=N[8],p=N[9],f=N[10],s=!0}return i?[null,f]:(r.isInclusive=s,r.prevResultSize=a,r.nextResultSize=o,r.reverse=l,r.messageType=u,r.customType=c,""===r.customType&&(r.customType="*"),r.senderUserIds=d,r.includeMetaArray=h,r.includeReactions=p,[r,f])}},{key:"_getMessageList",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.MessageListParams,o=null,u=tt.parse(arguments,[new tt({type:"number"}),new tt({type:"string",constraint:function(e){return Object.values(Tt).includes(e)}}),new tt({type:a,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),c=C(u,5);return o=c[0],e=c[1],t=c[2],n=c[3],r=c[4],oe(this._iid,(function(r){o?r(o,null):U.get(i._iid).container.apiClient.getMessageList(l(l({channel:i,token:e,tokenType:t},n),{},{shouldReverse:n.reverse})).then((function(e){var t=x.get(i._iid).BaseChannel,n=e.messages.map((function(e){return t.buildMessage(e,i)})).filter((function(e){return null!==e}));r(null,n)})).catch((function(e){r(e,null)}))}),r)}},{key:"getPreviousMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getPreviousAndNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.TIMESTAMP,r,i)}},{key:"getPreviousMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getPreviousAndNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(tt.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Tt.MESSAGE_ID,r,i)}},{key:"getMessagesByTimestamp",value:function(e,t,n){return this._getMessageList(e,Tt.TIMESTAMP,t,n)}},{key:"getMessagesByMessageId",value:function(e,t,n){return this._getMessageList(e,Tt.MESSAGE_ID,t,n)}},{key:"_sendUserMessage",value:function(e){var t=this,n=e.reqId,r=e.message,i=e.data,s=e.customType,a=e.metaArrays,o=e.mentionType,u=e.mentionedUserIds,c=e.pushNotificationDeliveryOption,d=e.rootMessageId,h=e.parentMessageId,p=e.translationTargetLanguages,f=e.appleCriticalAlertOptions,_=e.pollId,g=e.silent,y=void 0!==g&&g,m=e.isReplyToChannel,E=e.messageParams,v=e.oldMessage,b=void 0===v?null:v,C=e.isManualResend,A=void 0!==C&&C,N=e.callback,S=x.get(this._iid),I=S.Command,T=S.UserMessage,O=ki.getInstance(this._iid),k=Ae.of(this._iid),R=Et.of(this._iid),M=Ie.of(this._iid),P=U.get(this._iid).container.localCacheEnabled;n||(n=I.generateRequestId());var L={};Array.isArray(p)&&p.forEach((function(e){return L[e]=""}));var w=T.objectify({messageId:0,reqId:n,user:O.currentUser||{},channel:this,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,rootMessageId:d,parentMessageId:h,translations:L,silent:y,appleCriticalAlertOptions:f,isReplyToChannel:m,messageParams:E,createdAt:(new Date).getTime()}),D=new T(w);if(D.requestState=O.MessageRequestState.PENDING,D.sendingStatus=O.MessageSendingStatus.PENDING,D.requestedMentionUserIds=u,D._messageParams=E,!O.currentUser){var F=new H("Connection should be made first.",H.CONNECTION_REQUIRED),G=new T(w);return G.requestState=O.MessageRequestState.FAILED,G.sendingStatus=O.MessageSendingStatus.FAILED,G.requestedMentionUserIds=u,G.errorCode=F.code,N(F,G),D}return(!t.isGroupChannel()||b&&b._isAutoResendRegistered?Promise.resolve():k.upsert([D],de.UNSENT).then((function(){M.send({source:A?Ce.LOCAL_MESSAGE_RESEND_STARTED:Ce.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:t,message:D}})}))).then((function(){var e=I.bMessage({channelUrl:t.url,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,requestId:n,rootMessageId:d,parentMessageId:h,silent:y,translationTargetLanguages:p,pushNotificationDeliveryOption:c,appleCriticalAlertOptions:f,pollId:_,isReplyToChannel:m});(D.reqId=e.requestId,t.isGroupChannel()&&O.getConnectionState()!==O.ConnectionState.OPEN&&O.currentUser&&!O.connecting&&!O.reconnecting&&"string"==typeof s&&0===s.indexOf("SB_VIDEOCHAT"))?U.get(O._iid).container.apiClient.sendUserMessage({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),message:r,data:i,customType:s,translationTargetLanguages:p,metaArrays:a,mentionType:o,mentionedUserIds:u,pushNotificationDeliveryOption:c,rootMessageId:d,parentMessageId:h,appleCriticalAlertOptions:f,pollId:_,isReplyToChannel:m},(function(e,r){var i=null;if(e){if(D._isAutoResendRegistered&&ie.isAutoResendableError(e.code))return;(i=new T(w)).requestState=O.MessageRequestState.FAILED,i.requestedMentionUserIds=u,b&&(i._isAutoResendRegistered=b._isAutoResendRegistered),e.code===H.REQUEST_CANCELED?(i.sendingStatus=O.MessageSendingStatus.CANCELED,k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){M.send({source:Ce.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(new H(e.message,e.code),i)}))):(i.errorCode=e.code,i.sendingStatus=O.MessageSendingStatus.FAILED,P&&ie.isAutoResendableError(e.code)&&(i.sendingStatus=O.MessageSendingStatus.PENDING,i.errorCode=0,i._isAutoResendRegistered=!0),k.upsert([i],de.UNSENT).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,i),M.send({source:Ce.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){var t=i._clone();t.sendingStatus=O.MessageSendingStatus.FAILED,t.errorCode=e.code,t._isAutoResendRegistered=!1,N&&N(new H(e.message,e.code),t)})))}else{for(var s in(i=new T(r)).reqId=n,i.requestState=O.MessageRequestState.SUCCEEDED,i.sendingStatus=O.MessageSendingStatus.SUCCEEDED,b&&(i._isAutoResendRegistered=b._isAutoResendRegistered),t.lastMessage=i,O.channelHandlers){O.channelHandlers[s].onChannelChanged(t)}R.upsert([t]).then((function(){M.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return k.upsert([i],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,i),M.send({source:Ce.EVENT_MESSAGE_SENT,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(null,i)}))}})):O.sendCommand(e,(function(r,i){if(O.getErrorFirstCallback()){var s=[r,i];i=s[0],r=s[1]}if(i){if(D._isAutoResendRegistered&&ie.isAutoResendableError(i.code))return;var a=new T(w);a.reqId=e.requestId,a.requestState=O.MessageRequestState.FAILED,i.code===H.REQUEST_CANCELED?(a.sendingStatus=O.MessageSendingStatus.CANCELED,t.isGroupChannel()&&k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){M.send({source:Ce.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:a}})})).catch((function(e){return J.error(e)})).finally((function(){N&&N(new H(i.message,i.code),a)}))):(a.sendingStatus=O.MessageSendingStatus.FAILED,a.errorCode=i.code,a.requestedMentionUserIds=u,t.isGroupChannel()?(P&&ie.isAutoResendableError(i.code)&&(a.sendingStatus=O.MessageSendingStatus.PENDING,a.errorCode=0,a._isAutoResendRegistered=!0),k.upsert([a],de.UNSENT).then((function(){return Xe._completeCurrentAndProcessNextAutoResend(O,a),M.send({source:Ce.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:a}})})).catch((function(e){J.error(e)})).finally((function(){var e=a._clone();e.sendingStatus=O.MessageSendingStatus.FAILED,e.errorCode=i.code,e._isAutoResendRegistered=!1,N&&N(new H(i.message,i.code),e)}))):N&&N(new H(i.message,i.code),a))}else{var o=new T(l(l({},r.getJsonElement()),{},{messageParams:E}));o.reqId=n,o.requestState=O.MessageRequestState.SUCCEEDED,o.sendingStatus=O.MessageSendingStatus.SUCCEEDED,b&&(o._isAutoResendRegistered=b._isAutoResendRegistered);var c=O.currentUser;if(c&&o._sender&&c.userId===o._sender.userId&&(c.nickname!==o._sender.nickname&&(c.nickname=o._sender.nickname),c.plainProfileUrl!==o._sender.plainProfileUrl&&(c.plainProfileUrl=o._sender.plainProfileUrl),ie.deepEqual(c.metaData,o._sender.metaData)||(c.metaData=o._sender.metaData)),t.isGroupChannel()){t.lastMessage=o,Object.keys(O.channelHandlers).forEach((function(e){O.channelHandlers[e].onChannelChanged(t)}));var d=Ie.of(t._iid);Et.of(t._iid).upsert([t]).then((function(){d.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return k.removeUnsentMessages({channelUrl:t.url,sendingStatus:O.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return k.upsert([o],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(O,o),d.send({source:Ce.EVENT_MESSAGE_SENT,payload:{channel:t,message:o}})})).catch((function(e){J.error(e)})).finally((function(){N&&N(null,o)}))}else N&&N(null,o)}}))})),D}},{key:"sendUserMessage",value:function(){var e=tt.toArray(arguments),t=e.pop(),n=null,r=null,i=x.get(this._iid),s=i.UserMessageParams;if("function"==typeof t)if(e[0]instanceof s)null===(r=e[0]).data&&(r.data=""),null===r.customType&&(r.customType="");else if("string"==typeof e[0])switch((r=new s).message=e[0],e.length){case 1:break;case 2:r.data=e[1]||"";break;case 3:r.data=e[1]||"",r.customType=e[2]||"";break;case 4:r.data=e[1]||"",r.customType=e[2]||"",r.translationTargetLanguages=Array.isArray(e[3])?e[3]:[e[3]];break;default:n=tt.error}else n=tt.error;else n=tt.error;var a=U.get(this._iid),o=a.container.isErrorFirstInCallback;return!n&&r._validate()&&r.message?this._sendUserMessage(l(l({},r),{},{metaArrays:r.metaArrays,mentionType:r.mentionType,mentionedUserIds:r._mentionedUserIds,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,messageParams:r,callback:function(e,n){o?t(e,n):t(n,e)}})):(o?t(tt.error,null):t(null,tt.error),null)}},{key:"_autoResendUserMessage",value:function(e){var t=this,n=ki.getInstance(this._iid);if(n&&n.currentUser){var r=e._messageParams;return new Promise((function(n,i){return t._sendUserMessage(l(l({},r),{},{reqId:e.reqId,metaArrays:r.metaArrays,mentionType:r.mentionType,mentionedUserIds:r._mentionedUserIds,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,pushNotificationDeliveryOption:r.pushNotificationDeliveryOption,messageParams:r,oldMessage:e,callback:function(e,t){e?i(e):n(t)}}))}))}}},{key:"_autoResendFileMessage",value:function(e){var t=ki.getInstance(this._iid);if(t&&t.currentUser){var n=this._parsePendingFileMessage(e),r=x.get(this._iid).FileMessageQueue;r.create(this).addJob(new r.Job({fileInfo:n,pendingMessage:e._clone(),requestId:e.reqId,error:n.error,response:null}))}}},{key:"resendUserMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.UserMessage,s=r.UserMessageParams,a=null,o=tt.parse(arguments,[new tt({type:i,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===n.url&&"string"==typeof e.message&&"string"==typeof e.data&&"string"==typeof e.customType&&"object"===u(e.translations)&&!Array.isArray(e.translations)}}),new tt({type:"callback"})]),c=C(o,3);return a=c[0],e=c[1],t=c[2],oe(this._iid,(function(t){if(a)a.message+=" Please check if the failed message is resend-able with `message.isResendable().`",t(a,null);else{var r=Object.keys(e.translations),i=s.PushNotificationDeliveryOption.DEFAULT;n._sendUserMessage(l(l({},e),{},{mentionedUserIds:e.requestedMentionUserIds,translationTargetLanguages:r,pushNotificationDeliveryOption:i,reqId:e.reqId,messageParams:e._messageParams,isManualResend:!0,callback:t}))}}),t)}},{key:"updateUserMessage",value:function(e,t,n,r,i){var s=this,a=x.get(this._iid),o=a.Command,u=a.UserMessage,c=a.UserMessageParams,d=arguments,h=null,p=null;if("number"==typeof e)switch(d.length){case 3:var f=tt.parse(d,[new tt({type:"number"}),new tt({type:c}),new tt({type:"callback"})]),_=C(f,4);h=_[0],e=_[1],p=_[2],i=_[3];break;case 5:p=new c;var g=tt.parse(d,[new tt({type:"number"}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),y=C(g,6);h=y[0],e=y[1],t=y[2],n=y[3],r=y[4],i=y[5],p.message=t,p.data=n,p.customType=r}return oe(this._iid,(function(t){if(!h&&p&&p._validate()){var n=o.bUpdateUserMessage(l(l({channelUrl:s.url,messageId:e},p),{},{mentionType:p._mentionType,mentionedUserIds:p._mentionedUserIds})),r=ki.getInstance(s._iid),i=Ae.of(s._iid),a=Ie.of(s._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var o=[e,n];n=o[0],e=o[1]}var c=null;n||(c=new u(l(l({},e.getJsonElement()),{},{messageParams:p})),s.isGroupChannel()&&i.upsert([c],de.SUCCEEDED).then((function(){a.send({source:Ce.EVENT_MESSAGE_UPDATED,payload:{channel:s,message:c}})})).catch((function(e){J.error(e)}))),t(n,c)}))}else t(tt.error,null)}),i)}},{key:"translateUserMessage",value:function(e,t,n){var r=this,i=ki.getInstance(this._iid),s=x.get(this._iid),a=s.UserMessage,o=null,l=tt.parse(arguments,[new tt({type:a,constraint:function(e){return e.channelUrl===r.url&&e.sendingStatus===i.MessageSendingStatus.SUCCEEDED}}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),u=C(l,4);return o=u[0],e=u[1],t=u[2],n=u[3],oe(this._iid,(function(n){o?n(o,null):U.get(r._iid).container.apiClient.translateUserMessage({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),messageId:e.messageId,translationTargetLanguages:t},(function(e,t){var r=null;e||(r=new a(t)),n(e,r)}))}),n)}},{key:"_parsePendingFileMessage",value:function(e){var t=e._messageParams.serialize(),n=t.data,r=t.customType,i=t.fileUrl,s=t.thumbnailSizes,a=t.mentionType,o=t.mentionedUserIds,l=t.metaArrays,u=t.parentMessageId,c=t.pushNotificationDeliveryOption,d=e._messageParams;return{file:d.file?d.file:i,name:e.name,type:e.type,size:e.size,data:n,customType:r,thumbnailSizes:s,metaArrays:l,mentionType:a,mentionedUserIds:o,pushNotificationDeliveryOption:c,rootMessageId:u,parentMessageId:u,appleCriticalAlertOptions:d.appleCriticalAlertOptions,messageParams:e._messageParams,silent:e.silent,error:null,progressHandler:null,callback:null}}},{key:"_parseFileMessageArguments",value:function(e){var t=x.get(this._iid),n=t.BaseMessageParams,r=t.FileMessageParams,i={error:null,file:null,name:null,type:null,size:null,data:"",customType:"",thumbnailSizes:[],metaArrays:[],mentionType:n.MentionType.USERS,mentionedUserIds:[],pushNotificationDeliveryOption:r.PushNotificationDeliveryOption.DEFAULT,rootMessageId:null,parentMessageId:null,progressHandler:null,silent:!1,appleCriticalAlertOptions:null,isReplyToChannel:!1,messageParams:null,callback:null};if("function"==typeof e[e.length-1]&&(i.callback=e.pop()),"function"==typeof e[e.length-1]&&(i.progressHandler=e.pop()),e[0]instanceof r)i.file=e[0].file||e[0].fileUrl,i.name=e[0].fileName,i.type=e[0].mimeType,i.size=e[0].fileSize,i.data=e[0].data,i.customType=e[0].customType,i.thumbnailSizes=e[0].thumbnailSizes,i.metaArrays=e[0].metaArrays,i.mentionType=e[0]._mentionType,i.mentionedUserIds=e[0]._mentionedUserIds,i.pushNotificationDeliveryOption=e[0].pushNotificationDeliveryOption?e[0].pushNotificationDeliveryOption:r.PushNotificationDeliveryOption.DEFAULT,i.rootMessageId=e[0].rootMessageId,i.parentMessageId=e[0].parentMessageId,i.silent=e[0].silent,e[0]._validate()||(i.error=tt.error),i.appleCriticalAlertOptions=e[0].appleCriticalAlertOptions,i.isReplyToChannel=e[0].isReplyToChannel,i.messageParams=e[0];else if(ie.isFile(e[0])||"string"==typeof e[0]){switch(i.file=e[0],e.length){case 1:break;case 2:i.data=e[1];break;case 3:i.data=e[1],i.customType=e[2];break;case 4:i.data=e[1],i.customType=e[2],i.thumbnailSizes=e[3];break;case 5:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4];break;case 6:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4],i.customType=e[5];break;case 7:i.name=e[1],i.type=e[2],i.size=e[3],i.data=e[4],i.customType=e[5],i.thumbnailSizes=e[6]}var s=C(tt.parse([i.file,i.name,i.type,i.size,i.data,i.customType,i.thumbnailSizes],[new tt({type:["file","string"]}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"number",nullable:!0,constraint:function(e){return e>=0}}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"array"})]),8);i.error=s[0],i.file=s[1],i.name=s[2],i.type=s[3],i.size=s[4],i.data=s[5],i.customType=s[6],i.thumbnailSizes=s[7];var a=ie.isFile(i.file);a&&(i.name=i.name||i.file.name,i.type=i.type||i.file.type,i.size=i.size||i.file.size),i.messageParams={mentionType:n.MentionType.USERS,mentionedUserIds:i.mentionedUserIds,cachedMentionedUsers:[],cachedMentionedUserIds:[],metaArrays:i.metaArrays,parentMessageId:i.parentMessageId,pushNotificationDeliveryOption:i.pushNotificationDeliveryOption,appleCriticalAlertOptions:i.appleCriticalAlertOptions,fileName:i.name,mimeType:i.type,fileSize:i.size,data:i.data,customType:i.customType,isUpdate:!1,file:a?i.file:null,fileUrl:a?null:i.file,thumbnailSizes:i.thumbnailSizes}}else i.error=tt.error;return ie.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 t=ki.getInstance(this._iid),n=x.get(this._iid),r=n.Command,i=n.FileMessage,s=l(l({},e),{},{messageId:0,reqId:r.generateRequestId(),user:t.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:t.MessageSendingStatus.PENDING,createdAt:(new Date).getTime()}),a=i.objectify(s);return new i(a)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this,t=tt.toArray(arguments),n=this._parseFileMessageArguments(t),r=x.get(this._iid),i=r.Command,s=null,a=i.generateRequestId();n.error||((s=this._createTempFileMessage(n)).requestedMentionUserIds=n.mentionedUserIds,a=s.reqId);var o=ki.getInstance(this._iid);if(o&&o.currentUser||(n.error=new H("Connection should be made first.",H.CONNECTION_REQUIRED)),this.isGroupChannel()){var l=Ae.of(this._iid),u=Ie.of(this._iid);l.upsert([s],de.UNSENT).then((function(){u.send({source:Ce.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:e,message:s}})}))}var c=x.get(this._iid),d=c.FileMessageQueue,h=d.create(this);return h.addJob(new d.Job({fileInfo:n,pendingMessage:s,requestId:a,error:n.error,response:null})),s}},{key:"sendFileMessages",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.progress?n.progress:function(){},i=n.sent?n.sent:function(){},s=n.complete?n.complete:function(){};if(Array.isArray(e)&&e.length>0&&e.length<=20){var a=[];return e.forEach((function(n,o){a.push(t.sendFileMessage(n,r,(function(t,n){i(t,n),o===e.length-1&&s(null)})))})),a}return s(tt.error),null}},{key:"resendFileMessage",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.FileMessage,a=i.FileMessageParams,o=null,l=tt.parse(arguments,[new tt({type:s,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 tt({type:"file",optionalIf:function(e){return!!e[0].plainUrl},defaultValue:null}),new tt({type:"callback"})]),u=C(l,4);return o=u[0],e=u[1],t=u[2],n=u[3],oe(this._iid,(function(n){if(o)o.message+=" Please check if the failed message is resend-able with `message.isResendable().`",n(o,null);else{var i=new a;e.plainUrl?i.fileUrl=e.plainUrl:i.file=t,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,n)}}),n)}},{key:"updateFileMessage",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.Command,o=s.FileMessage,u=s.FileMessageParams,c=arguments,d=null,h=null;if("number"==typeof e)switch(c.length){case 3:var p=tt.parse(c,[new tt({type:"number"}),new tt({type:u}),new tt({type:"callback"})]),f=C(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 _=tt.parse(c,[new tt({type:"number"}),new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),g=C(_,5);d=g[0],e=g[1],t=g[2],n=g[3],r=g[4],h.data=t,h.customType=n,h._isUpdate=!0}return oe(this._iid,(function(t){if(!d&&h&&h._validate()){var n=a.bUpdateFileMessage(l(l({channelUrl:i.url,messageId:e},h),{},{mentionType:h._mentionType,mentionedUserIds:h._mentionedUserIds})),r=ki.getInstance(i._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var s=[e,n];n=s[0],e=s[1]}var a=null;if(!n&&(a=new o(l(l({},e.getJsonElement()),{},{messageParams:h})),i.isGroupChannel())){var u=Ae.of(i._iid),c=Ie.of(i._iid);u.upsert([a],de.SUCCEEDED).then((function(){c.send({source:Ce.EVENT_MESSAGE_UPDATED,payload:{channel:i,message:a}})})).catch((function(e){J.error(e)}))}t(n,a)}))}else t(tt.error,null)}),r)}},{key:"cancelUploadingFileMessage",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:["number","string"]}),new tt({type:"callback"})]),i=C(r,3);n=i[0],e=i[1],t=i[2];var s=U.get(this._iid),a=s.container.isErrorFirstInCallback;if(n)return a?t(n,null):t(null,n),!1;var o=x.get(this._iid),l=o.FileMessageQueue,u=l.create(this);return u.cancelUploadItemByRequestId(e,(function(e,n){return a?t(e,n):t(n,e)}))}},{key:"addReaction",value:function(e,t,n){var r=this,i=ki.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=tt.parse(arguments,[new tt({type:St}),new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),c=C(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?U.get(r._iid).container.apiClient.addReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:t},(function(t,r){var i=null;t||(i=a.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),n(t,i)})):n(new H("Cannot add reaction to a non-succeeded message.",H.REQUEST_FAILED),null)}),n)}},{key:"deleteReaction",value:function(e,t,n){var r=this,i=ki.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=tt.parse(arguments,[new tt({type:St}),new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),c=C(u,4);return o=c[0],e=c[1],t=c[2],n=c[3],oe(this._iid,(function(n){o?n(o,null):e.sendingStatus===i.MessageSendingStatus.SUCCEEDED?U.get(r._iid).container.apiClient.deleteReaction({isGroupChannel:e.isGroupChannel(),channelUrl:e.channelUrl,messageId:e.messageId,key:t},(function(t,r){var i=null;t||(i=a.createFromJson(l(l({},r),{},{msg_id:e.messageId}))),n(t,i)})):n(new H("Cannot remove reaction to a non-succeeded message.",H.REQUEST_FAILED),null)}),n)}},{key:"deleteMessage",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMessage({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),messageId:e.messageId},(function(r,i){if(!r&&n.isGroupChannel()){var s=Ae.of(n._iid),a=Ie.of(n._iid);s.remove([e.messageId],de.SUCCEEDED).then((function(){a.send({source:Ce.EVENT_MESSAGE_DELETED,payload:{channel:n,message:e}})})).catch((function(e){return J.error(e)}))}t(r,null)}))}),t)}},{key:"copyUserMessage",value:function(t,n,r){var i=x.get(this._iid);i.Command;var s=i.UserMessage,a=i.BaseMessageParams,o=null,u=tt.parse(arguments,[new tt({type:e}),new tt({type:s}),new tt({type:"callback"})]),c=C(u,4);o=c[0],t=c[1],n=c[2],r=c[3];var d=U.get(this._iid),h=d.container.isErrorFirstInCallback;if(o)return h?r(tt.error,null):r(null,tt.error),null;if(this.url!==n.channelUrl){var p=new H("The message does not belong to this channel",H.INVALID_PARAMETER);return h?r(p,null):r(null,p),null}var f={},_=Object.keys(n.translations);_.forEach((function(e){return f[e]=""}));var g=a.PushNotificationDeliveryOption.DEFAULT;return t._sendUserMessage(l(l({},n),{},{reqId:null,pushNotificationDeliveryOption:g,translationTargetLanguages:_,rootMessageId:null,parentMessageId:null,parentMessageText:null,messageParams:n._messageParams,callback:r}))}},{key:"copyFileMessage",value:function(t,n,r){var i=this,s=x.get(this._iid),a=s.Command;s.GroupChannel;var o=s.FileMessage,l=s.BaseMessageParams;s.FileMessageParams;var u=s.User,c=null,d=tt.parse(arguments,[new tt({type:e}),new tt({type:o}),new tt({type:"callback"})]),h=C(d,4);c=h[0],t=h[1],n=h[2],r=h[3];var p=U.get(this._iid),f=p.container.isErrorFirstInCallback;if(c)return f?r(tt.error,null):r(null,tt.error),null;if(this.url!==n.channelUrl){var _=new H("The message does not belong to this channel");return f?r(_,null):r(null,_),null}var g=ki.getInstance(this._iid),y=n,m=y.url,E=y.name,v=y.type,b=y.size,A=y.data,N=y.customType,S=y.mentionType,I=y.mentionedUserIds,T=y.mentionedUsers,O=y.metaArrays,k=y.thumbnails,R=y.requireAuth,M=y.messageSurvivalSeconds,P=y.silent,L=y.appleCriticalAlertOptions,w=a.generateRequestId(),D=g.currentUser||{},F=t.url,G=t.isOpenChannel(),j=T.filter((function(e){return new u(u.objectify(e))})),B=l.PushNotificationDeliveryOption.DEFAULT,V=o.objectify({messageId:0,reqId:w,user:D,channel:t,plainUrl:m,name:E,type:v,size:b,data:A,customType:N,mentionType:S,mentionedUserIds:I,mentionedUsers:j,requestedMentionUserIds:I,metaArrays:O,thumbnails:k,requireAuth:R,messageSurvivalSeconds:M,silent:P,createdAt:(new Date).getTime(),appleCriticalAlertOptions:L}),K=new o(V);if(K.requestState=g.MessageRequestState.PENDING,K.sendingStatus=g.MessageSendingStatus.PENDING,!g.currentUser){var q=new H("Connection should be made first.",H.CONNECTION_REQUIRED),z=new o(V);return z.requestState=g.MessageRequestState.FAILED,z.sendingStatus=g.MessageSendingStatus.FAILED,z.errorCode=q.code,f?r(q,z):r(z,q),K}var Y=a.bFile({requestId:w,channelUrl:F,url:m,name:E,type:v,size:b,data:A,customType:N,metaArrays:O,mentionType:S,mentionedUserIds:I,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:B,silent:P,appleCriticalAlertOptions:L});return g.getConnectionState()===g.ConnectionState.OPEN||g.connecting||g.reconnecting?g.sendCommand(Y,(function(e,n){if(g.getErrorFirstCallback()){var s=[e,n];n=s[0],e=s[1]}if(n)if(n.code!==H.INVALID_PARAMETER){var a=new o(V);a.requestState=g.MessageRequestState.FAILED,a.sendingStatus=g.MessageSendingStatus.FAILED,n.code!==H.FILE_UPLOAD_CANCEL_FAILED&&n.code!==H.REQUEST_CANCELED||(a.sendingStatus=g.MessageSendingStatus.CANCELED),a.errorCode=n.code,f?r(n,a):r(a,n)}else f?r(n,null):r(null,n);else{var l=new o(e.getJsonElement()),u=l._sender;if(D&&u&&D.userId===u.userId&&(D.nickname!==u.nickname&&(D.nickname=u.nickname),D.plainProfileUrl!==u.plainProfileUrl&&(D.plainProfileUrl=u.plainProfileUrl)),t.isGroupChannel()){t.lastMessage=l,Object.keys(g.channelHandlers).forEach((function(e){g.channelHandlers[e].onChannelChanged(t)}));var c=Ie.of(i._iid);Et.of(i._iid).upsert([t]).then((function(){c.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).catch((function(e){J.error(e)})),Ae.of(i._iid).upsert([l]).then((function(){c.send({source:Ce.EVENT_MESSAGE_SENT,payload:{channel:i,message:l}})})).catch((function(e){J.error(e)}))}f?r(null,l):r(l,null)}})):p.container.apiClient.sendFileMessage({channelUrl:F,isOpenChannel:G,fileUrl:m,fileName:E,fileType:v,fileSize:b,data:A,customType:N,metaArrays:O,mentionType:S,mentionedUserIds:I,thumbnailSizes:k,requireAuth:R,pushNotificationDeliveryOption:B,appleCriticalAlertOptions:L},(function(e,n){if(e)if(e.code!==H.INVALID_PARAMETER){var i=new o(commnad.getJsonElement());i.requestState=g.MessageRequestState.FAILED,i.sendingStatus=g.MessageSendingStatus.FAILED,e.code!==H.FILE_UPLOAD_CANCEL_FAILED&&e.code!==H.REQUEST_CANCELED||(i.sendingStatus=g.MessageSendingStatus.CANCELED),i.errorCode=e.code,f?r(e,i):r(i,e)}else f?r(e,null):r(null,e);else{var s=new o(n),a=s._sender;D&&a&&D.userId===a.userId&&(D.nickname!==a.nickname&&(D.nickname=a.nickname),D.plainProfileUrl!==a.plainProfileUrl&&(D.plainProfileUrl=a.plainProfileUrl)),t.isGroupChannel()&&(t.lastMessage=s,Object.keys(g.channelHandlers).forEach((function(e){g.channelHandlers[e].onChannelChanged(t)}))),f?r(null,s):r(s,null)}})),K}},{key:"addOperators",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.addOperators({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),operatorUserIds:e},(function(e,n){return t(e,n)}))}),t)}},{key:"removeOperators",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.removeOperators({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),operatorUserIds:e},(function(e,n){return t(e,n)}))}),t)}},{key:"getMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),keys:e},(function(e,n){return t(e,n)}))}),t)}},{key:"getAllMetaCounters",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),keys:[]},(function(t,n){return e(t,n)}))}),e)}},{key:"createMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.createMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e},(function(e,n){return t(e,n)}))}),t)}},{key:"updateMetaCounters",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateMetaCounters({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaCounter:e,upsert:t,mode:"set"},(function(e,t){return n(e,t)}))}),n)}},{key:"increaseMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e,upsert:!1,mode:"increase"},(function(e,n){return t(e,n)}))}),t)}},{key:"decreaseMetaCounters",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateMetaCounters({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaCounter:e,upsert:!1,mode:"decrease"},(function(e,n){var r=null;e||(r={},Object.keys(n).forEach((function(e){r[e]=n[e]}))),t(e,r)}))}),t)}},{key:"deleteMetaCounter",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMetaCounter({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),key:e},(function(e,n){return t(e,n)}))}),t)}},{key:"deleteAllMetaCounters",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteAllMetaCounters({channelUrl:t.url,isOpenChannel:t.isOpenChannel()},(function(t,n){return e(t,n)}))}),e)}},{key:"getCachedMetaData",value:function(){var e=Ot.get(this),t={};return Object.keys(e).forEach((function(n){var r=e[n];r.isRemoved||(t[n]=r.value)})),t}},{key:"getMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),keys:e},(function(e,n){t(e,n&&n.ts?n.metadata:n)}))}),t)}},{key:"getAllMetaData",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMetaData({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),keys:[]},(function(t,n){e(t,n&&n.ts?n.metadata:n)}))}),e)}},{key:"createMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.createMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),metaData:e},(function(e,n){t(e,n&&n.ts?n.metadata:n)}))}),t)}},{key:"updateMetaData",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateMetaData({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),metaData:e,upsert:t},(function(e,t){n(e,t&&t.ts?t.metadata:t)}))}),n)}},{key:"deleteMetaData",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteMetaData({channelUrl:n.url,isOpenChannel:n.isOpenChannel(),key:e},(function(e,n){t(e,n&&n.ts?{}:n)}))}),t)}},{key:"deleteAllMetaData",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteAllMetaData({channelUrl:t.url,isOpenChannel:t.isOpenChannel()},(function(t,n){return e(t,n&&n.ts?{}:n)}))}),e)}},{key:"_updateMessageMetaArray",value:function(e,t,n,r){var i=this;return oe(this._iid,(function(r){var s=x.get(i._iid),a=s.Command,o=s.UserMessage,l=s.FileMessage,u=s.AdminMessage,c=null;if(t.isUserMessage()?c=a.bUpdateUserMessage({channelUrl:e,messageId:t.messageId,metaArrayParams:n}):t.isFileMessage()&&(c=a.bUpdateFileMessage({channelUrl:e,messageId:t.messageId,metaArrayParams:n})),c){var d=ki.getInstance(i._iid);d.sendCommand(c,(function(e,n){if(d.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}var s=null;n||(t.isUserMessage()?s=new o(e.getJsonElement()):t.isFileMessage()?s=new l(e.getJsonElement()):t.isAdminMessage()&&(s=new u(e.getJsonElement()))),r(n,s)}))}else r(tt.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=tt.parse(arguments,[new tt({type:St}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new tt({type:"callback"})]),o=C(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=[];if(Array.isArray(t))for(var u=0;u0&&e.every((function(e){return e instanceof i}))||Object.keys(e).length>0&&Object.keys(e).every((function(t){return Array.isArray(e[t])&&e[t].length>0&&e[t].every((function(e){return"string"==typeof e&&e.length>0}))})))}}),new tt({type:"callback"})]),o=C(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=Array.isArray(t)?t.map((function(e){return e.encode()})):Object.keys(t).map((function(e){return{key:e,value:t[e]}}));return this._updateMessageMetaArray(this.url,e,{array:l,mode:"add",upsert:!0},n)}},{key:"removeMessageMetaArrayValues",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=tt.parse(arguments,[new tt({type:St}),new tt({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(t){return Array.isArray(e[t])&&e[t].length>0&&e[t].every((function(e){return"string"==typeof e&&e.length>0}))})))}}),new tt({type:"callback"})]),o=C(a,4);if(s=o[0],e=o[1],t=o[2],n=o[3],s)return oe(this._iid,(function(e){e(s,null)}),n);var l=Array.isArray(t)?t.map((function(e){return e.encode()})):Object.keys(t).map((function(e){return{key:e,value:t[e]}}));return this._updateMessageMetaArray(this.url,e,{array:l,mode:"remove",upsert:!0},n)}},{key:"report",value:function(e,t,n){var r=this,i=x.get(this._iid),s=i.BaseChannel,a=null,o=tt.parse(arguments,[new tt({type:s.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),l=C(o,4);return a=l[0],e=l[1],t=l[2],n=l[3],oe(this._iid,(function(n){if(a)n(a,null);else{var i=ki.getInstance(r._iid);U.get(r._iid).container.apiClient.report({channelUrl:r.url,isOpenChannel:r.isOpenChannel(),reportCategory:e,reportingUserId:i.currentUser?i.currentUser.userId:null,reportDescription:t},(function(e,t){n(e,null)}))}}),n)}},{key:"reportUser",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=null,l=tt.parse(arguments,[new tt({type:It}),new tt({type:a.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),u=C(l,5);return o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],oe(this._iid,(function(r){if(o)r(o,null);else{var s=ki.getInstance(i._iid);U.get(i._iid).container.apiClient.reportUser({channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:t,offendingUserId:e.userId,reportingUserId:s.currentUser?s.currentUser.userId:null,reportDescription:n},(function(e,t){r(e,null)}))}}),r)}},{key:"reportMessage",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=null,l=tt.parse(arguments,[new tt({type:St}),new tt({type:a.ReportCategory}),new tt({type:"string"}),new tt({type:"callback"})]),u=C(l,5);return o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],oe(this._iid,(function(r){if(o)r(o,null);else{var s=ki.getInstance(i._iid);U.get(i._iid).container.apiClient.reportMessage({messageId:e.messageId,channelUrl:i.url,isOpenChannel:i.isOpenChannel(),reportCategory:t,offendingUserId:e.sender.userId,reportingUserId:s.currentUser?s.currentUser.userId:null,reportDescription:n},(function(e,t){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,t){var n=x.get(this._iid),r=n.UserMessage,i=n.FileMessage,s=n.AdminMessage;if(e)switch(e.hasOwnProperty("channel_type")||(e.channel_type=t.channelType),e.type){case"MESG":return new r(e);case"FILE":var a=e.file;return new i(l(l({},e),{},{url:String(a.url),name:String(a.name),type:String(a.type),size:parseInt(a.size),data:String(a.data)}));case"BRDM":case"ADMM":return new s(e)}return null}}]),e}(),Rt=function(){function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0,this.data=t.hasOwnProperty("data")?t.data:null,this.channelUrl=t.hasOwnProperty("channel_url")?String(t.channel_url):"",this.channelType=t.hasOwnProperty("channel_type")?String(t.channel_type):kt.CHANNEL_TYPE_GROUP)}return h(e,[{key:"isGroupChannel",value:function(){return this.channelType===kt.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===kt.CHANNEL_TYPE_OPEN}}]),e}();Rt.CATEGORY_NONE=0,Rt.CATEGORY_CHANNEL_ENTER=10102,Rt.CATEGORY_CHANNEL_EXIT=10103,Rt.CATEGORY_USER_CHANNEL_MUTE=10201,Rt.CATEGORY_USER_CHANNEL_UNMUTE=10200,Rt.CATEGORY_USER_CHANNEL_BAN=10601,Rt.CATEGORY_USER_CHANNEL_UNBAN=10600,Rt.CATEGORY_CHANNEL_FREEZE=10701,Rt.CATEGORY_CHANNEL_UNFREEZE=10700,Rt.CATEGORY_TYPING_START=10900,Rt.CATEGORY_TYPING_END=10901,Rt.CATEGORY_CHANNEL_JOIN=1e4,Rt.CATEGORY_CHANNEL_LEAVE=10001,Rt.CATEGORY_CHANNEL_OPERATOR_UPDATE=10002,Rt.CATEGORY_CHANNEL_INVITE=10020,Rt.CATEGORY_CHANNEL_DECLINE_INVITE=10022,Rt.CATEGORY_CHANNEL_PROP_CHANGED=11e3,Rt.CATEGORY_CHANNEL_DELETED=12e3,Rt.CATEGORY_CHANNEL_META_DATA_CHANGED=11100,Rt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED=11200,Rt.CATEGORY_CHANNEL_HIDE=13e3,Rt.CATEGORY_CHANNEL_UNHIDE=13001;var Mt=function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0)};Mt.CATEGORY_USER_BLOCK=20001,Mt.CATEGORY_USER_UNBLOCK=2e4,Mt.CATEGORY_FRIEND_DISCOVERED=20900;var Pt=function(){function e(t){c(this,e),this.sb=t,this.cls=x.get(this.sb._iid)}return h(e,[{key:"onRawCommandReceived",value:function(e){var t=this,n=this.cls,r=n.Command,i=n.User,s=n.Member,a=n.RestrictedUser,o=n.BaseChannel,c=n.GroupChannel,d=n.OpenChannel,h=n.UserMessage,p=n.FileMessage,f=n.AdminMessage,_=n.BaseMessageParams,g=n.ReactionEvent,y=n.ReadStatus,m=n.ThreadInfoUpdateEvent,E=n.PollUpdateEvent,v=n.PollVoteEvent,b=n.RestrictionInfo,C=U.get(this.sb._iid),A=C.container,N=A.pinger,S=A.auth,O=A.subscribedUnreadMessageCount,k=A.sessionManager,R=A.ackStateMap,M=new r(e),P=M.getJsonElement();if(P.hasOwnProperty("unread_cnt")&&"object"===u(P.unread_cnt)){var L=!1,w=P.unread_cnt.ts;"number"==typeof w&&w>O.ts&&(O.all!==P.unread_cnt.all&&(L=!0),O.all=P.unread_cnt.all>=0?P.unread_cnt.all:0,P.unread_cnt.custom_types&&Object.keys(P.unread_cnt.custom_types).forEach((function(e){O.custom_types[e]!==P.unread_cnt.custom_types[e]&&(L=!0),O.custom_types[e]=P.unread_cnt.custom_types[e]})),L=L&&O.ts>0,O.ts=w),L&&Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onTotalUnreadMessageCountUpdated(O.all,O.custom_types)}))}var D=M.requestId;if(D){var F=R[D];if(F){clearTimeout(F.timer);var G=F.handler;G&&("EROR"===M.command?G(new H(P.message,P.code),null):G(null,M)),R.hasOwnProperty(D)&&delete R[D]}}else{N&&"LOGI"!==M.command&&N.refreshTimer();var x=Et.of(this.sb._iid),j=Ae.of(this.sb._iid),B=Ie.of(this.sb._iid);switch(M.command){case"LOGI":if(this.sb.loginTimer)if(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,P.hasOwnProperty("error"))this.sb.isSessionOpened=!1,this.sb.loginHandler(new H(P.message,P.code),null);else{if(this.sb.isSessionOpened=!0,P.hasOwnProperty("key")&&(S.sessionKey=P.key),P.hasOwnProperty("ekey")&&(S.eKey=P.ekey),P.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(P)),"number"==typeof P.ping_interval&&P.ping_interval>0&&C.set("pingInterval",1e3*P.ping_interval),"number"==typeof P.pong_timeout&&P.pong_timeout>0&&C.set("pongTimeout",1e3*P.pong_timeout),"number"==typeof P.login_ts){var V=1e3*P.login_ts;C.set("connectedAt",V),C.container.firstConnectedAt||C.set("firstConnectedAt",V)}"number"==typeof P.max_unread_cnt_on_super_group?C.set("maxUnreadCountOfSuperGroupChannel",P.max_unread_cnt_on_super_group):C.set("maxUnreadCountOfSuperGroupChannel",T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),P.profile_image_encryption&&C.set("profileImageEncryption",!0),N&&N.start(),P.hasOwnProperty("file_upload_size_limit")&&P.hasOwnProperty("premium_feature_list")&&P.hasOwnProperty("emoji_hash")&&C.set("appInfo",new $e(P)),P.hasOwnProperty("concurrent_call_limit")&&P.hasOwnProperty("back_off_delay")&&(C.set("concurrentCallLimit",P.concurrent_call_limit),C.set("backOffDelay",P.back_off_delay)),this.sb.loginHandler(null,this.sb.currentUser)}break;case"EXPR":var K=new H("The session would be expired.",P.reason||H.SESSION_KEY_EXPIRED);k.refreshSessionIfExpiredError(K).then((function(){})).catch((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var q=null;if("MESG"===M.command?q=new h(P):"FILE"===M.command?q=new p(P):"BRDM"!==M.command&&"ADMM"!==M.command||(q=new f(P)),q){var z=this.sb.currentUser?this.sb.currentUser.userId:null,Y=q.silent,Q=!!P.force_update_last_message,W=q._sender&&q._sender.userId===z;if(q.isGroupChannel()){var X=c.cachedChannels.hasOwnProperty(q.channelUrl);c.getChannel(q.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}if(!n){if(!C.container.appInfo.isSupergroupMackDisabled||!e.isSuper||e.isBroadcast){var s=r.bMessageAck({channelUrl:q.channelUrl,messageId:q.messageId});t.sb.sendCommand(s)}if(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,q._sender&&e.memberMap.hasOwnProperty(q._sender.userId)){var a=e.memberMap[q._sender.userId];a.nickname!==q._sender.nickname&&(a.nickname=q._sender.nickname),a.plainProfileUrl!==q._sender.plainProfileUrl&&(a.plainProfileUrl=q._sender.plainProfileUrl),ie.deepEqual(a.metaData,q._sender.metaData)||(a.metaData=q._sender.metaData),a.isBlockedByMe!==q._sender.isBlockedByMe&&(a.isBlockedByMe=q._sender.isBlockedByMe)}var o=t.sb.currentUser;o&&W&&(o.nickname!==q._sender.nickname&&(o.nickname=q._sender.nickname),o.plainProfileUrl!==q._sender.plainProfileUrl&&(o.plainProfileUrl=q._sender.plainProfileUrl),ie.deepEqual(o.metaData,q._sender.metaData)||(o.metaData=q._sender.metaData));var l=!1;if(q.mentionType===_.MentionType.CHANNEL)W||(l=!0);else if(q.mentionType===_.MentionType.USERS)for(var u=0;u=Z.createAt,a=t.sb.currentUser;a&&te&&(a.nickname!==Z._sender.nickname&&(a.nickname=Z._sender.nickname),a.plainProfileUrl!==Z._sender.plainProfileUrl&&(a.plainProfileUrl=Z._sender.plainProfileUrl),ie.deepEqual(a.metaData,Z._sender.metaData)||(a.metaData=Z._sender.metaData));var o=!1,l=!1;if(!te&&!s&&P&&P.hasOwnProperty("old_values")){var u=P.old_values.mention_type||Z.mentionType,c=P.old_values.mentioned_user_ids||Z.mentionedUsers.map((function(e){return e.userId}));if(u===_.MentionType.USERS&&Z.mentionType===_.MentionType.USERS){for(var d=!1,h=!1,p=0;p0||e.unreadMentionCount>0)&&(e._setGroupChannelUnreadCount(0,0),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReadReceiptUpdated(e)})),B.send({source:Ce.EVENT_READ_RECEIPT_UPDATED,payload:{channel:e,user:oe.reader}})))}));break;case"MRCT":var ue=String(P.channel_type),ce=String(P.channel_url),de=g.createFromJson(P);switch(ue){case o.CHANNEL_TYPE_GROUP:c.getChannel(ce,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,de)})),j.get("".concat(de.messageId)).then((function(n){n&&(n.applyReactionEvent(de),j.upsert([n]).then((function(){B.send({source:Ce.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:de}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(ce,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,de)})),B.send({source:Ce.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:de}}))}))}break;case"DLVR":var he=String(P.channel_url),pe=P.hasOwnProperty("updated")?P.updated:null,fe=c.cachedChannels.hasOwnProperty(he);c.getChannel(he,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(!n){var i=!1;Object.keys(pe).forEach((function(n){t.sb.currentUser&&n===t.sb.currentUser.userId&&(i=!0),fe&&e.updateDeliveryReceipt(n,parseInt(pe[n]))})),c.cachedChannels[e.url]=e,i&&1===Object.keys(pe).length||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onDeliveryReceiptUpdated(e)})),B.send({source:Ce.EVENT_DELIVERY_RECEIPT_UPDATED,payload:{channel:e}}))}}));break;case"MTHD":var _e=String(P.channel_url),ge=String(P.channel_type),ye=m.createFromJson(P);switch(ge){case o.CHANNEL_TYPE_GROUP:c.getChannel(_e,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onThreadInfoUpdated(e,ye)})),j.get("".concat(ye.targetMessageId)).then((function(n){n&&(n.applyThreadInfoUpdateEvent(ye),j.upsert([n]).then((function(){B.send({source:Ce.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:ye}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(_e,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onThreadInfoUpdated(e,ye)})),B.send({source:Ce.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:ye}}))}))}break;case"MCNT":if(P.hasOwnProperty("group_channels")&&Array.isArray(P.group_channels)){var me,Ee=[],ve=I(P.group_channels);try{for(ve.s();!(me=ve.n()).done;){var be=me.value;if(be){var Ne=c.cachedChannels[be.channel_url];if(Ne&&Ne.isBroadcast)Ne.setLatestMemberCount(be.member_count,be.joined_member_count,be.ts)&&Ee.push(Ne)}}}catch(e){ve.e(e)}finally{ve.f()}Ee.length>0&&(Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelMemberCountChanged(Ee)})),x.upsert(Ee).then((function(){var e,t=I(Ee);try{for(t.s();!(e=t.n()).done;){var n=e.value;B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:n}})}}catch(e){t.e(e)}finally{t.f()}})).catch((function(e){t.handleCacheError(e)})))}if(P.hasOwnProperty("open_channels")&&Array.isArray(P.open_channels)){var Se,Te=[],Oe=I(P.open_channels);try{for(Oe.s();!(Se=Oe.n()).done;){var Ue=Se.value;if(Ue){var ke=d.cachedChannels[Ue.channel_url];if(ke)ke.setLatestParticipantCount(Ue.participant_count,Ue.ts)&&Te.push(ke)}}}catch(e){Oe.e(e)}finally{Oe.f()}if(Te.length>0){Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelParticipantCountChanged(Te)}));var Re,Me=I(Te);try{for(Me.s();!(Re=Me.n()).done;){var Pe=Re.value;B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:Pe}})}}catch(e){Me.e(e)}finally{Me.f()}}}break;case"PEDI":var Le=E.createFromJson(P);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollUpdated(Le)}));break;case"VOTE":var we=v.createFromJson(P);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollVoted(we)}));break;case"SYEV":var De=new Rt(P),He=P.ts;switch(De.category){case Rt.CATEGORY_CHANNEL_JOIN:case Rt.CATEGORY_CHANNEL_LEAVE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var a=De.data.hasOwnProperty("member_count")?De.data.member_count:null,o=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null,l=!1;if(De.category===Rt.CATEGORY_CHANNEL_JOIN){(De.data.hasOwnProperty("users")?De.data.users:[De.data]).forEach((function(n){e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,P.ts):(n.state=s.JOINED,e.addMember(new s(n),He),e.updateJoinedMemberCount());var r=new i(n);t.sb.currentUser&&r.userId===t.sb.currentUser.userId&&(e.myMemberState="joined",c.cachedChannels[e.url]=e),Object.keys(t.sb.channelHandlers).forEach((function(n){var i=t.sb.channelHandlers[n];i.onUserJoined(e,r),e.isBroadcast&&l&&i.onChannelMemberCountChanged([e])})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_USER_JOINED,payload:{channel:e,user:r}})})).catch((function(e){t.handleCacheError(e)}))}))}else{var u=new i(De.data);t.sb.currentUser&&u.userId===t.sb.currentUser.userId?(e.isPublic||c.removeCachedChannel(De.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)):c.cachedChannels[e.url]=e,e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,P.ts):(e.removeMember(u),e.updateJoinedMemberCount()),Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserLeft(e,u),e.isBroadcast&&l&&r.onChannelMemberCountChanged([e])})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_USER_LEFT,payload:{channel:e,user:u}})})).catch((function(e){t.handleCacheError(e)}))}}}));break;case Rt.CATEGORY_CHANNEL_OPERATOR_UPDATE:De.isGroupChannel()?c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{for(var s=De.data.operators.map((function(e){return new i(e)})),a=s.map((function(e){return e.userId})),o=0;o=0?c.Role.OPERATOR:c.Role.NONE;e.myRole=t.sb.currentUser&&a.indexOf(t.sb.currentUser.userId)>=0?c.Role.OPERATOR:c.Role.NONE,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onOperatorUpdated(e,s)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:s}})})).catch((function(e){t.handleCacheError(e)}))}})):De.isOpenChannel()&&d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.operators=De.data.operators.map((function(e){return new i(e)})),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onOperatorUpdated(e,e.operators)})),B.send({source:Ce.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:operators}}))}));break;case Rt.CATEGORY_CHANNEL_INVITE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var a=null;De.data&&De.data.inviter&&Object.keys(De.data.inviter).length>0&&(a=new i(De.data.inviter));for(var o=[],l=0;l0&&(s=new i(De.data.inviter));var a=new i(De.data.invitee);if(t.sb.currentUser&&a.userId===t.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||c.removeCachedChannel(De.channelUrl)),e.isSuper||e.isBroadcast){var o=De.data.hasOwnProperty("member_count")?De.data.member_count:null,l=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null;e.setLatestMemberCount(o,l,P.ts)}else e.removeMember(a);t.sb.currentUser&&a.userId!==t.sb.currentUser.userId&&(c.cachedChannels[e.url]=e),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserDeclinedInvitation(e,s,a)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_USER_DECLINED_INVITATION,payload:{channel:e,inviter:s,invitee:a}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_TYPING_START:case Rt.CATEGORY_TYPING_END:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var s=new i(De.data);De.category===Rt.CATEGORY_TYPING_START?e.updateTypingStatus(s,!0):e.updateTypingStatus(s,!1),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onTypingStatusUpdated(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_TYPING_STATUS_UPDATED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_CHANNEL_ENTER:case Rt.CATEGORY_CHANNEL_EXIT:d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var s=De.data.hasOwnProperty("participant_count")?De.data.participant_count:null,a=e.setLatestParticipantCount(s,P.ts),o=new i(De.data);De.category===Rt.CATEGORY_CHANNEL_ENTER?(Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserEntered(e,o),a&&r.onChannelParticipantCountChanged([e])})),B.send({source:Ce.EVENT_CHANNEL_ENTER,payload:{channel:e,user:o}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){var r=t.sb.channelHandlers[n];r.onUserExited(e,o),a&&r.onChannelParticipantCountChanged([e])})),B.send({source:Ce.EVENT_CHANNEL_EXIT,payload:{channel:e,user:o}}))}}));break;case Rt.CATEGORY_USER_CHANNEL_MUTE:case Rt.CATEGORY_USER_CHANNEL_UNMUTE:var Fe=De.category===Rt.CATEGORY_USER_CHANNEL_MUTE,Ge=l({},De.data);Fe&&(Ge.restriction_type=a.RestrictionType.MUTED);var xe=Fe?new a(Ge):new i(De.data),je=Fe?"muted":"unmuted";De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):Fe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,xe)})),B.send({source:Ce.EVENT_USER_MUTED,payload:{channel:e,user:xe}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,xe)})),B.send({source:Ce.EVENT_USER_UNMUTED,payload:{channel:e,user:xe}}))})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(t.sb.currentUser&&xe.userId===t.sb.currentUser.userId&&(e.myMutedState=je),Array.isArray(e.members)&&e.members.filter((function(e){return e&&e.userId===xe.userId})).forEach((function(e){e.isMuted=Fe,e.restrictionInfo=new b(Ge)})),Fe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,xe)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_USER_MUTED,payload:{channel:e,user:xe}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,xe)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_USER_UNMUTED,payload:{channel:e,user:xe}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Rt.CATEGORY_USER_CHANNEL_BAN:case Rt.CATEGORY_USER_CHANNEL_UNBAN:var Be=De.category===Rt.CATEGORY_USER_CHANNEL_BAN,Ve=l({},De.data);Be&&(Ve.restriction_type=a.RestrictionType.BANNED);var Ke=Be?new a(Ve):new i(De.data);De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else if(Be){if(t.sb.currentUser&&Ke.userId===t.sb.currentUser.userId)delete d.enteredChannels[De.channelUrl],t.cls.FileMessageQueue.delete(De.channelUrl);Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,Ke)})),B.send({source:Ce.EVENT_USER_BANNED,payload:{channel:e,user:Ke}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,Ke)})),B.send({source:Ce.EVENT_USER_UNBANNED,payload:{channel:e,user:Ke}})})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else if(Be){if(t.sb.currentUser&&Ke.userId===t.sb.currentUser.userId&&(e.isPublic||c.removeCachedChannel(De.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var i=De.data.hasOwnProperty("member_count")?De.data.member_count:null,s=De.data.hasOwnProperty("joined_member_count")?De.data.joined_member_count:null;e.setLatestMemberCount(i,s,P.ts)}else e.removeMember(Ke),e.updateJoinedMemberCount();Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,Ke)})),B.send({source:Ce.EVENT_USER_BANNED,payload:{channel:e,user:Ke}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,Ke)})),B.send({source:Ce.EVENT_USER_UNBANNED,payload:{channel:e,user:Ke}})}));break;case Rt.CATEGORY_CHANNEL_FREEZE:case Rt.CATEGORY_CHANNEL_UNFREEZE:De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.isFrozen=De.data.freeze,d.cachedChannels[e.url]=e,De.category===Rt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),B.send({source:Ce.EVENT_CHANNEL_FROZEN,payload:{channel:e}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),B.send({source:Ce.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})))})):c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(e.isFrozen=De.data.freeze,c.cachedChannels[e.url]=e,De.category===Rt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_FROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Rt.CATEGORY_CHANNEL_DELETED:De.isGroupChannel()?c.removeCachedChannel(De.channelUrl):d.removeCachedChannel(De.channelUrl);var qe=De.channelUrl,ze=De.isGroupChannel()?"group":"open";Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelDeleted(qe,ze)})),x.remove([qe]).then((function(){B.send({source:Ce.EVENT_CHANNEL_DELETED,payload:{channelUrl:qe,channelType:ze}})})).catch((function(e){t.handleCacheError(e)}));break;case Rt.CATEGORY_CHANNEL_PROP_CHANGED:De.isOpenChannel()?d.getChannelWithoutCache(De.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:e}}))})):c.getChannelWithoutCache(De.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n)J.debug("Discard command:","`".concat(M.command,"`"),De.category);else{var i=e.unreadMessageCount,s=e.unreadMentionCount;e.myCountPreference!==c.CountPreference.ALL&&(e.myCountPreference===c.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?s=0:e.myCountPreference===c.CountPreference.UNREAD_MENTION_COUNT_ONLY?i=0:(i=0,s=0)),e._setGroupChannelUnreadCount(i,s),Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Rt.CATEGORY_CHANNEL_META_DATA_CHANGED:case Rt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var Ye=De.data.hasOwnProperty("created"),Qe=De.data.hasOwnProperty("updated"),We=De.data.hasOwnProperty("deleted");(De.isOpenChannel()?d.getChannel(De.channelUrl,T.INTERNAL_CALL):c.getChannel(De.channelUrl,T.INTERNAL_CALL)).then((function(e){var n=De.data.created,r=De.data.updated,i=De.data.deleted,s=P.ts;Ye&&e._addOrUpdateCachedMetaData(n,s),Qe&&e._addOrUpdateCachedMetaData(r,s),We&&e._markAsDeletedCachedMetaData(i,s),Object.keys(t.sb.channelHandlers).forEach((function(s){var a=t.sb.channelHandlers[s];De.category===Rt.CATEGORY_CHANNEL_META_DATA_CHANGED?(Ye&&a.onMetaDataCreated(e,n),Qe&&a.onMetaDataUpdated(e,r),We&&a.onMetaDataDeleted(e,i),(Ye||Qe)&&B.send({source:Ce.EVENT_CHANNEL_METADATA_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),We&&B.send({source:Ce.EVENT_CHANNEL_METADATA_DELETED,payload:{channel:e,metaData:l({},i)}})):(Ye&&a.onMetaCountersCreated(e,n),Qe&&a.onMetaCountersUpdated(e,r),We&&a.onMetaCountersDeleted(e,i),(Ye||Qe)&&B.send({source:Ce.EVENT_CHANNEL_METACOUNTER_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),We&&B.send({source:Ce.EVENT_CHANNEL_METACOUNTER_DELETED,payload:{channel:e,metaData:l({},i)}}))}))})).catch((function(e){return J.debug("Discard command:","`".concat(M.command,"`"),De.category)}));break;case Rt.CATEGORY_CHANNEL_HIDE:case Rt.CATEGORY_CHANNEL_UNHIDE:c.getChannel(De.channelUrl,T.INTERNAL_CALL,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(M.command,"`"),De.category):De.category===Rt.CATEGORY_CHANNEL_HIDE?(e.isHidden=!0,De.data&&(De.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=De.data.allow_auto_unhide?c.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:c.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),De.data.hasOwnProperty("hide_previous_messages")&&De.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),P.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=P.ts_message_offset),c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelHidden(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_HIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))):(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),x.upsert([e]).then((function(){B.send({source:Ce.EVENT_CHANNEL_UNHIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)})))}))}break;case"USEV":var Je=new Rt(P);switch(Je.category){case Mt.CATEGORY_USER_BLOCK:case Mt.CATEGORY_USER_UNBLOCK:var Xe=Je.data.blocker.user_id,Ze=Je.data.blockee.user_id;Object.keys(c.cachedChannels).forEach((function(e){var n=c.cachedChannels[e];try{t.sb.currentUser&&(t.sb.currentUser.userId===Xe?n.memberMap[Ze].isBlockedByMe=Je.category===Mt.CATEGORY_USER_BLOCK:t.sb.currentUser.userId===Ze&&(n.memberMap[Xe].isBlockingMe=Je.category===Mt.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Mt.CATEGORY_FRIEND_DISCOVERED:var et=Je.data.friend_discoveries.map((function(e){return new i(e)}));Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onFriendsDiscovered(et)}))}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:J.debug("Discard command:","`".concat(M.command,"`"))}}}},{key:"handleCacheError",value:function(e){J.error(e)}}]),e}(),Lt=200,wt={},Dt={},Ht=function(){function e(t){c(this,e),this.channel=t,this.uploadQueue=[],this.messageQueue=[],this.latestTimestampToSendMessage=0,x.get(this._iid).FileMessageQueue.queueMap[t.url]=this}return h(e,[{key:"_handleMessageQueueUpdated",value:function(e){var t=this;switch(J.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 n=x.get(this._iid).FileMessageQueue,r=this.messageQueue[0];if(r)if(r.state===n.State.UPLOADED)if(navigator&&"boolean"==typeof navigator.onLine)if(navigator.onLine){for(r.state=n.State.SENDING,0===this.latestTimestampToSendMessage&&(this.latestTimestampToSendMessage=(new Date).getTime()-Lt);(new Date).getTime()-this.latestTimestampToSendMessage-1&&(t.state=r.State.SENT,this._handleMessageQueueUpdated("update")),this._finalizeUpload(t.requestId);else navigator&&"boolean"==typeof navigator.onLine?navigator.onLine?this._uploadFile(t,(function(e){t.error&&t.state===r.State.SENT||(t.state=r.State.UPLOADED),t.fileInfo=e,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId)})):(t.state=r.State.SENT,t.error=new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),t.response=null,this._handleMessageQueueUpdated("update"),this._finalizeUpload(t.requestId)):qe.ready().then((function(e){e?n._uploadFile(t,(function(e){t.error&&t.state===r.State.SENT||(t.state=r.State.UPLOADED),t.fileInfo=e,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId)})):(t.state=r.State.SENT,t.error=new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),t.response=null,n._handleMessageQueueUpdated("update"),n._finalizeUpload(t.requestId))}));break;case"update":break;case"remove":this.uploadQueue.length<6&&this._moveFirstPendingMessageToUploadQueue()}}},{key:"_moveFirstPendingMessageToUploadQueue",value:function(){var e=x.get(this._iid).FileMessageQueue,t=this.messageQueue.filter((function(t){return t.state===e.State.PENDING}));if(t.length>0){var n=t[0];this.uploadQueue.push(n),this._handleUploadQueueUpdated("add",n)}}},{key:"_sendUploadedMessage",value:function(e,t){var n=x.get(this._iid),r=n.Command,i=n.FileMessage,s=e.fileInfo,a=r.bFile(l(l({},s),{},{requestId:e.requestId,channelUrl:this.channel.url,url:s.file,metaArrays:s.metaArrays})),o=ki.getInstance(this._iid),u=U.get(this._iid);o.getConnectionState()===o.ConnectionState.OPEN||!o.currentUser||o.connecting||o.reconnecting?o.sendCommand(a,(function(e,n){if(o.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}if(n){var l=new i(a.getJsonElement());l.requestedMentionUserIds=s.mentionedUserIds,t(n,l)}else{var u=new i(e.getJsonElement());t(null,u)}})):u.container.apiClient.sendFileMessage(l(l({reqId:e.requestId,channelUrl:this.channel.url,isOpenChannel:this.channel.isOpenChannel()},s),{},{fileUrl:s.file,fileName:s.name,fileSize:s.size,fileType:s.type,metaArrays:s.metaArrays}),(function(e,n){var r=new i(e?a.getJsonElement():n);e&&(r.requestedMentionUserIds=s.mentionedUserIds),t(e,r)}))}},{key:"_uploadFile",value:function(e,t){var n=e.fileInfo,r=e.pendingMessage;if("string"!=typeof n.file&&n.file){var i=x.get(this._iid).FileMessageQueue;U.get(this._iid).container.apiClient.uploadFile(l(l({},n),{},{fileType:n.type,channelUrl:this.channel.url,reqId:r?r.reqId:null}),(function(r,s){if(r)e.state=i.State.SENT,e.error=r,e.response=null,t(n);else{var a="object"===u(s)?s:JSON.parse(s);n.file=a.url,n.thumbnailSizes=a.hasOwnProperty("thumbnails")?a.thumbnails:[],n.requireAuth=!!a.hasOwnProperty("require_auth")&&a.require_auth,n.size=a.hasOwnProperty("file_size")?a.file_size:n.size,t(n)}}))}else n.thumbnailSizes=[],n.requireAuth=!1,t(n)}},{key:"_finalizeUpload",value:function(e){var t=this.uploadQueue.map((function(e){return e.requestId})).indexOf(e);if(t>-1){var n=this.uploadQueue.splice(t,1);n.length>0&&this._handleUploadQueueUpdated("remove",n[0])}}},{key:"_finalizeMessage",value:function(){var e=this,t=U.get(this._iid),n=t.container.localCacheEnabled,r=t.container.isErrorFirstInCallback,i=ki.getInstance(this._iid),s=Et.of(this._iid),a=Ae.of(this._iid),o=Ie.of(this._iid),l=x.get(this._iid).FileMessageQueue,u=this.messageQueue[0],c=u.pendingMessage;if(u&&u.state===l.State.SENT){u.state=l.State.DONE;var d=u.response;d&&c&&(d._isAutoResendRegistered=c._isAutoResendRegistered);var h=u.error,p=h?new H(h.message,h.code):null,f=u.fileInfo.callback;if(d&&!h){d.reqId=c.reqId,d.requestState=i.MessageRequestState.SUCCEEDED,d.sendingStatus=i.MessageSendingStatus.SUCCEEDED;var _=i.currentUser;if(_&&d._sender&&_.userId===d._sender.userId&&(_.nickname!==d._sender.nickname&&(_.nickname=d._sender.nickname),_.plainProfileUrl!==d._sender.plainProfileUrl&&(_.plainProfileUrl=d._sender.plainProfileUrl)),this.channel.isGroupChannel())return this.channel.lastMessage=d,Object.keys(i.channelHandlers).forEach((function(t){i.channelHandlers[t].onChannelChanged(e.channel)})),void s.upsert([this.channel]).then((function(){o.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:e.channel}})})).then((function(){return a.removeUnsentMessages({channelUrl:e.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]})})).then((function(){return a.upsert([d],de.SUCCEEDED)})).then((function(){Xe._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:Ce.EVENT_MESSAGE_SENT,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(null,d):f(d,null)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}if(h){if(d&&d._isAutoResendRegistered&&ie.isAutoResendableError(h.code))return this.messageQueue.shift(),void this._handleMessageQueueUpdated("remove");if(u.pendingMessage&&(d=u.pendingMessage._clone()),d&&h.code!==H.INVALID_PARAMETER)if(d.requestState=i.MessageRequestState.FAILED,h.code===H.FILE_UPLOAD_CANCEL_FAILED||h.code===H.REQUEST_CANCELED){if(d.sendingStatus=i.MessageSendingStatus.CANCELED,this.channel.isGroupChannel())return void a.removeUnsentMessages({channelUrl:this.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]}).then((function(){o.send({source:Ce.LOCAL_MESSAGE_CANCELED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}else if(d.sendingStatus=i.MessageSendingStatus.FAILED,d.errorCode=h.code,d.requestedMentionUserIds=u.fileInfo.mentionedUserIds,h.code===H.FILE_SIZE_LIMIT_EXCEEDED&&d._messageParams&&d._messageParams.file&&(d._messageParams.file=null),this.channel.isGroupChannel())return void(h.code===H.USER_NOT_MEMBER||h.code===H.CHANNEL_NOT_FOUND?s.remove([this.channel.url]).then((function(){return a.removeUnsentMessages({channelUrl:e.channel.url,sendingStatus:i.MessageSendingStatus.PENDING,reqIds:[d.reqId]})})).then((function(){o.send({source:Ce.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")})):(n&&ie.isAutoResendableError(h.code)&&(d.sendingStatus=i.MessageSendingStatus.PENDING,d.errorCode=0,d._isAutoResendRegistered=!0),a.upsert([d],de.UNSENT).then((function(){Xe._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:Ce.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){var t=d._clone();t.sendingStatus=i.MessageSendingStatus.FAILED,t.errorCode=h.code,t._isAutoResendRegistered=!1,f&&(r?f(p,t):f(t,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))))}f&&(r?f(p,d):f(d,p)),this.messageQueue.shift(),this._handleMessageQueueUpdated("remove")}}},{key:"addJob",value:function(e){this.messageQueue.push(e),this._handleMessageQueueUpdated("add")}},{key:"cancelUploadItemByRequestId",value:function(e,t){this._finalizeUpload(e);var n=this.messageQueue.map((function(e){return e.requestId})).indexOf(e);if(n>-1){var r=x.get(this._iid).FileMessageQueue,i=this.messageQueue[n];!i||i.state!==r.State.UPLOADING&&i.state!==r.State.PENDING||(i.state=r.State.SENT,i.response=null,i.error=new H("Uploading has been completed or canceled.",H.FILE_UPLOAD_CANCEL_FAILED),this._handleMessageQueueUpdated("update"));var s=r.uploadRequest[e];if(s)return"function"==typeof s.abort?s.abort():"function"==typeof s.cancel&&s.cancel("Upload has been canceled."),t(null,!0),!0;t(new H("Uploading has been completed or canceled.",H.FILE_UPLOAD_CANCEL_FAILED),!1)}else t(new H("Uploading has been completed or canceled.",H.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 x.get(this._iid).FileMessageQueue.queueMap[e]}},{key:"create",value:function(e){var t=x.get(this._iid).FileMessageQueue;return t.queueMap.hasOwnProperty(e.url)||(t.queueMap[e.url]=new t(e)),t.queueMap[e.url]}},{key:"delete",value:function(e){var t=x.get(this._iid).FileMessageQueue;t.queueMap.hasOwnProperty(e)&&delete t.queueMap[e]}},{key:"clear",value:function(){Dt[this._iid]={}}},{key:"queueMap",get:function(){return Dt[this._iid]||(Dt[this._iid]={}),Dt[this._iid]}},{key:"uploadRequest",get:function(){return wt[this._iid]||(wt[this._iid]={}),wt[this._iid]}}]),e}();Ht.Job=function(){return function e(t){var n=t.fileInfo,r=t.requestId,i=t.pendingMessage,s=t.state,a=t.error,o=void 0===a?null:a,l=t.response,u=void 0===l?null:l;c(this,e),this.fileInfo=n,this.requestId=r,this.pendingMessage=i,this.state=s||Ht.State.PENDING,this.error=o,this.response=u}}();var Ft,Gt={},xt=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,l=e.blockHashMultiplier,u=void 0===l?10:l,c=e.blockHashConstant,d=void 0===c?11:c,h=e.transactionApplyDelay,p=void 0===h?200:h;return Gt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=d,this.transactionApplyDelay=p,Gt[t]=this),Gt[t]}return e.get=function(e){return Gt[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ft||(Ft={}));var jt,Bt=function(e){function t(t){var n=t.code,r=void 0===n?Ft.UNKNOWN_ERROR:n,i=t.message,s=void 0===i?"Unknown error occurred.":i,a=e.call(this,s)||this;return a.code=r,a}return R(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Ft.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Ft.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Ft.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Ft.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ft.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Ft.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Ft.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Ft.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Ft.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ft.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ft.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Ft.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Ft.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Ft.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ft.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Ft.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ft.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Ft.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ft.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Ft.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Ft.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(jt||(jt={}));var Vt,Kt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Bt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return Kt(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=Kt(e[r],t);return t.delete(e),n}return e},qt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Bt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},zt=function(e,t){for(var n=0,r=0;r>>0)%t},Yt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Qt=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Qt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Qt(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(qt(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(qt(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(qt(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(qt(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Wt=function(){},Jt=function(){return Promise.resolve()},Xt=function(e){return e},Zt=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Vt||(Vt={}));var $t,en,tn,nn=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Xt:a,l=e.backward,u=void 0===l?Jt:l,c=e.forward,d=void 0===c?Jt:c,h=e.complete,p=void 0===h?Wt:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,this._forward=d,this._iterator=s,this._complete=p}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return P(this,void 0,void 0,(function(){var e,t,n;return L(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return P(this,void 0,void 0,(function(){var e,t,n;return L(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),rn=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var l in this.condition[s])if(o.includes(l))for(var u=r;u>=0;u--)if(a*qt(this._indexer.origin[u].columnValues[i],this.condition[s][l])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*qt(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var d=function(r){var i=h._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),h.condition[i])if("object"==typeof h.condition[i])Object.keys(h.condition[i]).forEach((function(a){if((s>0?t:n).includes(a))for(var o=c;o=0){c=o;break}}));else for(var a=c;a=0){c=a;break}},h=this,i=0;i0){for(var r=Math.ceil(e.data.length/n)+"."+e.type+"."+t,i=[],s=0;s0))return[3,6];a=0,u.label=1;case 1:return a0))return[3,2];for(i=0;i-1){var r=this._items[n];return t===tn.PERSISTENT&&(r.state=en.PERSISTENT),t!==tn.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)pn.includes(this._items[t].state)&&pn.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].generation=e.generation,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===en.VOLATILE})).length-this._limit;if(n>0){for(var r=[],i=0,s=this._items;i0?n--:r.push(a)}this._items=r}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==en.VOLATILE}))},e}(),gn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return on(e,t)+"/trans.metadata"}(t,n),this.recordsetKey=function(e,t){return on(e,t)+"/trans.recordset"}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,e),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],l=o.data;n[l.key]||(s.unshift(o),n[l.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c;return L(this,(function(d){switch(d.label){case 0:n=_n.get(this.dbname),r=t.generation,i=t.requests,s=null,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return M(M({},e.data),{generation:r})})))];case 2:for(a=d.sent(),o=0;o0))return[3,4];for(t=[],n={},o=e.length-1;o>=0;o--)r=e[o],u=r.data,n[u.key]||(n[u.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=p.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(p.sent(),a=_n.get(this.dbname),o=0;o0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=a.sent())&&(s=yn.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];a.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return P(this,void 0,void 0,(function(){var n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return n=xt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,_n.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(a=s?yn.createFromCacheItem(s):new yn({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return P(this,void 0,void 0,(function(){var t;return L(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return L(this,(function(o){switch(o.label){case 0:return e=un(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=o.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:for(o.sent(),r=_n.get(this.dbname),i=0,s=n;i")),this._transaction=a,this._store=o,this._transaction.on($t.COMMIT,this.indexerKey,(function(){return t.commit()})),this._transaction.on($t.ERROR,this.indexerKey,(function(){return t.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=this.indexOf(n),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=this.indexOf(n),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){for(var t,n,r=[],i=0,s=this.fields;i0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return P(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d;return L(this,(function(h){switch(h.label){case 0:return[4,(e=_n.get(this.dbname)).find(this._store,this.indexerKey,tn.PERSISTENT)];case 1:return(t=h.sent())?[3,7]:(n=un(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),i=0,s=r,h.label=3;case 3:return i0?this._resolvers.shift()():this._locked=!1)},e}(),bn=function(){function e(e){var t=this,n=e.dbname,r=e.collectionName,i=e.keyName,s=e.keyHash,a=e.indexes,o=e.store;this._state=jt.INIT,this._metadata=null,this._indexers=[],this.dbname=n,this.name=r,this.keyName=i,this.indexes=w([[i]],a.filter((function(e){return En.createKey(e)!==t.keyName})),!0),this._keyHash=s,this._store=o,this._mutex=new vn(function(e,t){return on(e,t)+".lock"}(n,r)),this._blobContainer=new hn({dbname:n,collectionName:r,store:o}),this._transaction=new gn({dbname:n,collectionName:r,store:o})}return e.metadataOf=function(e,t,n){return P(this,void 0,void 0,(function(){var r;return L(this,(function(i){switch(i.label){case 0:return r=ln(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.init=function(){return P(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p=this;return L(this,(function(f){switch(f.label){case 0:return[4,this._mutex.lock()];case 1:f.sent(),f.label=2;case 2:return f.trys.push([2,9,,10]),t=xt.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=f.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:for(f.sent(),this._blockManager=new mn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=w([],this.indexes,!0),i=[],s=r.map((function(e){return En.createKey(e)})),a=n?n.indexes.map((function(e){return En.createKey(e)})):[],o=0,l=a;o0&&!r.some((function(t){switch(t){case Ln.CHANNEL_NAME:return e.name.toLowerCase().includes(n.toLowerCase());case Ln.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(n.toLowerCase())}));default:return!0}})))return!1;var i=this._userIdsFilter,s=i.includeMode,a=i.queryType,o=i.userIds,l=U.get(this._iid).get("currentUserId"),u=e.members.map((function(e){return e.userId}));if(s){if(o.length>0)switch(a){case Pn.AND:if(o.some((function(e){return!u.includes(e)})))return!1;break;case Pn.OR:if(o.every((function(e){return!u.includes(e)})))return!1}}else{if(o.includes(l)||o.push(l),e.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=w([],e,!0).sort(),r=w([],t,!0).sort(),i=0;i0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^"+this.customTypeStartsWithFilter).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var c=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(c)})))return!1}if(this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){case wn.JOINED:if("joined"!==e.myMemberState)return!1;break;case wn.INVITED:if("invited"!==e.myMemberState)return!1;break;case wn.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case wn.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gn.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gn.HIDDEN:if(!e.isHidden)return!1;break;case Gn.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gn.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter)switch(this.unreadChannelFilter){case Fn.UNREAD_MESSAGE:if(0===e.unreadMessageCount)return!1}if(this.publicChannelFilter)switch(this.publicChannelFilter){case Hn.PUBLIC:if(!e.isPublic)return!1;break;case Hn.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Dn.SUPER:if(!e.isSuper)return!1;break;case Dn.NON_SUPER:if(e.isSuper)return!1}return!0},e.QueryType=Pn,e.SearchField=Ln,e}(),Vn=function(){function e(e){var t=e.iid;this._iid=t,this._filter=new Bn,this._filter.iid=this._iid,this._order=ze.LATEST_LAST_MESSAGE,this._limit=20}return e.prototype.setFilter=function(e){return this._filter=e.clone(),this._filter.iid=this._iid,this},e.prototype.setOrder=function(e){return this._order=e,this},e.prototype.setLimit=function(e){return this._limit=e,this},e.prototype.build=function(){return new yt({iid:this._iid,filter:this._filter,order:this._order,limit:this._limit})},e}(),Kn=function(){function e(e){var t=e.iid,n=e.channel;this._iid=t,this._channel=n,this._startingPoint=Date.now(),this._filter=new He,this._limit=100}return e.prototype.setFilter=function(e){return this._filter=e.clone(),this},e.prototype.setStartingPoint=function(e){return this._startingPoint=e,this},e.prototype.setLimit=function(e){return this._limit=e,this},e.prototype.build=function(){return new Xe({iid:this._iid,channel:this._channel,startingPoint:this._startingPoint,filter:this._filter,limit:this._limit})},e}(),qn={},zn={},Yn=new WeakMap,Qn=new WeakMap,Wn=new WeakMap,Jn=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=kt.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=n.PushTriggerOption.DEFAULT,r.isPushEnabled,r.isHidden=!1,r.hiddenState=n.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},Yn.set(y(r),{}),Qn.set(y(r),{start:0,end:0}),Wn.set(y(r),0),e&&r._update(e),r}return h(n,[{key:"messageOffsetTimestamp",get:function(){return this._messageOffsetTimestamp}},{key:"createMessageCollection",value:function(){return new Kn({iid:this._iid,channel:this})}},{key:"_setGroupChannelUnreadCount",value:function(e,t){try{if("number"==typeof e&&e>=0)if("all"===this.myCountPreference||"unread_message_count_only"===this.myCountPreference)if(this.isSuper||this.isBroadcast){var n=U.get(this._iid).container.maxUnreadCountOfSuperGroupChannel;this.unreadMessageCount=e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&("all"===this.myCountPreference||"unread_mention_count_only"===this.myCountPreference?this.unreadMentionCount=t:this.unreadMentionCount=0)}catch(e){}}},{key:"_update",value:function(e){var t=this,n=x.get(this._iid),r=n.BaseChannel,i=n.GroupChannel,s=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:i.PushTriggerOption.DEFAULT,this.myCountPreference=e.hasOwnProperty("count_preference")?e.count_preference:i.CountPreference.ALL,this.unreadMessageCount=0,this.unreadMentionCount=0,this._setGroupChannelUnreadCount(parseInt(e.unread_message_count),parseInt(e.unread_mention_count)),e.hasOwnProperty("read_receipt")&&(this.cachedReadReceiptStatus={},Object.keys(e.read_receipt).forEach((function(n){var r=e.read_receipt[n];t.updateReadReceipt(n,parseInt(r))}))),e.hasOwnProperty("delivery_receipt")&&"object"===u(e.delivery_receipt)&&null!==e.delivery_receipt&&(this.cachedDeliveryReceiptStatus||(this.cachedDeliveryReceiptStatus={}),Object.keys(e.delivery_receipt).forEach((function(n){var r=e.delivery_receipt[n];t.updateDeliveryReceipt(n,parseInt(r))}))),e.hasOwnProperty("user_last_read")&&"number"==typeof e.user_last_read?this.myLastRead=e.user_last_read:this.myLastRead=0,e.hasOwnProperty("members")){this.members=[],this.memberMap={};for(var o=0;o0?this.inviter=new s(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=i.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 t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isSuper&&!this.isBroadcast){var n=x.get(this._iid),r=n.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,t),this.updateDeliveryReceipt(e.userId,t)}}},{key:"removeMember",value:function(e){var t=null;if(!this.isSuper&&!this.isBroadcast&&this.memberMap.hasOwnProperty(e.userId)){delete this.memberMap[e.userId];for(var n=0;n0&&e.every((function(e){return!!e.userId&&"string"==typeof e.userId}))}}),new tt({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){return e(tt.error,null)}),t):this.inviteWithUserIds(e.map((function(e){return e.userId})),t)}},{key:"inviteWithUserIds",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.inviteToGroupChannel({channelUrl:n.url,userIds:e},(function(e,r){var i=null;e||(i=x.get(n._iid).GroupChannel.upsert(r));t(e,i)}))}),t)}},{key:"acceptInvitation",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.acceptInvitation({channelUrl:n.url,accessCode:e},(function(e,r){var i=null;e||((i=x.get(n._iid).GroupChannel.upsert(r)).myMemberState="joined");t(e,i)}))}),t)}},{key:"declineInvitation",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.declineInvitation({channelUrl:t.url},(function(n,r){var i=null;if(!n){var s=x.get(t._iid).GroupChannel;(i=s.upsert(r)).myMemberState="none",t.isPublic||s.removeCachedChannel(t.url)}e(n,i)}))}),e)}},{key:"join",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.joinGroupChannel({channelUrl:n.url,accessCode:e},(function(e,r){var i=null;e||((i=x.get(n._iid).GroupChannel.upsert(r)).myMemberState="joined");t(e,i)}))}),t)}},{key:"leave",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.leaveGroupChannel({channelUrl:t.url},(function(t,n){return e(t,null)}))}),e)}},{key:"muteUser",value:function(e,t,n,r){return this.muteUserWithUserId(e?e.userId:null,t,n,r)}},{key:"muteUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string",optional:!0,defaultValue:""}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!0},(function(e,t){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,t){return this.unmuteUserWithUserId(e?e.userId:null,t)}},{key:"unmuteUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unmuteUser({channelUrl:n.url,userId:e,isGroupChannel:!0},(function(e,n){t(e,null)}))}),t)}},{key:"banUser",value:function(e,t,n,r){return this.banUserWithUserId(e?e.userId:null,t,n,r)}},{key:"banUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string"}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.banUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!0},(function(e,t){r(e,null)}))}),r)}},{key:"unbanUser",value:function(e,t){return this.unbanUserWithUserId(e?e.userId:null,t)}},{key:"unbanUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unbanUser({channelUrl:n.url,userId:e,isGroupChannel:!0},(function(e,n){t(e,null)}))}),t)}},{key:"updateJoinedMemberCount",value:function(){if(!this.isSuper&&!this.isBroadcast){var e=x.get(this._iid).Member;this.joinedMemberCount=this.members.filter((function(t){return t.state===e.JOINED})).length}}},{key:"setLatestMemberCount",value:function(e,t,n){var r=!1;return"number"==typeof e&&"number"==typeof t&&"number"==typeof n&&n>=Wn.get(this)&&(Wn.set(this,n),r=t!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"hide",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"boolean",optional:!0,defaultValue:!1}),new tt({type:"boolean",optional:!0,defaultValue:!0}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.hideGroupChannel({channelUrl:r.url,hidePreviousMessages:e,allowAutoUnhide:t},(function(i,s){if(!i){var a=x.get(r._iid).GroupChannel;r.isHidden=!0,r.hiddenState=t?a.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:a.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,e&&r._setGroupChannelUnreadCount(0,0),s.hasOwnProperty("ts_message_offset")&&(r._messageOffsetTimestamp=s.ts_message_offset),a.cachedChannels[r.url]=r}n(i,s)}))}),n)}},{key:"unhide",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unhideGroupChannel({channelUrl:t.url},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isHidden=!1,t.hiddenState=i.HiddenState.UNHIDDEN,i.cachedChannels[t.url]=t}e(n,r)}))}),e)}},{key:"freeze",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.freeze({channelUrl:t.url,isGroupChannel:!0,freezing:!0},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isFrozen=!0,i.cachedChannels[t.url]=t}e(n,null)}))}),e)}},{key:"unfreeze",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.freeze({channelUrl:t.url,isGroupChannel:!0,freezing:!1},(function(n,r){if(!n){var i=x.get(t._iid).GroupChannel;t.isFrozen=!1,i.cachedChannels[t.url]=t}e(n,null)}))}),e)}},{key:"delete",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteGroupChannel({channelUrl:t.url},(function(n,r){n||x.get(t._iid).GroupChannel.removeCachedChannel(t.url);e(n,r)}))}),e)}},{key:"markAsRead",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).Command,r=ki.getInstance(t._iid),i=n.bRead({channelUrl:t.url});r.sendCommand(i,(function(n,i){if(r.getErrorFirstCallback()){var s=[n,i];i=s[0],n=s[1]}if(i)e(i,null);else if(r.currentUser){var a=Et.of(t._iid),o=Ie.of(t._iid);t.updateReadReceipt(r.currentUser.userId,n.getJsonElement().ts);var l=!1;(t.unreadMessageCount>0||t.unreadMentionCount>0)&&(t._setGroupChannelUnreadCount(0,0),Object.keys(r.channelHandlers).forEach((function(e){r.channelHandlers[e].onChannelChanged(t)})),l=!0),e(null,null),a.upsert([t]).then((function(){l&&o.send({source:Ce.EVENT_CHANNEL_CHANGED,payload:{channel:t}}),o.send({source:Ce.EVENT_READ_RECEIPT_UPDATED,payload:{channel:t}})})).catch((function(e){J.error(e)}))}else{var u=new SendBirdException("Connection should be made first.",SendBirdException.CONNECTION_REQUIRED);e(u,null)}}))}),e)}},{key:"getUnreadMemberCount",value:function(e){var t=U.get(this._iid),n=x.get(this._iid).Member,r=t.container.currentUserId;if(e instanceof St&&!e.isAdminMessage()&&r&&!this.isSuper&&!this.isBroadcast){for(var i=0,s=e.createdAt,a=this.members,o=0;o1&&void 0!==arguments[1]&&arguments[1],n=ki.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof St&&!e.isAdminMessage()){for(var r=[],i=0;i=e.createdAt&&r.push(s)}}return r}return[]}},{key:"getUnreadMembers",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=ki.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof St&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],n=ki.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast){for(var r={},i=Object.keys(this.cachedReadReceiptStatus),s=function(s){var a=i[s];if(!t&&a===n.currentUser.userId)return"continue";var o=e.cachedReadReceiptStatus[a],l=e.members.filter((function(e){return e.userId===a}));r[a]={user:l.length>0?l[0]:null,last_seen_at:parseInt(o)}},a=0;a9e3)&&(n=1e3);var r=Qn.get(this);if(t-r.start>=n){r.end=0,r.start=t;var i=x.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=ki.getInstance(this._iid),t=(new Date).getTime(),n=e.Options.typingIndicatorThrottle;("number"!=typeof n||n<1e3||n>9e3)&&(n=1e3);var r=Qn.get(this);if(t-r.end>=n){r.start=0,r.end=t;var i=x.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=Yn.get(this),t=(new Date).getTime(),n=!1;return Object.keys(e).forEach((function(r){var i=e[r].ts;t-i>=1e4&&(delete e[r],n=!0)})),n}},{key:"getTypingMembers",value:function(){var e=this,t=Yn.get(this),n=[];return Object.keys(t).forEach((function(t){var r=e.memberMap[t];r&&n.push(r)})),n}},{key:"getTypingUsers",value:function(){var e=Yn.get(this),t=[];return Object.keys(e).forEach((function(n){var r=e[n].user;t.push(r)})),t}},{key:"updateTypingStatus",value:function(e,t){var n=Yn.get(this);t?n[e.userId]={user:e,ts:(new Date).getTime()}:delete n[e.userId]}},{key:"isTyping",value:function(){var e=Yn.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.ScheduledUserMessage,s=r.ScheduledUserMessageParams,a=null,o=tt.parse(arguments,[new tt({type:s,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new tt({type:"callback"})]),l=C(o,3);return a=l[0],e=l[1],t=l[2],oe(this._iid,(function(t){a?t(a,null):U.get(n._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:n.url,isOpenChannel:!1},(function(e,r){var s=null;if(!e){s=new i(r);var a=ki.getInstance(n._iid).currentUser;a&&s._sender&&a.userId===s._sender.userId&&(a.nickname=s._sender.nickname,a.plainProfileUrl=s._sender.plainProfileUrl,a.metaData=s._sender.metaData)}t(e,s)}))}),t)}},{key:"getPushPreference",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMyPushTriggerOption({channelUrl:t.url},(function(n,r){var i=null;if(!n){try{i=r.enable}catch(e){i=!1}t.isPushEnabled=i}e&&e(n,i)}))}),e)}},{key:"setPushPreference",value:function(e,t){var n=this;return oe(this._iid,(function(t){var r=x.get(n._iid).GroupChannel;U.get(n._iid).container.apiClient.setMyPushTriggerOption({channelUrl:n.url,enable:e},(function(e,i){e||(n.isPushEnabled=i.enable,n.isPushEnabled||(n.myPushTriggerOption=r.PushTriggerOption.OFF)),t(e,i)}))}),t)}},{key:"getMyPushTriggerOption",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getMyPushTriggerOption({channelUrl:t.url},(function(r,i){var s=null;if(!r){try{s=i.push_trigger_option||n.PushTriggerOption.DEFAULT}catch(e){J.debug(e)}t.myPushTriggerOption=s}e(r,s)}))}),e)}},{key:"setMyPushTriggerOption",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.PushTriggerOption}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.setMyPushTriggerOption({channelUrl:n.url,pushTriggerOption:e},(function(e,r){var i=null;if(!e){try{i=r.push_trigger_option}catch(e){J.debug(e)}n.myPushTriggerOption=i}t(e,i)}))}),t)}},{key:"setMyCountPreference",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.CountPreference}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.setMyCountPreference({channelUrl:n.url,countPreference:e},(function(e,r){var s=null;e||(s=n.myCountPreference=r.count_preference,n._setGroupChannelUnreadCount(n.unreadMessageCount,n.unreadMentionCount),i.cachedChannels[n.url]=n),t(e,s)}))}),t)}},{key:"resetMyHistory",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.resetMyHistory({channelUrl:t.url},(function(n,r){if(!n&&r.hasOwnProperty("ts_message_offset")){var i=x.get(t._iid).GroupChannel;t._messageOffsetTimestamp=r.ts_message_offset,i.cachedChannels[t.url]=t}e(n,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",BROADCAST_ONLY:"broadcast_only"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return qn[this._iid]||(qn[this._iid]={}),qn[this._iid]}},{key:"createGroupChannelCollection",value:function(){return new Vn({iid:this._iid})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.Member,i=t.GroupChannel,s=t.BaseMessage,a=t.UserMessage,o=t.FileMessage,c=t.AdminMessage,d=Ct.deserialize(e),h=function(e){return null!=e&&"object"===u(e)?e.messageType===s.MESSAGE_TYPE_USER?new a(a.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):e.messageType===s.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({},e))})),last_message:h,created_by:null!==d.creator&&void 0!==d.creator&&"object"===u(d.creator)?n.objectify(d.creator):null,inviter:null!==d.inviter&&void 0!==d.inviter&&"object"===u(d.inviter)?n.objectify(d.inviter):null,cached_primary_key:d.cachedPrimaryKey})}},{key:"upsert",value:function(e){var t=x.get(this._iid).GroupChannel,n=new t(e);if(t.cachedChannels.hasOwnProperty(n.url)){if(n.isEphemeral){var r=t.cachedChannels[n.url];e.last_message=r.lastMessage,e.unread_message_count=r.unreadMessageCount}t.cachedChannels[n.url].update(e)}else t.cachedChannels[n.url]=n;return t.cachedChannels[n.url]}},{key:"removeCachedChannel",value:function(e){var t=x.get(this._iid),n=t.GroupChannel,r=t.FileMessageQueue;n.cachedChannels[e]&&delete n.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){qn[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),s=C(i,4);if(n=s[0],e=s[1],r=s[2],t=s[3],n)return oe(this._iid,(function(e){e(n,null)}),t);var a=x.get(this._iid),o=a.GroupChannel;return o.cachedChannels[e]?oe(this._iid,(function(t){t(null,o.cachedChannels[e])}),t):o.getChannelWithoutCache(e,r,t)}},{key:"getChannelWithoutCache",value:function(e,t){var n=this,r=null,i=null,s=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),a=C(s,4);return r=a[0],e=a[1],i=a[2],t=a[3],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},(function(e,r){var i=null;e||(i=n.upsert(r)),t(e,i)}))}),t)}},{key:"createDistinctChannelIfNotExist",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannelParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):(e.isPublic||(e.accessCode=null),U.get(n._iid).container.apiClient.createGroupChannel(l(l({},e),{},{isDistinct:!0}),(function(e,r){var i=null;if(!e){var s=x.get(n._iid).GroupChannel;i={channel:new s(r),isCreated:r.is_created},s.cachedChannels[i.channel.url]=i.channel}t(e,i)})))}),t)}},{key:"createChannel",value:function(){var e=this,t=tt.toArray(arguments),n=void 0;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];(r.isPublic||(r.accessCode=null),r._validate())?U.get(e._iid).container.apiClient.createGroupChannel(r,(function(e,t){var r=null;e||(r=new i(t),i.cachedChannels[r.url]=r),n(e,r)})):n(tt.error,null)}),n);if(Array.isArray(t[0])){var a=new s;switch(t.length){case 1:a.addUsers(t[0]);break;case 2:a.addUsers(t[0]),a.isDistinct=t[1];break;case 3:a.addUsers(t[0]),a.isDistinct=t[1],a.customType=t[2];break;case 5:a.addUsers(t[0]),a.isDistinct=t[1],a.name=t[2],"string"==typeof t[3]?a.coverUrl=t[3]:a.coverImage=t[3],a.data=t[4];break;case 6:a.addUsers(t[0]),a.isDistinct=t[1],a.name=t[2],"string"==typeof t[3]?a.coverUrl=t[3]:a.coverImage=t[3],a.data=t[4],a.customType=t[5];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}return oe(this._iid,(function(e){return e(tt.error,null)}),n)}},{key:"createChannelWithUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;"function"==typeof e[e.length-1]&&(t=e.pop());var n=x.get(this._iid),r=n.GroupChannel,i=n.GroupChannelParams,s=new i;switch(e.length){case 1:s.addUserIds(e[0]);break;case 2:s.addUserIds(e[0]),s.isDistinct=e[1];break;case 3:s.addUserIds(e[0]),s.isDistinct=e[1],s.customType=e[2];break;case 5:s.addUserIds(e[0]),s.isDistinct=e[1],s.name=e[2],"string"==typeof e[3]?s.coverUrl=e[3]:s.coverImage=e[3],s.data=e[4];break;case 6:s.addUserIds(e[0]),s.isDistinct=e[1],s.name=e[2],"string"==typeof e[3]?s.coverUrl=e[3]:s.coverImage=e[3],s.data=e[4],s.customType=e[5];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}return r.createChannel(s,t)}},{key:"createMyGroupChannelListQuery",value:function(){return new(0,x.get(this._iid).GroupChannelListQuery)}},{key:"createPublicGroupChannelListQuery",value:function(){return new(0,x.get(this._iid).PublicGroupChannelListQuery)}},{key:"markAsReadAllLastSentAt",get:function(){return zn[this._iid]||0},set:function(e){zn[this._iid]=e}},{key:"getChannelCount",value:function(e,t){return ki.getInstance(this._iid).getGroupChannelCount(e,t)}},{key:"getUnreadItemCount",value:function(e,t){return ki.getInstance(this._iid).getUnreadItemCount(e,t)}},{key:"getTotalUnreadMessageCount",value:function(){var e=tt.toArray(arguments),t="function"==typeof e[e.length-1]?e.pop():null,n=ki.getInstance(this._iid);return n.getTotalUnreadMessageCount.apply(n,A(e).concat([t]))}},{key:"getTotalUnreadChannelCount",value:function(e){return ki.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),n}(kt),Xn=function(e){function t(t){var n=e.call(this,t)||this;return n.state="",n.role="",n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.restrictionInfo=null,t&&n._update(t),n}return R(t,e),t.objectify=function(e){var t=x.get(this._iid),n=t.User,r=t.RestrictedUser,i=t.RestrictionInfo,s=e.state,a=e.role,o=void 0===a?"":a,l=e.isMuted,u=void 0!==l&&l,c=e.isBlockedByMe,d=void 0!==c&&c,h=e.isBlockingMe,p=void 0!==h&&h,f=e.restrictionInfo,_=void 0===f?null:f,g=u?r.objectify(e):n.objectify(e);if(g.state=s,g.role=o,g.is_muted=u,g.is_blocked_by_me=d,g.is_blocking_me=p,_){var y=i.objectify(_);g.restriction_type=y.restriction_type,g.muted_description=y.description,g.muted_end_at=y.end_at}return g},t.buildFromSerializedData=function(e){var t=x.get(this._iid).Member,n=Ct.deserialize(e);return new t(t.objectify(M({},n)))},t.prototype._update=function(e){var t=x.get(this._iid),n=t.RestrictedUser,r=t.RestrictionInfo;this.state=e.state,this.role=e.role||Jn.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me),this.isMuted&&(this.restrictionInfo=new r(e),this.restrictionInfo.restrictionType=n.RestrictionType.MUTED)},t.prototype.parse=function(e){this._update(e)},Object.defineProperty(t,"JOINED",{get:function(){return"joined"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"INVITED",{get:function(){return"invited"},enumerable:!1,configurable:!0}),t}(It),Zn=function(e){function t(t){var n=e.call(this,t)||this;return n.role="",n.isBlockedByMe=!1,t&&n._update(t),n}return R(t,e),t.objectify=function(e){var t=x.get(this._iid).User,n=e.role,r=void 0===n?"":n,i=e.isBlockedByMe,s=void 0!==i&&i,a=t.objectify(e);return a.role=r,a.is_blocked_by_me=s,a},t.buildFromSerializedData=function(e){var t=x.get(this._iid).Sender,n=Ct.deserialize(e);return new t(t.objectify(M({},n)))},t.prototype.parse=function(e){this._update(e)},t.prototype._update=function(e){this.role=e.role||Jn.Role.NONE,e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)},t}(It),$n=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).restrictionInfo=null,e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=x.get(this._iid).RestrictionInfo;this.restrictionInfo=new t(e)}}],[{key:"RestrictionType",get:function(){return{MUTED:"muted",BANNED:"banned"}}},{key:"objectify",value:function(e){var t=x.get(this._iid),n=t.User,r=t.RestrictionInfo,i=e.restrictionInfo,s=void 0===i?{}:i;return l(l({},n.objectify(e)),r.objectify(s))}}]),n}(It),er=function(){function e(e){this.emojiHash=null,this.emojiCategories=null,e&&this._update(e)}return e.prototype._update=function(e){var t=x.get(this._iid).EmojiCategory;this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new t(e)})):[]},e}(),tr=function(){function e(e){this.id=null,this.name=null,this.url=null,this.emojis=null,e&&this._update(e)}return e.prototype._update=function(e){var t=x.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 t(e)})):[]},e}(),nr=function(){function e(e){this.key=null,this.url=null,e&&this._update(e)}return e.prototype._update=function(e){this.key=e.key,this.url=e.url},e}(),rr={},ir={},sr=new WeakMap,ar=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=kt.CHANNEL_TYPE_OPEN,r.participantCount=0,sr.set(y(r),0),r.operators=[],e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=x.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 t(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,x.get(this._iid).ParticipantListQuery)({channelUrl:this.url})}},{key:"createMutedUserListQuery",value:function(){return new(0,x.get(this._iid).MutedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"createBannedUserListQuery",value:function(){return new(0,x.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 x.get(this._iid).OpenChannel.getChannelWithoutCache(this.url,e)}},{key:"enter",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).Command.bEnter({channelUrl:t.url}),r=ki.getInstance(t._iid);r.sendCommand(n,(function(n,i){if(r.getErrorFirstCallback()){var s=[n,i];i=s[0],n=s[1]}i?(i=i?new H(i.message,i.code):null,e(i,null)):(x.get(t._iid).OpenChannel.enteredChannels[t.url]=t,Ie.of(t._iid).send({source:Ce.EVENT_CHANNEL_ENTER,payload:{channel:t}}),t.refresh((function(){return e(null,null)})))}))}),e)}},{key:"exit",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.Command,i=n.FileMessageQueue,s=r.bExit({channelUrl:t.url}),a=ki.getInstance(t._iid);a.sendCommand(s,(function(n,r){if(a.getErrorFirstCallback()){var s=[n,r];r=s[0],n=s[1]}r?(r=r?new H(r.message,r.code):null,e(r,null)):(delete x.get(t._iid).OpenChannel.enteredChannels[t.url],i.delete(t.url),Ie.of(t._iid).send({source:Ce.EVENT_CHANNEL_EXIT,payload:{channel:t}}),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,t=tt.toArray(arguments),n=null;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.OpenChannel,s=r.OpenChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];(r.channelUrl=e.url,r._validate())?U.get(e._iid).container.apiClient.updateOpenChannel(r,(function(e,t){var r=null;e||(r=i.upsert(t)),n(e,r)})):n(tt.error,null)}),n);if(3===t.length){var a=new s;return a.channelUrl=this.url,a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=this.operators.map((function(e){return e.userId})),this.updateChannel(a,n)}if(4===t.length){var o=new s;return o.channelUrl=this.url,o.name=t[0],o.coverUrlOrImage=t[1],o.data=t[2],Array.isArray(t[3])&&(o.operatorUserIds=t[3]),this.updateChannel(o,n)}if(5===t.length){var l=new s;return l.channelUrl=this.url,l.name=t[0],l.coverUrlOrImage=t[1],l.data=t[2],Array.isArray(t[3])&&(l.operatorUserIds=t[3]),l.customType=t[4],this.updateChannel(l,n)}return oe(this._iid,(function(e){return e(tt.error,null)}),n)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return this.updateChannel.apply(this,A(e).concat([t]));default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}}},{key:"muteUser",value:function(e,t,n,r){return this.muteUserWithUserId(e?e.userId:null,t,n,r)}},{key:"muteUserWithUserId",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"string",optional:!0,defaultValue:""}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.muteUser({channelUrl:i.url,userId:e,description:n,seconds:t,isGroupChannel:!1},(function(e,t){r(e,null)}))}),r)}},{key:"unmuteUser",value:function(e,t){return this.unmuteUserWithUserId(e?e.userId:null,t)}},{key:"unmuteUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unmuteUser({channelUrl:n.url,userId:e,isGroupChannel:!1},(function(e,n){t(e,null)}))}),t)}},{key:"banUser",value:function(e,t,n){return this.banUserWithUserId(e?e.userId:null,t,n)}},{key:"banUserWithUserId",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.banUser({channelUrl:r.url,userId:e,description:null,seconds:t,isGroupChannel:!1},(function(e,t){n(e,null)}))}),n)}},{key:"unbanUser",value:function(e,t){return this.unbanUserWithUserId(e?e.userId:null,t)}},{key:"unbanUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unbanUser({channelUrl:n.url,userId:e,isGroupChannel:!1},(function(e,n){t(e,null)}))}),t)}},{key:"setLatestParticipantCount",value:function(e,t){var n=!1;return"number"==typeof e&&"number"==typeof t&&t>=sr.get(this)&&(sr.set(this,t),n=e!==this.participantCount,this.participantCount=e),n}},{key:"delete",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.deleteOpenChannel({channelUrl:t.url},(function(n,r){n||(delete x.get(t._iid).OpenChannel.cachedChannels[t.url],x.get(t._iid).FileMessageQueue.delete(t.url));e(n,r)}))}),e)}}],[{key:"cachedChannels",get:function(){return rr[this._iid]||(rr[this._iid]={}),rr[this._iid]}},{key:"enteredChannels",get:function(){return ir[this._iid]||(ir[this._iid]={}),ir[this._iid]}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.OpenChannel,i=Ct.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 n.objectify(e)}))})}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),s=C(i,4);if(n=s[0],e=s[1],r=s[2],t=s[3],n)return oe(this._iid,(function(e){e(n,null)}),t);var a=x.get(this._iid),o=a.OpenChannel;return o.cachedChannels[e]?oe(this._iid,(function(t){t(null,o.cachedChannels[e])}),t):o.getChannelWithoutCache(e,r,t)}},{key:"getChannelWithoutCache",value:function(e,t){var n=this,r=null,i=null,s=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"callback"})]),a=C(s,4);return r=a[0],e=a[1],i=a[2],t=a[3],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getOpenChannel({channelUrl:e,internalCall:i},(function(e,r){var i=null;e||(i=x.get(n._iid).OpenChannel.upsert(r));t(e,i)}))}),t)}},{key:"createChannel",value:function(){var e=this,t=tt.toArray(arguments),n=null;"function"==typeof t[t.length-1]&&(n=t.pop());var r=x.get(this._iid),i=r.OpenChannel,s=r.OpenChannelParams;if(t[0]instanceof s&&1===t.length)return oe(this._iid,(function(n){var r=t[0];r._validate()?U.get(e._iid).container.apiClient.createOpenChannel(r,(function(t,r){var i=null;t||(i=x.get(e._iid).OpenChannel.upsert(r));n(t,i)})):n(tt.error,null)}),n);var a=new s;switch(t.length){case 0:break;case 1:a.name=t[0];break;case 2:a.name=t[0],a.coverUrlOrImage=t[1];break;case 3:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2];break;case 4:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=t[3];break;case 5:a.name=t[0],a.coverUrlOrImage=t[1],a.data=t[2],a.operatorUserIds=t[3],a.customType=t[4];break;default:return oe(this._iid,(function(e){return e(tt.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=tt.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return this.createChannel.apply(this,A(e).concat([t]));default:return oe(this._iid,(function(e){return e(tt.error,null)}),t)}}},{key:"upsert",value:function(e){var t=new(0,x.get(this._iid).OpenChannel)(e);return this.cachedChannels.hasOwnProperty(t.url)?this.cachedChannels[t.url].update(e):this.cachedChannels[t.url]=t,this.cachedChannels[t.url]}},{key:"removeCachedChannel",value:function(e){this.cachedChannels[e]&&delete this.cachedChannels[e],x.get(this._iid).FileMessageQueue.delete(e)}},{key:"clearCache",value:function(){rr[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){ir[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,x.get(this._iid).OpenChannelListQuery)}}]),n}(kt),or="default",lr=function(){function e(e){this.name=or,this.volume=1,e&&this._update(e)}return e.prototype._update=function(e){e.hasOwnProperty("name")&&(this.name=e.name),e.hasOwnProperty("volume")&&(this.volume=e.volume)},e.objectify=function(e){var t=e.name,n=void 0===t?or:t,r=e.volume;return{name:n,volume:void 0===r?1:r}},e.prototype.serialize=function(){return Ct.serialize(this)},e}(),ur=function(){function e(e,t){void 0===t&&(t=[]),this.key=e,this.value=Array.isArray(t)&&t.every((function(e){return"string"==typeof e}))?t:[]}return e.prototype.encode=function(){return{key:this.key,value:this.value||[]}},e}(),cr=new WeakMap,dr=function(){function e(t){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],cr.set(this,null),this._parentMessageId=null,this.data=null,this.customType=null,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this.isReplyToChannel=!1,t&&this._update(t)}return h(e,[{key:"mentionType",get:function(){return this._mentionType},set:function(e){var t=x.get(this._iid).BaseMessageParams;Object.keys(t.MentionType).map((function(e){return t.MentionType[e]})).indexOf(e)>-1&&(this._mentionType=e)}},{key:"mentionedUserIds",get:function(){return this._cachedMentionedUserIds},set:function(e){if(Array.isArray(e))for(var t=ki.getInstance(this._iid),n=0;n-1&&this._mentionedUserIds.every((function(e){return"string"==typeof e}))&&Array.isArray(this._metaArrays)&&this._metaArrays.every((function(e){return e instanceof n}))&&("number"==typeof r||null===r)&&("number"==typeof this._parentMessageId||null===this._parentMessageId)&&("string"==typeof this.data||null===this.data)&&("string"==typeof this.customType||null===this.customType)&&(null===this.pushNotificationDeliveryOption||Object.keys(t.PushNotificationDeliveryOption).map((function(e){return t.PushNotificationDeliveryOption[e]})).indexOf(this.pushNotificationDeliveryOption)>-1)&&(null===this.appleCriticalAlertOptions||this.appleCriticalAlertOptions instanceof lr)&&"boolean"==typeof this.isReplyToChannel}}],[{key:"_objectify",value:function(t){var n=t.mentionType,r=void 0===n?e.MentionType.USERS:n,i=t.mentionedUserIds,s=void 0===i?[]:i,a=t.cachedMentionedUsers,o=void 0===a?[]:a,l=t.cachedMentionedUserIds,u=void 0===l?[]:l,c=t.metaArrays,d=void 0===c?[]:c,h=t.parentMessageId,p=void 0===h?null:h,f=t.pushNotificationDeliveryOption,_=void 0===f?null:f,g=t.appleCriticalAlertOptions,y=void 0===g?null:g,m=t.isReplyToChannel;return{mention_type:r,mentioned_user_ids:s,cached_mentioned_users:o,cached_mentioned_user_ids:u,meta_arrays:d,parent_message_id:p,push_notification_delivery_option:_,apple_critical_alert_options:y,is_reply_to_channel:void 0!==m&&m}}},{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),hr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).message=null,r.pollId=void 0,r._translationTargetLanguages=[],e&&r._update(e),r}return h(n,[{key:"serialize",value:function(){return b(_(n.prototype),"_serialize",this).call(this,(function(e){e.hasOwnProperty("_translationTargetLanguages")&&(e.translationTargetLanguages=e._translationTargetLanguages,delete e._translationTargetLanguages)}))}},{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 t=0;t0?t.MessageRequestState.SUCCEEDED:t.MessageRequestState.FAILED,e.hasOwnProperty("sending_status")&&(this.requestState=e.sending_status,this.requestState===t.MessageSendingStatus.CANCELED&&(this.requestState=t.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)}))),this.poll=null,e.hasOwnProperty("poll")&&(this.poll=new s(e.poll)),e.hasOwnProperty("message_params")&&(this._messageParams=new hr(e.message_params))}},{key:"sender",get:function(){var e=ki.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.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=ki.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&ie.isResendableError(this.errorCode)}},{key:"serialize",value:function(){var e=this;return b(_(n.prototype),"serialize",this).call(this,(function(t){e._messageParams&&(t.messageParams=e._messageParams.serialize())}))}},{key:"messageParams",get:function(){return this._messageParams}},{key:"_clone",value:function(){return x.get(this._iid).UserMessage.buildFromSerializedData(this.serialize())}}],[{key:"objectify",value:function(e){var t=ki.getInstance(this._iid),n=x.get(this._iid),r=n.BaseChannel,i=n.BaseMessageParams,s=n.Sender,a=n.User,o=n.UserMessage,u=n.FileMessage,c=n.AdminMessage,d=n.ThreadInfo,h=n.OGMetaData,p=n.Plugin,f=n.AppleCriticalAlertOptions,_=n.Poll,g=n.UserMessageParams,y=e.messageId,m=e.reqId,E=void 0===m?"":m,v=e.user,b=e.channel,C=e.message,A=e.data,N=void 0===A?"":A,S=e.customType,I=void 0===S?"":S,T=e.mentionType,O=void 0===T?i.MentionType.USERS:T,U=e.mentionedUsers,k=void 0===U?[]:U,R=e.mentionedUserIds,M=void 0===R?[]:R,P=e.requestedMentionUserIds,L=void 0===P?[]:P,w=e.reactions,D=void 0===w?[]:w,H=e.metaArrays,F=void 0===H?[]:H,G=e.rootMessageId,j=void 0===G?0:G,B=e.parentMessageId,V=void 0===B?0:B,K=e.parentMessageText,q=void 0===K?"":K,z=e.threadInfo,Y=void 0===z?null:z,Q=e.isReplyToChannel,W=void 0!==Q&&Q,J=e.parentMessage,X=void 0===J?null:J,Z=e.translations,$=void 0===Z?{}:Z,ee=e.sendingStatus,te=e.errorCode,ne=void 0===te?0:te,re=e.silent,ie=void 0!==re&&re,se=e.isGlobalBlocked,ae=void 0!==se&&se,oe=e.messageSurvivalSeconds,le=void 0===oe?-1:oe,ue=e.ogMetaData,ce=void 0===ue?null:ue,de=e.isOperatorMessage,he=void 0!==de&&de,pe=e.plugins,fe=void 0===pe?[]:pe,_e=e.appleCriticalAlertOptions,ge=e.poll,ye=void 0===ge?null:ge,me=e.createdAt,Ee=e.updatedAt,ve=void 0===Ee?0:Ee,be=e.messageParams,Ce=void 0===be?null:be,Ae=e.isAutoResendRegistered,Ne=void 0!==Ae&&Ae,Se={};if(Se.req_id=E,Se.msg_id=y,Se.user=s.objectify(l({},v)),Se.channel_url=b.url,Se.channel_type=b.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,Se.message=C,Se.data=N,Se.custom_type=I,Se.translations=$,Se.is_global_block=!!ae,Se.ts=me,Se.updated_at=ve,Se.mention_type=O,Se.mentioned_users=k.map((function(e){return a.objectify(e)})),Se.mentioned_user_ids=M,Se.requested_mention_user_ids=L,Se.reactions=D.map((function(e){return e.serialize()})),Se.metaarray={},F.forEach((function(e){var t=e.key;Se.metaarray[t]=e.value})),Se.metaarray_key_order=F.map((function(e){return e.key})),Se.root_message_id=j,Se.parent_message_id=V,Se.parent_message_text=q,Y&&(Se.thread_info=d.objectify(Y)),Se.is_reply_to_channel=W,X)switch(X.messageType){case r.MESSAGE_TYPE_USER:Se.parent_message_info=o.objectify(X);break;case r.MESSAGE_TYPE_FILE:Se.parent_message_info=u.objectify(X);break;case r.MESSAGE_TYPE_ADMIN:Se.parent_message_info=c.objectify(X)}return Se.sending_status=y>0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ee&&(Se.sending_status=ee),Se.silent=!!ie,Se.error_code=ne,Se.message_survival_seconds=le,ce&&(Se.og_tag=h.objectify(ce)),Se.is_op_msg=!!he,Se.plugins=fe.map((function(e){return p.objectify(e)})),ye&&(Se.poll=_.objectify(ye)),_e&&(Se.apple_critical_alert_options=f.objectify(_e)),Ce&&(Se.message_params=g.objectify(Ce)),Se.is_auto_resend_registered=Ne,Se}},{key:"build",value:function(e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_,g,y,m,E,v,b,C,A,N,S,I,T,O,U){return this.objectify({messageId:t,reqId:e,user:n,channel:r,message:i,data:s,customType:a,mentionType:p,mentionedUsers:f,mentionedUserIds:E,requestedMentionUserIds:b,reactions:h,metaArrays:d,rootMessageId:_,parentMessageId:g,parentMessageText:y,threadInfo:m,translations:o,sendingStatus:v,errorCode:C,isGlobalBlocked:l,messageSurvivalSeconds:A,ogMetaData:N,isOperatorMessage:S,plugins:I,appleCriticalAlertOptions:T,poll:O,createdAt:u,updatedAt:c,messageParams:U})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).UserMessage,n=Ct.deserialize(e);return new t(t.objectify(l(l({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,messageParams:n.messageParams?new hr(hr.objectify(n.messageParams)):null})))}}]),n}(St),fr="file",_r="blob",gr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).fileName=null,r.mimeType=null,r.fileSize=null,r._isUpdate=!1,r._file=null,r._fileType=null,r._fileUrl=null,r._thumbnailSizes=[],e&&r._update(e),r}return h(n,[{key:"serialize",value:function(){return b(_(n.prototype),"_serialize",this).call(this,(function(e){e.hasOwnProperty("_isUpdate")&&(e.isUpdate=e._isUpdate,delete e._isUpdate),e.hasOwnProperty("_file")&&(e.file=e._file,delete e._file),e.hasOwnProperty("_fileType")&&(e.fileType=e._fileType,delete e._fileType),e.hasOwnProperty("_fileUrl")&&(e.fileUrl=e._fileUrl,delete e._fileUrl),e.hasOwnProperty("_thumbnailSizes")&&(e.thumbnailSizes=e._thumbnailSizes,delete e._thumbnailSizes)}))}},{key:"file",get:function(){return this._file},set:function(e){ie.isFile(e)&&(this._fileUrl=null,this._file=e,se.isFile(e)?this._fileType=fr:se.isBlob(e)&&(this._fileType=_r))}},{key:"fileType",get:function(){return this._fileType}},{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 t=0;t0&&e.maxHeight>0})))}}],[{key:"objectify",value:function(e){var t=e.fileName,n=void 0===t?null:t,r=e.mimeType,i=void 0===r?null:r,s=e.fileSize,a=void 0===s?null:s,o=e.data,u=void 0===o?null:o,c=e.customType,d=void 0===c?null:c,h=e.isUpdate,p=void 0!==h&&h,f=e.file,_=void 0===f?null:f,g=e.fileType,y=void 0===g?null:g,m=e.fileUrl,E=void 0===m?null:m,v=e.thumbnailSizes,b=void 0===v?[]:v;return l(l({},dr._objectify(e)),{},{file_name:n,mime_type:i,file_size:a,data:u,custom_type:d,is_update:p,file:_,file_type:y,file_url:E,thumbnail_sizes:b})}}]),n}(dr),yr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=St.MESSAGE_TYPE_FILE,r.plainUrl=null,r.name="File",r.size=0,r.type=null,r.thumbnails=[],r._sender=null,r.requireAuth=null,r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r._messageParams=null,e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){var t=ki.getInstance(this._iid),n=U.get(this._iid).container.auth,r=x.get(this._iid).Sender;if(this._sender=new r(e.user),this.requireAuth=!!e.hasOwnProperty("require_auth")&&e.require_auth,e.hasOwnProperty("url")&&(this.plainUrl=e.url.split("?auth=")[0]),this.name=e.hasOwnProperty("name")?e.name:"File",this.size=parseInt(e.size)||0,this.type=e.type,e.hasOwnProperty("custom")&&(this.data=e.custom),e.hasOwnProperty("file")){var i=e.file;i.hasOwnProperty("url")&&(this.plainUrl=i.url),i.hasOwnProperty("name")&&(this.name=i.name),i.hasOwnProperty("size")&&(this.size=i.size),i.hasOwnProperty("type")&&(this.type=i.type),i.hasOwnProperty("custom")&&(this.data=i.custom)}if(Object.defineProperty(this,"url",{value:this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(n.eKey):this.plainUrl,configurable:!0,writable:!1}),this.reqId=e.hasOwnProperty("req_id")?String(e.req_id):"",this.thumbnails=e.hasOwnProperty("thumbnails")?e.thumbnails:[],this.requireAuth)for(var s=0;s0?t.MessageRequestState.SUCCEEDED:t.MessageRequestState.FAILED,e.hasOwnProperty("sending_status")&&(this.requestState=e.sending_status,this.requestState===t.MessageSendingStatus.CANCELED&&(this.requestState=t.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),e.hasOwnProperty("message_params")&&(this._messageParams=new gr(e.message_params))}},{key:"sender",get:function(){var e=ki.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(e.Options.useMemberAsMessageSender&&this.isGroupChannel()){var n=t.cachedChannels[this.channelUrl];if(n){var r=n.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),ie.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=ki.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&ie.isResendableError(this.errorCode)}},{key:"serialize",value:function(){var e=this;return b(_(n.prototype),"serialize",this).call(this,(function(t){e._messageParams&&(t.messageParams=e._messageParams.serialize())}))}},{key:"messageParams",get:function(){return this._messageParams}},{key:"_clone",value:function(){var e=x.get(this._iid).FileMessage.buildFromSerializedData(this.serialize());if(this._messageParams&&e._messageParams){var t=this._messageParams.file;t&&se.isBlob(t)&&(e._messageParams.file=t.slice())}return e}}],[{key:"objectify",value:function(e){var t=ki.getInstance(this._iid),n=x.get(this._iid),r=n.BaseChannel,i=n.BaseMessageParams,s=n.Sender,a=n.User,o=n.UserMessage,u=n.FileMessage,c=n.AdminMessage,d=n.ThreadInfo,h=n.OGMetaData,p=n.FileMessageParams,f=n.AppleCriticalAlertOptions,_=e.messageId,g=e.reqId,y=void 0===g?"":g,m=e.user,E=void 0===m?{}:m,v=e.channel,b=e.plainUrl,C=e.name,A=void 0===C?null:C,N=e.type,S=e.size,I=void 0===S?0:S,T=e.data,O=void 0===T?"":T,U=e.customType,k=void 0===U?"":U,R=e.mentionType,M=void 0===R?i.MentionType.USERS:R,P=e.mentionedUsers,L=void 0===P?[]:P,w=e.mentionedUserIds,D=void 0===w?[]:w,H=e.requestedMentionUserIds,F=void 0===H?[]:H,G=e.reactions,j=void 0===G?[]:G,B=e.metaArrays,V=void 0===B?[]:B,K=e.rootMessageId,q=void 0===K?0:K,z=e.parentMessageId,Y=void 0===z?0:z,Q=e.parentMessageText,W=void 0===Q?"":Q,J=e.threadInfo,X=void 0===J?null:J,Z=e.isReplyToChannel,$=void 0!==Z&&Z,ee=e.parentMessage,te=void 0===ee?null:ee,ne=e.thumbnails,re=void 0===ne?[]:ne,ie=e.requireAuth,se=void 0!==ie&&ie,ae=e.sendingStatus,oe=e.errorCode,le=void 0===oe?0:oe,ue=e.silent,ce=void 0!==ue&&ue,de=e.isGlobalBlocked,he=void 0!==de&&de,pe=e.messageSurvivalSeconds,fe=void 0===pe?-1:pe,_e=e.ogMetaData,ge=void 0===_e?null:_e,ye=e.isOperatorMessage,me=void 0!==ye&&ye,Ee=e.appleCriticalAlertOptions,ve=e.createdAt,be=e.updatedAt,Ce=void 0===be?0:be,Ae=e.messageParams,Ne=void 0===Ae?null:Ae,Se=e.isAutoResendRegistered,Ie=void 0!==Se&&Se,Te={};Te.req_id=y,Te.msg_id=_,Te.user=s.objectify(l({},E)),Te.channel_url=v.url,Te.channel_type=v.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,Te.url=b,Te.name=A,Te.type=N,Te.size=I,Te.custom=O,Te.custom_type=k,Te.thumbnails=re,Te.require_auth=se,Te.is_global_block=!!he,Te.ts=ve,Te.updated_at=Ce,Te.mention_type=M,Te.mentioned_users=L.map((function(e){return a.objectify(e)})),Te.mentioned_user_ids=D,Te.requested_mention_user_ids=F,Te.reactions=j.map((function(e){return e.serialize()})),Te.metaarray={};for(var Oe=0;Oe0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ae&&(Te.sending_status=ae),Te.silent=!!ce,Te.error_code=le,Te.message_survival_seconds=fe,ge&&(Te.og_tag=h.objectify(ge)),Te.is_op_msg=!!me,Ee&&(Te.apple_critical_alert_options=f.objectify(Ee)),Ne&&(Te.message_params=p.objectify(Ne)),Te.is_auto_resend_registered=Ie,Te}},{key:"build",value:function(e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_,g,y,m,E,v,b,C,A,N,S,I,T,O,U,k,R){return this.objectify({messageId:t,reqId:e,user:n,channel:r,plainUrl:i,name:s,type:a,size:o,data:l,customType:u,mentionType:y,mentionedUsers:m,mentionedUserIds:A,requestedMentionUserIds:S,reactions:g,metaArrays:_,rootMessageId:E,parentMessageId:v,parentMessageText:b,threadInfo:C,thumbnails:h,requireAuth:p,sendingStatus:N,errorCode:I,isGlobalBlocked:c,messageSurvivalSeconds:T,ogMetaData:O,isOperatorMessage:U,appleCriticalAlertOptions:k,createdAt:d,updatedAt:f,messageParams:R})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).FileMessage,n=Ct.deserialize(e);return new t(t.objectify(l(l({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,messageParams:n.messageParams?new gr(gr.objectify(n.messageParams)):null})))}}]),n}(St),mr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=St.MESSAGE_TYPE_ADMIN,r.message="",r.translations={},e&&r._update(e),r}return h(n,[{key:"_update",value:function(e){this.message=String(e.message),this.translations=e.hasOwnProperty("translations")?e.translations:{}}}],[{key:"objectify",value:function(e){var t=x.get(this._iid),n=t.BaseChannel,r=t.BaseMessageParams,i=t.UserMessage,s=t.FileMessage,a=t.AdminMessage,o=t.User,l=t.ThreadInfo,u=t.OGMetaData,c=e.messageId,d=e.channel,h=e.message,p=e.data,f=void 0===p?"":p,_=e.customType,g=void 0===_?"":_,y=e.mentionType,m=void 0===y?r.MentionType.USERS:y,E=e.mentionedUsers,v=void 0===E?[]:E,b=e.reactions,C=void 0===b?[]:b,A=e.metaArrays,N=void 0===A?[]:A,S=e.rootMessageId,I=void 0===S?0:S,T=e.parentMessageId,O=void 0===T?0:T,U=e.parentMessageText,k=void 0===U?"":U,R=e.threadInfo,M=void 0===R?null:R,P=e.isReplyToChannel,L=void 0!==P&&P,w=e.parentMessage,D=void 0===w?null:w,H=e.translations,F=void 0===H?{}:H,G=e.silent,j=void 0!==G&&G,B=e.ogMetaData,V=void 0===B?null:B,K=e.createdAt,q=e.updatedAt,z=void 0===q?0:q,Y={msg_id:c,channel_url:d.url,channel_type:d.channelType===n.CHANNEL_TYPE_OPEN?n.CHANNEL_TYPE_OPEN:n.CHANNEL_TYPE_GROUP,message:h,data:f,custom_type:g,silent:j,ts:K,updated_at:z};Y.translations=F,Y.mention_type=m,Y.mentioned_users=v.map((function(e){return o.objectify(e)})),Y.reactions=C.map((function(e){return e.serialize()})),Y.metaarray={};for(var Q=0;Q0&&Array.isArray(t.userIdsFilter)&&"string"==typeof t.metaDataKeyFilter&&Array.isArray(t.metaDataValuesFilter)&&!!t.metaDataKeyFilter==t.metaDataValuesFilter.length>0&&("string"==typeof t.nicknameStartsWithFilter||null===t.nicknameStartsWithFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadUserList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Nr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._isOpenChannel=!1,this._channelUrl=null,this._token="",t.channelUrl&&(this._channelUrl=t.channelUrl),t.isOpenChannel&&(this._isOpenChannel=t.isOpenChannel)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadBannedUserList(l(l({},t),{},{channelUrl:t._channelUrl,isOpenChannel:t._isOpenChannel,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).RestrictedUser,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.banned_list.map((function(e){var t=new s(e);return t.restrictionInfo.restrictionType=s.RestrictionType.BANNED,t}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Sr=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 t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0&&Array.isArray(t.userIdsFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadBlockedUserList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Ir=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 t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasMore?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadFriendList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasMore=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Tr=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=Jn.MemberStateFilter.ALL,this.customTypesFilter=[],this.channelUrlsFilter=[],this.superChannelFilter=Jn.SuperChannelFilter.ALL,this.publicChannelFilter=Jn.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Jn.UnreadChannelFilter.ALL,this.metadataOrderKeyFilter=null,this.metadataKey=null,this.metadataValues=[],this.metadataValueStartsWith=null,this.hiddenChannelFilter=Jn.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(t){Object.keys(e.QueryType).map((function(t){return e.QueryType[t]})).indexOf(t)>-1&&(this._userIdsIncludeFilterQueryType=t.toUpperCase(),this._userIdsFilter.queryType=this._userIdsIncludeFilterQueryType)}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={search_query:t,search_fields:e.join(",").toLocaleLowerCase()})}},{key:"serialize",value:function(){return Ct.serialize(this,(function(e){e.isLoading=!1}))}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.GroupChannel,i=n.GroupChannelListQuery;!("number"==typeof t.limit&&t.limit>0&&"boolean"==typeof t.includeEmpty&&"string"==typeof t.order&&[i.ORDER_CHRONOLOGICAL,i.ORDER_LATEST_LAST_MESSAGE,i.CHANNEL_NAME_ALPHABETICAL,i.METADATA_VALUE_ALPHABETICAL].indexOf(t.order.toLowerCase())>-1&&Array.isArray(t._userIdsExactFilter)&&Array.isArray(t._userIdsIncludeFilter)&&Array.isArray(t.customTypesFilter)&&Array.isArray(t.channelUrlsFilter)&&Object.keys(i.QueryType).map((function(e){return i.QueryType[e]})).indexOf(t._userIdsIncludeFilterQueryType.toUpperCase())>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(t.memberStateFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(t.superChannelFilter)>-1&&Object.keys(r.PublicChannelFilter).map((function(e){return r.PublicChannelFilter[e]})).indexOf(t.publicChannelFilter)>-1&&Object.keys(r.UnreadChannelFilter).map((function(e){return r.UnreadChannelFilter[e]})).indexOf(t.unreadChannelFilter)>-1&&Object.keys(r.HiddenChannelFilter).map((function(e){return r.HiddenChannelFilter[e]})).indexOf(t.hiddenChannelFilter)>-1)||"string"!=typeof t.customTypeStartsWithFilter&&null!==t.customTypeStartsWithFilter||"string"!=typeof t.nicknameContainsFilter||"string"!=typeof t.channelNameContainsFilter||"string"!=typeof t.metadataOrderKeyFilter&&null!==t.metadataOrderKeyFilter||"string"!=typeof t.metadataKey&&null!==t.metadataKey||!Array.isArray(t.metadataValues)||!t.metadataValues.every((function(e){return"string"==typeof e}))||"string"!=typeof t.metadataValueStartsWith&&null!==t.metadataValueStartsWith||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadGroupChannelList(l(l({},t),{},{token:t._token,userIdsFilter:t._userIdsFilter,searchFilter:t._searchFilter})).then((function(n){var r=x.get(t._iid).GroupChannel,i=String(n.next);t._token=i,t.hasNext=!!i;var s=n.channels;if(!s||!Array.isArray(s))throw new H("Failed at loading group channels.",H.MALFORMED_DATA);var a=s.map((function(e){return"number"==typeof n.ts&&(e.ts=n.ts),r.upsert(e)}));t.isLoading=!1,e(null,a)})).catch((function(n){t.isLoading=!1,e(n,null)}))):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 t=x.get(this._iid).GroupChannel,n=Ct.deserialize(e),r=t.createMyGroupChannelListQuery();return Object.keys(n).forEach((function(e){r.hasOwnProperty(e)&&(r[e]=n[e])})),r}}]),e}(),Or=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.mutedMemberFilter=e.MutedMemberFilter.ALL,this.memberStateFilter=Jn.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.order=e.Order.MEMBER_NICKNAME_ALPHABETICAL,this._token="",this._channelUrl=t}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid),r=n.GroupChannel,i=n.Member,s=n.MemberListQuery;"number"==typeof t.limit&&t.limit>0&&Object.keys(s.MutedMemberFilter).map((function(e){return s.MutedMemberFilter[e]})).indexOf(t.mutedMemberFilter)>-1&&Object.keys(r.MemberStateFilter).map((function(e){return r.MemberStateFilter[e]})).indexOf(t.memberStateFilter)>-1&&Object.keys(s.Order).map((function(e){return s.Order[e]})).indexOf(t.order)>-1&&("string"==typeof t.nicknameStartsWithFilter||null===t.nicknameStartsWithFilter)?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadMemberList(l(l({},t),{},{channelUrl:t._channelUrl,token:t._token}),(function(n,r){var s=null;if(!n){var a=String(r.next);t._token=a,t.hasNext=!!a,s=r.members.map((function(e){return new i(e)}))}t.isLoading=!1,e(n,s)}))):e(null,[]):e(tt.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}(),Ur=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t.channelUrl&&(this._channelUrl=t.channelUrl),t.isOpenChannel&&(this._isOpenChannel=t.isOpenChannel)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadMutedUserList(l(l({},t),{},{channelUrl:t._channelUrl,isOpenChannel:t._isOpenChannel,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).RestrictedUser,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.muted_list.map((function(e){var t=new s(e);return t.restrictionInfo.restrictionType=s.RestrictionType.MUTED,t}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),kr=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 t=this;return oe(this._iid,(function(e){!("number"==typeof t.limit&&t.limit>0&&Array.isArray(t.customTypes))||"string"!=typeof t.nameKeyword&&null!==t.nameKeyword||"string"!=typeof t.urlKeyword&&null!==t.urlKeyword||"boolean"!=typeof t.includeFrozen||"boolean"!=typeof t.includeMetaData?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadOpenChannelList(l(l({},t),{},{token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).OpenChannel,a=String(r.next);t._token=a,t.hasNext=!!a;var o=r.channels;o&&Array.isArray(o)?i=o.map((function(e){return"number"==typeof r.ts&&(e.ts=r.ts),s.upsert(e)})):n=new H("Failed at loading open channels.",H.MALFORMED_DATA)}t.isLoading=!1,e(n,i)}))):e(null,[])}),e)}}]),e}(),Rr=new WeakMap,Mr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",Rr.set(this,t)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){if("number"==typeof t.limit&&t.limit>0)if(t.isLoading)e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(t.hasNext){t.isLoading=!0;var n=Rr.get(t);U.get(t._iid).container.apiClient.loadOperatorList(l(l({},t),{},{token:t._token,channelUrl:n.url,isOpenChannel:n.isOpenChannel()}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.operators.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))}else e(null,[]);else e(tt.error,null)}),e)}}]),e}(),Pr=new WeakMap,Lr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t&&Pr.set(this,t.channelUrl)}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadParticipantList(l(l({},t),{},{channelUrl:Pr.get(t),token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.participants.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),wr=new WeakMap,Dr=function(){function e(t,n){var r=n.limit,i=void 0===r?20:r,s=n.reverse,a=void 0!==s&&s,o=n.exactMatch,l=void 0!==o&&o,u=n.channelUrl,d=void 0===u?"":u,h=n.channelCustomType,p=void 0===h?"":h,f=n.messageTimestampFrom,_=void 0===f?null:f,g=n.messageTimestampTo,y=void 0===g?null:g,m=n.order,E=void 0===m?"score":m,v=n.advancedQuery,b=void 0!==v&&v,C=n.targetFields,A=void 0===C?null:C;c(this,e),this.isLoading=!1,this.hasNext=!0,wr.set(this,{keyword:t,limit:i,reverse:a,exactMatch:l,channelUrl:d,channelCustomType:p,messageTimestampFrom:_,messageTimestampTo:y,order:E,advancedQuery:b,targetFields:A,previousToken:"",nextToken:""})}return h(e,[{key:"key",get:function(){return wr.get(this).keyword}},{key:"limit",get:function(){return wr.get(this).limit}},{key:"reverse",get:function(){return wr.get(this).reverse}},{key:"exactMatch",get:function(){return wr.get(this).exactMatch}},{key:"channelUrl",get:function(){return wr.get(this).channelUrl}},{key:"channelCustomType",get:function(){return wr.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return wr.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return wr.get(this).messageTimestampTo}},{key:"order",get:function(){return wr.get(this).order}},{key:"next",value:function(e){var t=this,n=x.get(this._iid),r=n.BaseChannel,i=n.GroupChannel,s=n.OpenChannel;return oe(this._iid,(function(e){var n=wr.get(t),a=n.keyword,o=n.limit,l=n.reverse,u=n.exactMatch,c=n.channelUrl,d=n.channelCustomType,h=n.messageTimestampFrom,p=n.messageTimestampTo,f=n.order,_=n.advancedQuery,g=n.targetFields,y=n.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 _&&null!==_||!Array.isArray(g)&&null!==g?e(tt.error,null):t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.searchMessages({keyword:a,limit:o,reverse:l,exactMatch:u,channelUrl:c,channelCustomType:d,messageTimestampFrom:h,messageTimestampTo:p,order:f,advancedQuery:_,targetFields:g,nextToken:y},(function(n,a){var o=null;n||(o=[],a.results.forEach((function(e){if(e.channel.hasOwnProperty("members")){var t=new i(e.channel);i.cachedChannels[t.url]=t,o.push(r.buildMessage(e,t))}else{var n=new s(e.channel);s.cachedChannels[n.url]=n,o.push(r.buildMessage(e,n))}})),t.hasNext=a.has_next,wr.get(t).nextToken=a.end_cursor),t.isLoading=!1,e(n,o)}))):e(null,[])}),e)}}]),e}(),Hr=new WeakMap,Fr=new WeakMap,Gr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,Fr.set(this,Number.MAX_SAFE_INTEGER),Hr.set(this,t),this.reverse=!1,this.messageTypeFilter=null,this.customTypeFilter=null,this.customTypesFilter=[],this.senderUserIdsFilter=[],this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.showSubchannelMessagesOnly=!1,this.includePollDetails=!1}return h(e,[{key:"load",value:function(e,t,n,r){var i=this,s=x.get(this._iid),a=s.BaseChannel,o=s.BaseMessage,l=null,u=tt.parse(arguments,[new tt({type:"number",optional:!0,defaultValue:this.limit}),new tt({type:"boolean",optional:!0,defaultValue:this.reverse}),new tt({type:["string","number"],optional:!0,defaultValue:this.messageTypeFilter,constraint:function(e){return Object.keys(a.MessageTypeFilter).map((function(e){return a.MessageTypeFilter[e]})).indexOf(e)>-1||[0,1,2,3].indexOf(e)>-1}}),new tt({type:"callback"})]),c=C(u,5);return l=c[0],e=c[1],t=c[2],n=c[3],r=c[4],oe(this._iid,(function(r){if(("string"!=typeof i.customTypeFilter&&null!==i.customTypeFilter||!Array.isArray(i.customTypesFilter)||!i.customTypesFilter.every((function(e){return"string"==typeof e||null===e}))||!Array.isArray(i.senderUserIdsFilter)||!i.senderUserIdsFilter.every((function(e){return"string"==typeof e}))||"boolean"!=typeof i.includeMetaArray||null!==i.includeReaction&&"boolean"!=typeof i.includeReaction||null!==i.includeReactions&&"boolean"!=typeof i.includeReactions||"boolean"!=typeof i.includeThreadInfo||null!==i.includeReplies&&"boolean"!=typeof i.includeReplies||!(null===i.replyType||"string"==typeof i.replyType&&Object.values(o.ReplyType).includes(i.replyType))||null!==i.includeParentMessageText&&"boolean"!=typeof i.includeParentMessageText||null!==i.includeParentMessageInfo&&"boolean"!=typeof i.includeParentMessageInfo||"boolean"!=typeof i.showSubchannelMessagesOnly)&&(l=tt.error),l)r(l,null);else{if(i.limit=e,i.reverse=t,i.messageTypeFilter=n,"number"==typeof i.messageTypeFilter)switch(i.messageTypeFilter){case 0:i.messageTypeFilter=a.MessageTypeFilter.ALL;break;case 1:i.messageTypeFilter=a.MessageTypeFilter.USER;break;case 2:i.messageTypeFilter=a.MessageTypeFilter.FILE;break;case 3:i.messageTypeFilter=a.MessageTypeFilter.ADMIN}if(i.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(i.hasMore){i.isLoading=!0;var s=Hr.get(i);U.get(i._iid).container.apiClient.getMessageList({channel:s,token:Fr.get(i)||(new Date).getTime()+1e4,tokenType:"timestamp",isInclusive:!1,prevResultSize:e,nextResultSize:0,shouldReverse:t,messageType:i.messageTypeFilter,customType:i.customTypeFilter,customTypes:i.customTypesFilter,senderUserIds:i.senderUserIdsFilter,includeMetaArray:i.includeMetaArray,includeReaction:i.includeReaction,includeReactions:i.includeReactions,includeReplies:i.includeReplies,includeParentMessageText:i.includeParentMessageText,includeThreadInfo:i.includeThreadInfo,replyType:i.replyType,includeParentMessageInfo:i.includeParentMessageInfo,showSubchannelMessagesOnly:i.showSubchannelMessagesOnly,includePollDetails:i.includePollDetails}).then((function(t){var n=t.messages.map((function(e){return a.buildMessage(e,s)}));(0===n.length||n.length0&&"boolean"==typeof n.includeEmpty&&"string"==typeof n.order&&[e.ORDER_CHRONOLOGICAL,e.CHANNEL_NAME_ALPHABETICAL,e.METADATA_VALUE_ALPHABETICAL,e.ORDER_LATEST_LAST_MESSAGE].indexOf(n.order.toLowerCase())>-1&&Array.isArray(n.customTypesFilter)&&Array.isArray(n.channelUrlsFilter)&&Object.keys(e.MembershipType).map((function(t){return e.MembershipType[t]})).indexOf(n.membershipFilter)>-1&&Object.keys(r.SuperChannelFilter).map((function(e){return r.SuperChannelFilter[e]})).indexOf(n.superChannelFilter)>-1)||"string"!=typeof n.customTypeStartsWithFilter&&null!==n.customTypeStartsWithFilter||"string"!=typeof n.channelNameContainsFilter||"string"!=typeof n.metadataOrderKeyFilter&&null!==n.metadataOrderKeyFilter||"string"!=typeof n.metadataKey&&null!==n.metadataKey||!Array.isArray(n.metadataValues)||!n.metadataValues.every((function(e){return"string"==typeof e}))||"string"!=typeof n.metadataValueStartsWith&&null!==n.metadataValueStartsWith||"boolean"!=typeof n.includeFrozen||"boolean"!=typeof n.includeMetaData?t(tt.error,null):n.isLoading?t(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):n.hasNext?(n.isLoading=!0,U.get(n._iid).container.apiClient.loadPublicGroupChannelList(l(l({},n),{},{token:n._token}),(function(e,i){var s=null;if(!e){var a=String(i.next);n._token=a,n.hasNext=!!a;var o=i.channels;o&&Array.isArray(o)?s=o.map((function(e){return"number"==typeof i.ts&&(e.ts=i.ts),r.upsert(e)})):e=new H("Failed at loading group channels.",H.MALFORMED_DATA)}n.isLoading=!1,t(e,s)}))):t(null,[])}),t)}}],[{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}(),jr=new WeakMap,Br=new WeakMap,Vr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.token,s=void 0===i?"":i,a=t.limit,o=void 0===a?20:a;c(this,e),this.channelUrl=r,this.token=s,this.limit=o,jr.set(this,!1),Br.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!jr.get(this)}},{key:"hasNext",get:function(){return!!Br.get(this)}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"string"==typeof t.channelUrl&&"number"==typeof t.limit&&t.limit>0&&t.limit<=100?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(jr.set(t,!0),U.get(t._iid).container.apiClient.getPollList(l({},t),(function(n,r){if(n)jr.set(t,!1),e(n,null);else{var i=x.get(t._iid).Poll,s=r.hasOwnProperty("polls")&&Array.isArray(r.polls)?r.polls.map((function(e){return new i(e)})):[],a=r.hasOwnProperty("next")&&r.next?String(r.next):"";t.token=a,jr.set(t,!1),Br.set(t,!!a),e(null,s)}}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Kr=new WeakMap,qr=new WeakMap,zr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.pollId,s=void 0===i?null:i,a=t.optionId,o=void 0===a?null:a,l=t.token,u=void 0===l?"":l,d=t.limit,h=void 0===d?100:d;c(this,e),this.channelUrl=r,this.pollId=s,this.optionId=o,this.token=u,this.limit=h,Kr.set(this,!1),qr.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!Kr.get(this)}},{key:"hasNext",get:function(){return!!qr.get(this)}},{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"string"==typeof t.channelUrl&&"number"==typeof t.pollId&&"number"==typeof t.optionId&&"number"==typeof t.limit&&t.limit>0&&t.limit<=100?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(Kr.set(t,!0),U.get(t._iid).container.apiClient.getPollOptionVoterList(l({},t),(function(n,r){if(n)Kr.set(t,!1),e(n,null);else{var i=x.get(t._iid).User,s=r.hasOwnProperty("voters")&&Array.isArray(r.voters)?r.voters.map((function(e){return new i(e)})):[],a=r.hasOwnProperty("next")&&r.next?String(r.next):"";t.token=a,Kr.set(t,!1),qr.set(t,!!a),e(null,s)}}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Yr=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 t=null;Object.defineProperty(this,"operators",{set:function(e){Array.isArray(e)&&(e.filter((function(e){return e.hasOwnProperty("userId")})).length===e.length&&(t=e.map((function(e){return e.userId}))))}}),Object.defineProperty(this,"operatorUserIds",{get:function(){return t},set:function(e){Array.isArray(e)&&(e.filter((function(e){return"string"==typeof e})).length===e.length&&(t=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)&&(ie.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 t,n=e.filter((function(e){return e.hasOwnProperty("userId")&&"string"==typeof e.userId})).map((function(e){return e.userId}));(t=this._invitedUserIds).push.apply(t,A(n))}}},{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 t,n=e.filter((function(e){return"string"==typeof e}));(t=this._invitedUserIds).push.apply(t,A(n))}}},{key:"addUserId",value:function(e){"string"==typeof e&&this._invitedUserIds.push(e)}}]),e}(),Qr=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||ie.isFile(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&("string"==typeof this.name||null===this.name)&&("string"==typeof this.data||null===this.data)&&("string"==typeof this.customType||null===this.customType)&&("string"==typeof this.channelUrl&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)}}]),e}(),Wr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.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(n,[{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,t,n,r,i,s){"number"==typeof e&&4===e.toString().length&&"number"==typeof t&&t>=1&&t<=12&&"number"==typeof n&&n>=1&&n<=31&&"number"==typeof r&&r>=0&&r<=24&&"number"==typeof i&&i>=0&&i<=60&&"string"==typeof s&&s.length>0&&(this.scheduledDateTimeString=e.toString()+"-"+("0"+t.toString()).substr(-2)+"-"+("0"+n.toString()).substr(-2)+" "+("0"+r.toString()).substr(-2)+":"+("0"+i.toString()).substr(-2),this.timezone=s)}}]),n}(hr),Jr=function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=Jn.SuperChannelFilter.ALL},Xr=function(){function e(){c(this,e),this.channelUrl=null,this.channelType=null,this.messageId=0,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid).BaseChannel;return"string"==typeof this.channelUrl&&"string"==typeof this.channelType&&[e.CHANNEL_TYPE_BASE,e.CHANNEL_TYPE_OPEN,e.CHANNEL_TYPE_GROUP].includes(this.channelType)&&"number"==typeof this.messageId&&"boolean"==typeof this.includeMetaArray&&"boolean"==typeof this.includeReactions&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),Zr=function(){function e(){c(this,e);var t=x.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=t.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.showSubchannelMessagesOnly=!1,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid),t=e.BaseChannel,n=e.BaseMessage;return"number"==typeof this.prevResultSize&&"number"==typeof this.nextResultSize&&"boolean"==typeof this.isInclusive&&"boolean"==typeof this.reverse&&"string"==typeof this.messageType&&Object.values(t.MessageTypeFilter).includes(this.messageType)&&("string"==typeof this.customType||null===this.customType)&&Array.isArray(this.customTypes)&&this.customTypes.every((function(e){return"string"==typeof e||null===e}))&&(Array.isArray(this.senderUserIds)&&this.senderUserIds.every((function(e){return"string"==typeof e}))||null===this.senderUserIds)&&"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(n.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.showSubchannelMessagesOnly&&"boolean"==typeof this.includePollDetails}},{key:"belongsTo",value:function(e){var t=x.get(this._iid),n=t.BaseChannel,r=t.UserMessageParams,i=t.FileMessageParams,s=t.BaseMessage;if(this.messageType!==n.MessageTypeFilter.ALL){if(e instanceof r&&this.messageType!==n.MessageTypeFilter.USER)return!1;if(e instanceof i&&this.messageType!==n.MessageTypeFilter.FILE)return!1}if(Array.isArray(this.customTypes)&&this.customTypes.length>0&&!this.customTypes.includes(e.customType))return!1;if("string"==typeof this.customType&&this.customType!==e.customType)return!1;if(Array.isArray(this.senderUserIds)&&this.senderUserIds.length>0){var a=ki.getInstance(e._iid);if(!a||!a.currentUser||!this.senderUserIds.includes(a.currentUser.userId))return!1}if("string"==typeof this.replyType&&e.parentMessageId){if(this.replyType===s.ReplyType.NONE)return!1;if(this.replyType===s.ReplyType.ONLY_REPLY_TO_CHANNEL&&!e.isReplyToChannel)return!1}else if(!1===this.includeReplies&&e.parentMessageId)return!1;return!0}}]),e}(),$r=function(){function e(){c(this,e);var t=x.get(this._iid).BaseChannel;this.prevResultSize=0,this.nextResultSize=0,this.isInclusive=!1,this.reverse=!1,this.messageType=t.MessageTypeFilter.ALL,this.customType=null,this.customTypes=[],this.senderUserIds=null,this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeParentMessageText=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){var e=x.get(this._iid).BaseChannel;return"number"==typeof this.prevResultSize&&"number"==typeof this.nextResultSize&&"boolean"==typeof this.isInclusive&&"boolean"==typeof this.reverse&&"string"==typeof this.messageType&&Object.values(e.MessageTypeFilter).includes(this.messageType)&&("string"==typeof this.customType||null===this.customType)&&Array.isArray(this.customTypes)&&this.customTypes.every((function(e){return"string"==typeof e||null===e}))&&(Array.isArray(this.senderUserIds)&&this.senderUserIds.every((function(e){return"string"==typeof e}))||null===this.senderUserIds)&&"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),ei=function(){function e(){c(this,e),this.includeMetaArray=!1,this.includeReaction=null,this.includeReactions=null,this.includeReplies=null,this.includeParentMessageText=null,this.includeThreadInfo=!1,this.replyType=null,this.includeParentMessageInfo=null,this.includePollDetails=!1}return h(e,[{key:"_validate",value:function(){return"boolean"==typeof this.includeMetaArray&&(null===this.includeReaction||"boolean"==typeof this.includeReaction)&&(null===this.includeReactions||"boolean"==typeof this.includeReactions)&&"boolean"==typeof this.includeThreadInfo&&(null===this.includeReplies||"boolean"==typeof this.includeReplies)&&(null===this.replyType||"string"==typeof this.replyType&&Object.values(BaseMessage.ReplyType).includes(this.replyType))&&(null===this.includeParentMessageText||"boolean"==typeof this.includeParentMessageText)&&(null===this.includeParentMessageInfo||"boolean"==typeof this.includeParentMessageInfo)&&"boolean"==typeof this.includePollDetails}}]),e}(),ti=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}(),ni=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.title,r=void 0===n?null:n,i=t.options,s=void 0===i?null:i,a=t.data,o=void 0===a?null:a,l=t.isAnonymous,u=void 0===l?null:l,d=t.allowUserSuggestion,h=void 0===d?null:d,p=t.allowMultipleVotes,f=void 0===p?null:p,_=t.closeAt,g=void 0===_?null:_;c(this,e),this.title=r,this.options=s,this.data=o,this.isAnonymous=u,this.allowUserSuggestion=h,this.allowMultipleVotes=f,this.closeAt=g}return h(e,[{key:"_validate",value:function(){return"string"==typeof this.title&&(Array.isArray(this.options)&&this.options.length>0&&this.options.every((function(e){return"string"==typeof e}))||null===this.options)&&("string"==typeof this.data||null==this.data)&&("boolean"==typeof this.isAnonymous||null===this.isAnonymous)&&("boolean"==typeof this.allowUserSuggestion||null===this.allowUserSuggestion)&&("boolean"==typeof this.allowMultipleVotes||null===this.allowMultipleVotes)&&("number"==typeof this.closeAt||null===this.closeAt)}}]),e}(),ri=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.channelUrl,r=void 0===n?null:n,i=t.pollId,s=void 0===i?null:i,a=t.showPartialVoters,o=void 0!==a&&a;c(this,e),this.channelUrl=r,this.pollId=s,this.showPartialVoters=o}return h(e,[{key:"_validate",value:function(){return"string"==typeof this.channelUrl&&"number"==typeof this.pollId&&"boolean"==typeof this.showPartialVoters}}]),e}(),ii=function(){this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},si=function(){this.onFriendsDiscovered=function(){},this.onTotalUnreadMessageCountUpdated=function(){}},ai=function e(){c(this,e),this.onMessageReceived=function(e,t){},this.onMessageUpdated=function(e,t){},this.onMessageDeleted=function(e,t){},this.onReadReceiptUpdated=function(e){},this.onReactionUpdated=function(e,t){},this.onDeliveryReceiptUpdated=function(e){},this.onTypingStatusUpdated=function(e){},this.onUserJoined=function(e,t){},this.onUserLeft=function(e,t){},this.onOperatorUpdated=function(e,t){},this.onUserEntered=function(e,t){},this.onUserExited=function(e,t){},this.onUserMuted=function(e,t){},this.onUserUnmuted=function(e,t){},this.onUserBanned=function(e,t){},this.onUserUnbanned=function(e,t){},this.onChannelFrozen=function(e){},this.onChannelUnfrozen=function(e){},this.onChannelChanged=function(e){},this.onChannelDeleted=function(e,t){},this.onUserReceivedInvitation=function(e,t,n){},this.onUserDeclinedInvitation=function(e,t,n){},this.onMetaDataCreated=function(e,t){},this.onMetaDataUpdated=function(e,t){},this.onMetaDataDeleted=function(e,t){},this.onMetaCountersCreated=function(e,t){},this.onMetaCountersUpdated=function(e,t){},this.onMetaCountersDeleted=function(e,t){},this.onChannelHidden=function(e){},this.onMentionReceived=function(e,t){},this.onThreadInfoUpdated=function(e,t){},this.onChannelMemberCountChanged=function(e){},this.onChannelParticipantCountChanged=function(e){},this.onPollUpdated=function(e){},this.onPollVoted=function(e){}},oi=function e(t){if(c(this,e),t){var n=x.get(this._iid),r=n.User,i=n.BaseChannel;this.reader=new r(t.user),this.timestamp=parseInt(t.ts),this.channelUrl=t.hasOwnProperty("channel_url")?String(t.channel_url):"",this.channelType=t.hasOwnProperty("channel_type")?String(t.channel_type):i.CHANNEL_TYPE_GROUP}},li=function(){function e(e,t,n){void 0===t&&(t=[]),void 0===n&&(n=0),this.key=e,this.userIds=t,this.updatedAt=n;for(var r={},i=0,s=this.userIds;i0&&"number"==typeof r?new this(t,n,r):null},e.prototype.serialize=function(){return{key:this.key,user_ids:this.userIds,updated_at:this.updatedAt}},e.prototype._applyEvent=function(e){if(e.key===this.key&&(!this._version[e.userId]||this._version[e.userId]=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}},e}(),ui=function(){function e(e){this.replyCount=0,this.mostRepliedUsers=[],this.lastRepliedAt=0,this.updatedAt=0,e&&this._update(e)}return e.objectify=function(e){var t=x.get(this._iid).User,n=e.replyCount,r=void 0===n?0:n,i=e.mostRepliedUsers,s=void 0===i?[]:i,a=e.lastRepliedAt,o=void 0===a?0:a,l=e.updatedAt,u=void 0===l?0:l,c={};return c.reply_count=r,Array.isArray(s)&&s.every((function(e){return e instanceof t}))&&(c.most_replies=s.map((function(e){return t.objectify(e)}))),c.last_replied_at=o,c.updated_at=u,c},e.build=function(e,t,n,r){return this.objectify({replyCount:e,mostRepliedUsers:t,lastRepliedAt:n,updatedAt:r})},e.prototype._update=function(e){var t=x.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"==typeof e}))&&(this.mostRepliedUsers=e.most_replies.map((function(e){return new t(e)}))),e.hasOwnProperty("last_replied_at")&&(this.lastRepliedAt=parseInt(e.last_replied_at)),e.hasOwnProperty("updated_at")&&(this.updatedAt=parseInt(e.updated_at))},e}(),ci=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e&&this._update(e)}return e.objectify=function(e){var t=x.get(this._iid).OGImage,n=e.title,r=void 0===n?null:n,i=e.url,s=void 0===i?null:i,a=e.description,o=void 0===a?null:a,l=e.defaultImage,u=void 0===l?null:l,c={};return c["og:title"]=r,c["og:url"]=s,c["og:description"]=o,u&&(c["og:image"]=t.objectify(u)),c},e.prototype._update=function(e){var t=x.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 t(e["og:image"]))},e}(),di=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,e&&this._update(e)}return e.objectify=function(e){var t=e.url,n=void 0===t?null:t,r=e.secureUrl,i=void 0===r?null:r,s=e.type,a=void 0===s?null:s,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=n,p.secure_url=i,p.type=a,p.width=l,p.height=c,p.alt=h,p},e.prototype._update=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)},e}(),hi=function(){function e(e){this.type=null,this.vendor=null,this.detail={},e&&this._update(e)}return e.objectify=function(e){var t=e.type,n=void 0===t?"":t,r=e.vendor,i=void 0===r?"":r,s=e.detail,a=void 0===s?{}:s,o={};return o.type=n,o.vendor=i,o.detail=a,o},e.prototype._update=function(e){this.type=e.hasOwnProperty("type")?e.type:"",this.vendor=e.hasOwnProperty("vendor")?e.vendor:"",e.hasOwnProperty("detail")&&"object"==typeof e.detail&&!Array.isArray(e.detail)&&(this.detail=e.detail)},e}(),pi=function(){function e(t){c(this,e),this.id=0,this.title="",this.details=null,this._update(t)}return h(e,[{key:"update",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){if(s)t(s,null);else{var r={text:e.data};U.get(n._iid).container.apiClient.updatePoll(l(l({pollId:n.id},e),{},{data:r}),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}}),t)}},{key:"delete",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=C(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.deletePoll({pollId:t.id},(function(t,n){e(t||null,null)}))}),e)}},{key:"addOption",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"string"}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.addPollOption({channelUrl:e,pollId:r.id,text:t},(function(e,t){if(e)n(e,null);else{var i=new(0,x.get(r._iid).Poll)(t);n(null,i)}}))}),n)}},{key:"vote",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"array",constraint:function(e){return e.every((function(e){return"number"==typeof e}))}}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.votePoll({channelUrl:e,pollId:r.id,optionIds:t},(function(e,t){if(e)n(e,null);else{var i=new(0,x.get(r._iid).Poll)(t);n(null,i)}}))}),n)}},{key:"close",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=C(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.closePoll({pollId:t.id},(function(n,r){if(n)e(n,null);else{var i=new(0,x.get(t._iid).Poll)(r);e(null,i)}}))}),e)}},{key:"_update",value:function(e){var t=x.get(this._iid).PollDetails;this.id=parseInt(e.id),this.title=e.title,e.hasOwnProperty("options")&&e.hasOwnProperty("is_anonymous")&&e.hasOwnProperty("allow_user_suggestion")&&e.hasOwnProperty("allow_multiple_votes")&&e.hasOwnProperty("close_at")&&e.hasOwnProperty("voter_count")&&e.hasOwnProperty("status")&&e.hasOwnProperty("created_by")&&e.hasOwnProperty("created_at")&&e.hasOwnProperty("updated_at")&&(this.details=new t(e))}}],[{key:"Status",get:function(){return{OPEN:"open",CLOSED:"closed",REMOVED:"removed"}}},{key:"objectify",value:function(e){var t=x.get(this._iid).PollDetails,n=e.id,r=void 0===n?0:n,i=e.title,s=void 0===i?"":i,a=e.details,o=void 0===a?null:a,u=l({},o?t.objectify(o):{});return u.id=r,u.title=s,u}},{key:"get",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollRetrievalParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.getPoll(l({},e),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}),t)}},{key:"create",value:function(e,t){var n=this,r=x.get(this._iid),i=r.PollParams,s=null,a=tt.parse(arguments,[new tt({type:i,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){if(s)t(s,null);else{var r={text:e.data};U.get(n._iid).container.apiClient.createPoll(l(l({},e),{},{data:r}),(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}}),t)}}]),e}(),fi=function(){function e(t){c(this,e),this.options=[],this.data=null,this.isAnonymous=!1,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.closeAt=-1,this.voterCount=0,this.votedOptionIds=[],this.status="",this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._update(t)}return h(e,[{key:"_update",value:function(e){var t=x.get(this._iid).PollOption;e.hasOwnProperty("options")&&Array.isArray(e.options)&&(this.options=e.options.map((function(e){return new t(e)})));try{this.data=JSON.parse(e.data)}catch(t){this.data=e.data}this.isAnonymous=!!e.hasOwnProperty("is_anonymous")&&e.is_anonymous,this.allowUserSuggestion=!!e.hasOwnProperty("allow_user_suggestion")&&e.allow_user_suggestion,this.allowMultipleVotes=!!e.hasOwnProperty("allow_multiple_votes")&&e.allow_multiple_votes,this.closeAt=parseInt(e.close_at),this.voterCount=parseInt(e.voter_count),e.hasOwnProperty("voted_option_ids")&&Array.isArray(e.voted_option_ids)&&(this.votedOptionIds=e.voted_option_ids.map((function(e){return parseInt(e)}))),this.status=e.status,this.createdBy=e.created_by,this.createdAt=parseInt(e.created_at),this.updatedAt=parseInt(e.updated_at)}}],[{key:"objectify",value:function(e){var t=x.get(this._iid).PollOption,n=e.options,r=void 0===n?[]:n,i=e.data,s=void 0===i?null:i,a=e.isAnonymous,o=void 0!==a&&a,l=e.allowUserSuggestion,u=void 0!==l&&l,c=e.allowMultipleVotes,d=void 0!==c&&c,h=e.closeAt,p=void 0===h?-1:h,f=e.voterCount,_=void 0===f?0:f,g=e.votedOptionIds,y=void 0===g?[]:g,m=e.status,E=void 0===m?"":m,v=e.createdBy,b=void 0===v?"":v,C=e.createdAt,A=void 0===C?0:C,N=e.updatedAt,S=void 0===N?0:N,I={};return I.options=r.map((function(e){return t.objectify(e)})),I.data=JSON.stringify(s),I.is_anonymous=o,I.allow_user_suggestion=u,I.allow_multiple_votes=d,I.close_at=p,I.voter_count=_,I.voted_option_ids=y,I.status=E,I.created_by=b,I.created_at=A,I.updated_at=S,I}}]),e}(),_i=new WeakMap,gi=function(){function e(t){c(this,e),this.pollId=0,this.id=0,this.text="",this.voteCount=0,this.partialVoters=[],this.createdBy="",this.createdAt=0,this.updatedAt=0,_i.set(this,null),this._update(t)}return h(e,[{key:"lastVotedAt",get:function(){return _i.get(this)}},{key:"update",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updatePollOption({pollId:n.pollId,optionId:n.id,text:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Poll)(r);t(null,i)}}))}),t)}},{key:"delete",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=C(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.deletePollOption({pollId:t.pollId,optionId:t.id},(function(t,n){e(t||null,null)}))}),e)}},{key:"_applyEvent",value:function(e){return this.id===e.optionId&&this.lastVotedAt0&&void 0!==arguments[0]?arguments[0]:[];c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.userIds=t,this.metaDataKey="",this.metaDataValues=[],this._token=""}return h(e,[{key:"next",value:function(e){var t=this;return oe(this._iid,(function(e){"number"==typeof t.limit&&t.limit>0&&Array.isArray(t.userIds)&&"string"==typeof t.metaDataKey&&Array.isArray(t.metaDataValues)&&!!t.metaDataKey==t.metaDataValues.length>0?t.isLoading?e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null):t.hasNext?(t.isLoading=!0,U.get(t._iid).container.apiClient.loadUserList(l(l({},t),{},{userIdsFilter:t.userIds,metaDataKeyFilter:t.metaDataKey,metaDataValuesFilter:t.metaDataValues,token:t._token}),(function(n,r){var i=null;if(!n){var s=x.get(t._iid).User,a=String(r.next);t._token=a,t.hasNext=!!a,i=r.users.map((function(e){return new s(e)}))}t.isLoading=!1,e(n,i)}))):e(null,[]):e(tt.error,null)}),e)}}]),e}(),Ei=new WeakMap,vi=function(){function e(t){c(this,e),this.isLoading=!1,Ei.set(this,t)}return h(e,[{key:"prev",value:function(e,t,n,r){var i=arguments,s=this;return oe(this._iid,(function(r){var a,o=x.get(s._iid).BaseChannel,l=C(tt.parse(i,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"function"})]),5);if(a=l[0],e=l[1],t=l[2],n=l[3],r=l[4],a)r(a,null);else if(s.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var u=Ei.get(s);U.get(s._iid).container.apiClient.getMessageList({channelUrl:u.url,channelType:u.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:t,nextResultSize:0,shouldReverse:n,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return o.buildMessage(e,u)}));s.isLoading=!1,r(null,t)})).catch((function(e){s.isLoading=!1,r(e,null)}))}}),r)}},{key:"next",value:function(e,t,n,r){var i=arguments,s=this;return oe(this._iid,(function(r){var a,o=x.get(s._iid).BaseChannel,l=C(tt.parse(i,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"function"})]),5);if(a=l[0],e=l[1],t=l[2],n=l[3],r=l[4],a)r(a,null);else if(s.isLoading)r(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{s.isLoading=!0;var u=Ei.get(s);U.get(s._iid).container.apiClient.getMessageList({channelUrl:u.url,channelType:u.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:0,nextResultSize:t,shouldReverse:n,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return o.buildMessage(e,u)}));s.isLoading=!1,r(null,t)})).catch((function(e){s.isLoading=!1,r(e,null)}))}}),r)}},{key:"load",value:function(e,t,n,r,i){var s=arguments,a=this;return oe(this._iid,(function(i){var o,l=x.get(a._iid).BaseChannel,u=C(tt.parse(s,[new tt({type:"number"}),new tt({type:"number"}),new tt({type:"number"}),new tt({type:"boolean"}),new tt({type:"callback"})]),6);if(o=u[0],e=u[1],t=u[2],n=u[3],r=u[4],i=u[5],o)i(o,null);else if(a.isLoading)i(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else{a.isLoading=!0;var c=Ei.get(a);U.get(a._iid).container.apiClient.getMessageList({channelUrl:c.url,channelType:c.channelType,token:e,tokenType:"timestamp",isInclusive:!1,prevResultSize:t,nextResultSize:n,shouldReverse:r,messageType:"",customType:""}).then((function(e){var t=e.messages.map((function(e){return l.buildMessage(e,c)}));a.isLoading=!1,i(null,t)})).catch((function(e){a.isLoading=!1,i(e,null)}))}}),i)}}]),e}(),bi=0,Ci=1,Ai=2,Ni=function(){function e(t){var n=this;c(this,e),this.state=bi,this._value=null,this._reason=null;if("function"!=typeof t)throw"Promise resolver ".concat(t," is not a function");t((function(e){n.state===bi&&(n.state=Ci,n._value=e)}),(function(e){n.state===bi&&(n.state=Ai,n._reason=e)}))}return h(e,[{key:"length",get:function(){return 1}},{key:"then",value:function(t,n){var r=this,i=this;switch(this.state){case bi:setTimeout((function(){return r.then(t,n)}),100);break;case Ci:t&&"function"==typeof t&&(i=t(this._value));break;case Ai:n&&"function"==typeof n&&(i=n(this._reason))}return i instanceof e?i:this}},{key:"catch",value:function(t){var n=this,r=this;switch(this.state){case bi:setTimeout((function(){return n.catch(t)}),100);break;case Ci:break;case Ai:r=t(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(t){var n=this,r=this;switch(this.state){case bi:setTimeout((function(){return n.finally(t)}),100);break;case Ci:case Ai:r=t()}return r instanceof e?r:this}}],[{key:"all",value:function(t){return new e((function(n,r){if(Array.isArray(t)||"string"==typeof t)if(t.length>0){for(var i=[],s=0;s0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),Si();var r=!1;if((n.newInstance||!Ti||Ti&&n.appId!==Ti.getApplicationId()&&Ti.getConnectionState()===Ti.ConnectionState.CLOSED)&&(r=!0,Ti=this),r){try{if(!n.hasOwnProperty("appId"))return J.warn("Must be set appId."),Ti=null,null}catch(e){return J.warn("Must be set appId."),Ti=null,null}var i=jn.create();Object.defineProperty(this,"_iid",{get:function(){return i}}),Oi[i]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new nt(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:kt.MessageTypeFilter},this.GroupChannelFilter=Bn,this.MessageFilter=He,this.GroupChannelCollection={GroupChannelOrder:ze},this.MessageCollection={MessageCollectionInitPolicy:Me},this.CollectionEventSource=Ce,this._currentUserId=null;var s={User:It,Member:Xn,RestrictedUser:$n,GroupChannel:Jn,OpenChannel:ar,UserMessage:pr,FileMessage:yr,AdminMessage:mr,GroupChannelListQuery:Tr,MemberListQuery:Or,GroupChannelParams:Yr,OpenChannelParams:Qr,BaseMessageParams:dr,UserMessageParams:hr,FileMessageParams:gr,ScheduledUserMessageParams:Wr,GroupChannelTotalUnreadMessageCountParams:Jr,MessageRetrievalParams:Xr,MessageListParams:Zr,ThreadedMessageListParams:$r,MessageChangeLogsParams:ei,GroupChannelChangeLogsParams:ti,PollParams:ni,PollRetrievalParams:ri,MessageMetaArray:ur,UserEventHandler:si,SessionHandler:rt,ChannelHandler:ai,ConnectionHandler:ii,AppleCriticalAlertOptions:lr,Poll:pi,PollOption:gi},a={SessionManager:it,BaseChannel:kt,BaseMessage:St,UserListQuery:mi,ApplicationUserListQuery:Ar,BannedUserListQuery:Nr,BlockedUserListQuery:Sr,FriendListQuery:Ir,MutedUserListQuery:Ur,OpenChannelListQuery:kr,OperatorListQuery:Mr,ParticipantListQuery:Lr,MessageListQuery:vi,PreviousMessageListQuery:Gr,MessageSearchQuery:Dr,PublicGroupChannelListQuery:xr,PollListQuery:Vr,PollVoterListQuery:zr,ScheduledUserMessage:Er,ThreadInfo:ui,ThreadInfoUpdateEvent:vr,OGMetaData:ci,OGImage:di,Plugin:hi,Command:ot,Sender:Zn,ReadStatus:oi,Reaction:li,ReactionEvent:vt,Emoji:nr,EmojiCategory:tr,EmojiContainer:er,PollDetails:fi,PollUpdateEvent:br,PollVoteEvent:Cr,RestrictionInfo:yi,FileMessageQueue:Ht},o=new x(this._iid,l(l({},s),a));this.BaseMessage={ReplyType:St.ReplyType,getMessage:o.BaseMessage.getMessage.bind(o.BaseMessage)},Object.keys(o).forEach((function(e){s[e]&&(t[e]=o[e])}));var u={encrypt:function(e){return e},decrypt:function(e){return e}};U.create(i,{appId:n.appId,pinger:new Z(this),apiClient:new ue(this),wsAdapter:new et(this),commandHandler:new Pt(this),onlineDetector:new st(this),ackStateMap:{},subscribedUnreadMessageCount:{all:0,custom_types:{},ts:0},maxUnreadCountOfSuperGroupChannel:T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,nestdb:null,currentUserId:null,localCacheEnabled:"boolean"==typeof n.localCacheEnabled&&n.localCacheEnabled,localCacheLock:new X,debugCache:!1,encryption:u,store:new kn({encryption:u}),preference:null,auth:new F,appInfo:null,pingInterval:15e3,pongTimeout:5e3,connectedAt:0,extensions:{},supportedExtensionKeys:["sb_uikit","sb_syncmanager"],getUserAgentWithExtensions:function(e){var t=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",n=e.sb_uikit?"u".concat(e.sb_uikit):"";return"JS/c".concat(T.SDK_VERSION,"/").concat(t,"/").concat(n)},sessionManager:new o.SessionManager(this),stateChangeEnabled:!0,isInBackground:!1,closedByGoingBackground:!1,isErrorFirstInCallback:!1,autoResendQueue:[],isProcessingAutoResend:!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<=Ii&&(this._websocketResponseTimeout=e)},includePollDetails:!1};var d=pe.of(i);d.addObserver({onConnect:function(){t.isCacheEnabled&&!t.getIsProcessingAutoResend()&&(0===t.getAutoResendQueue().length?Xe._processPendingMessages(t).then((function(){Xe._processNextAutoResend(t)})):Xe._processNextAutoResend(t))},onDisconnect:function(){}})}return Ti}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 U.get(this._iid).container.appInfo}},{key:"isCacheEnabled",get:function(){return U.get(this._iid).container.localCacheEnabled}},{key:"ekey",get:function(){var e=U.get(this._iid).container.auth;return e?e.eKey:""}},{key:"getApplicationId",value:function(){return U.get(this._iid).get("appId")}},{key:"getCurrentUserId",value:function(){return this.currentUser?this.currentUser.userId:null}},{key:"getDebugMode",value:function(){return Ui}},{key:"setDebugMode",value:function(e){Ui=e,J.mode=e?J.Mode.DEBUG:J.Mode.PRODUCTION}},{key:"getErrorFirstCallback",value:function(){return U.get(this._iid).container.isErrorFirstInCallback}},{key:"setErrorFirstCallback",value:function(e){"boolean"==typeof e&&U.get(this._iid).set("isErrorFirstInCallback",e)}},{key:"getAutoResendQueue",value:function(){return U.get(this._iid).container.autoResendQueue}},{key:"getIsProcessingAutoResend",value:function(){return U.get(this._iid).container.isProcessingAutoResend}},{key:"setIsProcessingAutoResend",value:function(e){U.get(this._iid).set("isProcessingAutoResend",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=U.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=U.get(this._iid);return this.currentUser&&e.get("auth").hasSession()}},{key:"getLastConnectedAt",value:function(){var e=U.get(this._iid);return this.getConnectionState()===this.ConnectionState.OPEN&&this.currentUser?e.get("connectedAt"):0}},{key:"getMemoryStoreForDebugging",value:function(){var e=U.get(this._iid);return e.container.debugCache&&e.container.store instanceof Nn?e.container.store:null}},{key:"useMemoryAsDatabaseForDebugging",value:function(){var e=U.get(this._iid);e.container.debugCache=!0,e.container.store=new Nn}},{key:"useAsyncStorageAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Rn({AsyncStorage:e,encryption:t.container.encryption})}},{key:"initializeDatabase",value:function(e,t){var n=this,r=U.get(this._iid),i=r.container,s=i.appId,a=i.nestdb,o=i.store,l=i.localCacheEnabled;return oe(this._iid,(function(t){if(l)if(a)t(null);else{var i=r.container.nestdb=new xn({name:"sendbird=".concat(s,"-").concat(e,".db"),version:1,store:o});i.on("upgrade",(function(e,t){switch(e){case 0:i.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[_e.NAME_ALPHABETICAL,_e.CHRONOLOGICAL,_e.LATEST_LAST_MESSAGE]},{collectionName:"SucceededMessage",keyName:"messageId",keyHash:function(e,t){return Math.floor(parseInt(e)/t)},index:[ge.LATEST]},{collectionName:"UnsentMessage",keyName:"reqId",index:[ge.LATEST_UNSENT]}]).then((function(){return t()})).catch((function(e){throw e}));break;default:t()}})),i.on("error",(function(e){J.error("Database initialize failed with an error: ",e),t(e)})),i.on("success",(function(){r.container.currentUserId=e,new Et({iid:n._iid,collection:i.collection("GroupChannel")}),new Ae({iid:n._iid,collections:{succeeded:i.collection("SucceededMessage"),unsent:i.collection("UnsentMessage")}}),J.debug("Database initialize succeeded."),t(null)})),i.open()}else r.container.currentUserId=e,new Et({iid:n._iid,collection:null}),new Ae({iid:n._iid,collections:{succeeded:null,unsent:null}}),t(null)}),t)}},{key:"clearDatabase",value:function(e){var t=U.get(this._iid),n=t.container.nestdb;return oe(this._iid,(function(e){if(n){var r=null;n.close(),n.reset().then((function(){J.debug("Database clear succeeded."),t.container.nestdb=null})).catch((function(e){J.error("Database clear failed with an error: ",e),r=e})).finally((function(){return e(r)}))}else e(null)}),e)}},{key:"connect",value:function(e,t,n,r,i){var s=this,a=U.get(this._iid),o=a.container,l=o.wsAdapter,u=o.onlineDetector,c=o.localCacheEnabled;a.remove("firstConnectedAt"),u&&u.start();var d=null,h=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new tt({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new tt({type:"callback"})]),p=C(h,6);return d=p[0],e=p[1],t=p[2],n=p[3],r=p[4],i=p[5],oe(this._iid,(function(i){if(d)i(d,null);else if(s.customApiHost=n,s.customWsHost=r,s.connecting=!0,s.reconnecting=!1,s.isReconnectingOnError=!1,s.reconnectTimer&&(clearTimeout(s.reconnectTimer),s.reconnectTimer=null,s.onReconnectTimerCancel=null),s.getConnectionState()===s.ConnectionState.OPEN&&s.currentUser&&s.currentUser.userId===e)s.connecting=!1,i(null,s.currentUser);else if(c&&(s._currentUserId=e),s.connectionCallbacks.push(i),1===s.connectionCallbacks.length){l.disconnect({clearSession:!0,err:null},null);var o=a.container,u=o.nestdb,h=o.localCacheLock;u?l.connect(e,t):h.lock((function(n){s.initializeDatabase(e).then((function(){n(),l.connect(e,t)})).catch((function(e){a.container.localCacheEnabled=!1,n(),i(e,null)}))}))}}),i)}},{key:"reconnect",value:function(){var e=this,t=U.get(this._iid).container,n=t.wsAdapter,r=t.auth,i=t.localCacheLock;if(r.sessionKey&&this.currentUser){var s=!0;return n.reconnectCount>0&&(s=!1),i.lock((function(t){n.disconnect({clearSession:!1,err:new H("Connection has been canceled.",H.CONNECTION_CANCELED)},null),n.reconnectCount=0,n.reconnect(e.currentUser.userId,s),t()})),!0}return!1}},{key:"disconnect",value:function(e){var t=this;return oe(this._iid,(function(e){var n=U.get(t._iid).container,r=n.localCacheLock,i=n.wsAdapter,s=n.onlineDetector;s&&s.stop(),r.lock((function(n){i.disconnect({clearSession:!0,err:new H("Connection has been canceled.",H.CONNECTION_CANCELED)},(function(){t.clearDatabase((function(){n(),e(null)}))}))}))}),e)}},{key:"setBackgroundState",value:function(){var e=U.get(this._iid),t=e.container,n=t.wsAdapter,r=t.stateChangeEnabled;!t.isInBackground&&r&&(e.set("isInBackground",!0),this.getConnectionState()!==this.ConnectionState.CLOSED?(e.set("closedByGoingBackground",!0),n.disconnect({clearSession:!1,err:new H("Websocket connection failed.",H.WEBSOCKET_CONNECTION_FAILED)},null),pe.of(this._iid).invokeDisconnect()):e.set("closedByGoingBackground",!1))}},{key:"isInBackground",get:function(){return U.get(this._iid).container.isInBackground}},{key:"setForegroundState",value:function(){var e=U.get(this._iid),t=e.container,n=t.wsAdapter,r=t.stateChangeEnabled,i=t.isInBackground,s=t.closedByGoingBackground;i&&r&&(e.set("isInBackground",!1),s&&this.currentUser&&n.reconnect(this.currentUser.userId,!0))}},{key:"enableStateChange",value:function(){U.get(this._iid).set("enableStateChange",!0)}},{key:"disableStateChange",value:function(){U.get(this._iid).set("enableStateChange",!1)}},{key:"addExtension",value:function(e,t){var n=U.get(this._iid).container,r=n.extensions;n.supportedExtensionKeys.indexOf(e)>-1&&(r[e]=t)}},{key:"createUserListQuery",value:function(e){return new(0,x.get(this._iid).UserListQuery)(e)}},{key:"createApplicationUserListQuery",value:function(){return new(0,x.get(this._iid).ApplicationUserListQuery)}},{key:"createBlockedUserListQuery",value:function(){return new(0,x.get(this._iid).BlockedUserListQuery)}},{key:"createFriendListQuery",value:function(){return new(0,x.get(this._iid).FriendListQuery)}},{key:"createMessageSearchQuery",value:function(e,t){return new(0,x.get(this._iid).MessageSearchQuery)(e,t)}},{key:"sendCommand",value:function(e,t){var n=this;return oe(this._iid,(function(t){n.ConnectionManager.ready((function(r,i){if(r)t(r,null);else{var s=U.get(n._iid).container,a=s.wsAdapter,o=s.ackStateMap;if(null==a||null==a.client||a.client.getConnectionState()!==n.ConnectionState.OPEN||n.getConnectionState()!==n.ConnectionState.OPEN)return void t(new H("Connection is not valid. Please reconnect.",H.WEBSOCKET_CONNECTION_CLOSED),null);if(e.isAckRequired){var l=e.requestId,u={handler:t,timer:setTimeout((function(){t(new H("Command received no ack.",H.ACK_TIMEOUT),null),delete o[l]}),n.Options.websocketResponseTimeout)};o[l]=u,a.client.send(e,(function(e){e&&(clearTimeout(u.timer),t(e,null))}))}else a.client.send(e,t)}}),!1)}),t).catch((function(e){J.error(e)}))}},{key:"setSessionHandler",value:function(e){U.get(this._iid).container.sessionManager.setHandler(e)}},{key:"addUserEventHandler",value:function(e,t){t instanceof x.get(this._iid).UserEventHandler&&(this.userEventHandlers[e]=t)}},{key:"removeUserEventHandler",value:function(e){delete this.userEventHandlers[e]}},{key:"removeAllUserEventHandler",value:function(){this.userEventHandlers={}}},{key:"addChannelHandler",value:function(e,t){t instanceof x.get(this._iid).ChannelHandler&&(this.channelHandlers[e]=t)}},{key:"removeChannelHandler",value:function(e){delete this.channelHandlers[e]}},{key:"removeAllChannelHandlers",value:function(){this.channelHandlers={}}},{key:"addConnectionHandler",value:function(e,t){t instanceof x.get(this._iid).ConnectionHandler&&(this.connectionHandlers[e]=t)}},{key:"removeConnectionHandler",value:function(e){delete this.connectionHandlers[e]}},{key:"removeAllConnectionHandlers",value:function(){this.connectionHandlers={}}},{key:"updateCurrentUserInfo",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"string",nullable:!0}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:t},(function(i,s){var a=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),t&&(r.currentUser.plainProfileUrl=t)),a=r.currentUser),n(i,a)}))}),n)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"file",nullable:!0}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:t},(function(t,i){var s=null;t||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url)),s=r.currentUser),n(t,s)}))}),n)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.updateCurrentUserInfo({preferredLanguages:e},(function(r,i){var s=null;r||(n.currentUser&&e&&(n.currentUser._preferredLanguages=e),s=n.currentUser),t(r,s)}))}),t)}},{key:"registerGCMPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,n.pushTokenRegistrationState.ERROR):n.currentUser?U.get(n._iid).container.apiClient.registerGCMPushToken({token:e},(function(e,r){var i=n.pushTokenRegistrationState.ERROR;e||(n.GCMPushToken="",i=n.pushTokenRegistrationState.SUCCESS),t(e,i)})):(n.GCMPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterGCMPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):n.currentUser?U.get(n._iid).container.apiClient.unregisterGCMPushToken({token:e},(function(e,n){t(e,null)})):(n.GCMPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterGCMPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllGCMPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"registerAPNSPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,n.pushTokenRegistrationState.ERROR):n.currentUser?U.get(n._iid).container.apiClient.registerAPNSPushToken({token:e},(function(e,r){var i=n.pushTokenRegistrationState.ERROR;e||(n.APNSPushToken="",i=n.pushTokenRegistrationState.SUCCESS),t(e,i)})):(n.APNSPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e.length>0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):n.currentUser?U.get(n._iid).container.apiClient.unregisterAPNSPushToken({token:e},(function(e,n){t(e,null)})):(n.APNSPushToken=e,t(null,n.pushTokenRegistrationState.PENDING))}),t)}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllAPNSPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"unregisterPushTokenAllForCurrentUser",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.unregisterAllPushTokens({},(function(t,n){e(t,null)}))}),e)}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:"array",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new tt({type:"callback"})]),o=C(a,5);s=o[0],e=o[1],t=o[2],n=o[3],r=o[4];var u=x.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(s){var h=tt.parse(arguments,[new tt({type:"string",nullable:!0}),new tt({type:c,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),p=C(h,4);s=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=t,d.includeEmpty=n,d.includeFrozen=!0;return oe(this._iid,(function(t){s?t(s,null):U.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:null,token:e},d)).then((function(e){var n=x.get(i._iid).GroupChannel,r=e.updated.map((function(e){return new n(e)})),s=e.deleted,a=e.has_more,o=e.next;t(null,{updatedChannels:r,deletedChannelUrls:s,hasMore:a,token:o})})).catch((function(e){t(e,null)}))}),r)}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"array",optional:!0,nullable:!0,defaultValue:null}),new tt({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new tt({type:"callback"})]),o=C(a,5);s=o[0],e=o[1],t=o[2],n=o[3],r=o[4];var u=x.get(this._iid),c=u.GroupChannelChangeLogsParams,d=null;if(s){var h=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:c,constraint:function(e){return e._validate()}}),new tt({type:"callback"})]),p=C(h,4);s=p[0],e=p[1],d=p[2],r=p[3]}else(d=new c).customTypes=t,d.includeEmpty=n,d.includeFrozen=!0;return oe(this._iid,(function(t){s?t(s,null):U.get(i._iid).container.apiClient.getMyGroupChannelChangeLogs(l({ts:e,token:null},d)).then((function(e){var n=x.get(i._iid).GroupChannel,r=e.updated.map((function(e){return new n(e)})),s=e.deleted,a=e.has_more,o=e.next;t(null,{updatedChannels:r,deletedChannelUrls:s,hasMore:a,token:o})})).catch((function(e){t(e,null)}))}),r)}},{key:"getChannelInvitationPreference",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getChannelInvitationPreference({},(function(t,n){var r=null;t||(r={autoAccept:n.auto_accept}),e(t,r)}))}),e)}},{key:"setChannelInvitationPreference",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.setChannelInvitationPreference({isAutoAccept:e},(function(e,n){var r=null;e||(r={autoAccept:n.auto_accept}),t(e,r)}))}),t)}},{key:"getDoNotDisturb",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getDoNotDisturb({},(function(t,n){var r=null;t||(r={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone}),e(t,r)}))}),e)}},{key:"setDoNotDisturb",value:function(e,t,n,r,i,s,a){var o=this,l=null,u=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new tt({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new tt({type:"string"}),new tt({type:"callback"})]),c=C(u,8);return l=c[0],e=c[1],t=c[2],n=c[3],r=c[4],i=c[5],s=c[6],a=c[7],oe(this._iid,(function(a){l?a(l,null):U.get(o._iid).container.apiClient.setDoNotDisturb({doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s},(function(e,t){var n=null;e||(n={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}),a(e,n)}))}),a)}},{key:"getSnoozePeriod",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getSnoozePeriod({},(function(t,n){var r=null;t||(r={isSnoozeOn:n.snooze_enabled,startTs:n.snooze_start_ts,endTs:n.snooze_end_ts}),e(t,r)}))}),e)}},{key:"setSnoozePeriod",value:function(e,t,n,r){var i=this,s=null,a=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"number",constraint:function(e){return e>0}}),new tt({type:"number",constraint:function(e){return e>0}}),new tt({type:"callback"})]),o=C(a,5);return s=o[0],e=o[1],t=o[2],n=o[3],r=o[4],oe(this._iid,(function(r){s?r(s,null):U.get(i._iid).container.apiClient.setSnoozePeriod({snoozeOn:e,startTs:t,endTs:n},(function(e,t){var n=null;e||(n={isSnoozeOn:t.snooze_enabled,startTs:t.snooze_start_ts,endTs:t.snooze_end_ts}),r(e,n)}))}),r)}},{key:"blockUser",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new tt({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.blockUserWithUserId(e.userId,t)}},{key:"blockUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.blockUser({blockedUserId:e},(function(e,n){var r=null;e||(r=new It(n)),t(e,r)}))}),t)}},{key:"unblockUser",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new tt({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.unblockUserWithUserId(e.userId,t)}},{key:"unblockUserWithUserId",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.unblockUser({unblockedUserId:e},(function(e,n){t(e,null)}))}),t)}},{key:"getPushTriggerOption",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getPushTriggerOption({},(function(t,n){e(t,n?n.push_trigger_option:null)}))}),e)}},{key:"setPushTriggerOption",value:function(e,t){var n=this;return oe(this._iid,(function(t){Object.keys(n.PushTriggerOption).map((function(e){return n.PushTriggerOption[e]})).indexOf(e)>-1?U.get(n._iid).container.apiClient.setPushTriggerOption({pushTriggerOption:e},(function(e,n){t(e,n?n.push_trigger_option:null)})):t(tt.error,null)}),t)}},{key:"getGroupChannelCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=tt.parse(arguments,[new tt({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new tt({type:"callback"})]),o=C(a,3);return s=o[0],e=o[1],t=o[2],oe(this._iid,(function(t){s?t(s,null):U.get(n._iid).container.apiClient.getGroupChannelCount({memberStateFilter:e},(function(e,n){var r=null;e||(r=parseInt(n.group_channel_count)),t(e,r)}))}),t)}},{key:"getTotalUnreadChannelCount",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getTotalUnreadChannelCount({},(function(t,n){var r=null;t||(r=parseInt(n.unread_count)),e(t,r)}))}),e)}},{key:"getTotalUnreadMessageCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadMessageCountParams,a=null,o=tt.parse(arguments,[new tt({type:"object",optional:!0,defaultValue:null,constraint:function(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))||e instanceof s}}),new tt({type:"callback"})]),l=C(o,3);return a=l[0],e=l[1],t=l[2],oe(this._iid,(function(t){if(a)t(a,null);else{var r=i.SuperChannelFilter.ALL;if(e instanceof s){var o=e;e=o.channelCustomTypesFilter,r=o.superChannelFilter}U.get(n._iid).container.apiClient.getTotalUnreadMessageCount({customTypesFilter:e,superChannelFilter:r},(function(e,n){var r=null;e||(r=parseInt(n.unread_count)),t(e,r)}))}}),t)}},{key:"getUnreadItemCount",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.length>0&&e.every((function(e){return Object.keys(Jn.UnreadItemKey).map((function(e){return Jn.UnreadItemKey[e]})).indexOf(e)>-1}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){if(r)t(r,null);else{var i=e.filter((function(t,n){return e.indexOf(t)===n}));U.get(n._iid).container.apiClient.getUnreadItemCount({keys:i},(function(e,n){t(e,n)}))}}),t)}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=U.get(this._iid).container.subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=U.get(this._iid).container.subscribedUnreadMessageCount;if(Object.keys(e.custom_types).length>0){var t=0;return Object.keys(e.custom_types).forEach((function(n){t+=e.custom_types[n]})),t}return 0}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){if(e&&"string"==typeof e){var t=U.get(this._iid).container.subscribedUnreadMessageCount;return t.custom_types.hasOwnProperty(e)?t.custom_types[e]:0}return 0}},{key:"getMyPushTokensByToken",value:function(e,t,n){var r=this,i=null,s=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new tt({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){i?n(i,null):U.get(r._iid).container.apiClient.getPushTokens({ts:null,token:e,type:t},(function(e,t){if(e)n(e,null);else{var r=t.type;n(null,{deviceTokens:t.device_tokens,type:r?r.toLowerCase():"unknown",hasMore:t.has_more,token:t.token})}}))}),n)}},{key:"getPushTemplate",value:function(e){var t=this;return oe(this._iid,(function(e){U.get(t._iid).container.apiClient.getPushTemplate({},(function(t,n){var r=null;t||(r=n.name.toString()),e(t,r)}))}),e)}},{key:"setPushTemplate",value:function(e,t){var n=this;return oe(this._iid,(function(t){[n.PUSH_TEMPLATE_DEFAULT,n.PUSH_TEMPLATE_ALTERNATIVE].indexOf(e)>-1?U.get(n._iid).container.apiClient.setPushTemplate({templateName:e},(function(e,n){var r=null;e||(r=n.name.toString()),t(e,r)})):t(tt.error,null)}),t)}},{key:"markAsReadAll",value:function(e){var t=this;return oe(this._iid,(function(e){var n=x.get(t._iid).GroupChannel,r=(new Date).getTime();r-n.markAsReadAllLastSentAt<1e3?e(new H("MarkAsRead rate limit exceeded.",H.MARK_AS_READ_RATE_LIMIT_EXCEEDED),null):(n.markAsReadAllLastSentAt=r,U.get(t._iid).container.apiClient.markAsReadAll({channelUrls:null},(function(i,s){i||Object.keys(n.cachedChannels).forEach((function(e){t.currentUser&&n.cachedChannels[e].updateReadReceipt(t.currentUser.userId,r),n.cachedChannels[e]._setGroupChannelUnreadCount(0,0)})),e(i,null)})))}),e)}},{key:"markAsReadWithChannelUrls",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){if(r)t(r,null);else{var i=(new Date).getTime();U.get(n._iid).container.apiClient.markAsReadAll({channelUrls:e},(function(r,s){r||e.forEach((function(e){Jn.cachedChannels[e]&&(n.currentUser&&Jn.cachedChannels[e].updateReadReceipt(n.currentUser.userId,i),Jn.cachedChannels[e]._setGroupChannelUnreadCount(0,0))})),t(r,null)}))}}),t)}},{key:"markAsDelivered",value:function(e){"string"==typeof e&&x.get(this._iid).GroupChannel.getChannel(e,T.INTERNAL_CALL,(function(e,t){e||t.markAsDelivered()}))}},{key:"getFriendChangeLogsByToken",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string",optional:!0,defaultValue:null}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getFriendChangeLogsByToken({token:e},(function(e,r){var i=null;if(!e){var s=x.get(n._iid).User;i={updatedUsers:r.updated.map((function(e){return new s(e)})),deletedUserIds:r.deleted,hasMore:r.has_more,token:r.next}}t(e,i)}))}),t)}},{key:"uploadFriendDiscoveries",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.uploadFriendDiscoveries({discoveries:e},(function(e,n){t(e,n)}))}),t)}},{key:"deleteFriendDiscovery",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.deleteFriendDiscoveries([e],t)}},{key:"deleteFriendDiscoveries",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteFriendDiscoveries({discoveryKeys:e},(function(e,n){t(e,n)}))}),t)}},{key:"addFriends",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.addFriends({userIds:e},(function(e,r){var i=null;if(!e){var s=x.get(n._iid).User;i=r.users.map((function(e){return new s(e)}))}t(e,i)}))}),t)}},{key:"deleteFriend",value:function(e,t){var n=null,r=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){e(n,null)}),t):this.deleteFriends([e],t)}},{key:"deleteFriends",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.deleteFriends({userIds:e},(function(e,n){t(e,n)}))}),t)}},{key:"getAllEmoji",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=C(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.getAllEmoji((function(n,r){if(n)e(n,null);else{var i=new(0,x.get(t._iid).EmojiContainer)(r);e(null,i)}}))}),e)}},{key:"getEmojiCategory",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"number",constraint:function(e){return e>=0}}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getEmojiCategory({categoryId:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).EmojiCategory)(r);t(null,i)}}))}),t)}},{key:"getEmoji",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"string"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.getEmoji({emojiKey:e},(function(e,r){if(e)t(e,null);else{var i=new(0,x.get(n._iid).Emoji)(r);t(null,i)}}))}),t)}},{key:"getAllowFriendDiscovery",value:function(e){var t=this,n=null,r=tt.parse(arguments,[new tt({type:"callback"})]),i=C(r,2);return n=i[0],e=i[1],oe(this._iid,(function(e){n?e(n,null):U.get(t._iid).container.apiClient.getAllowFriendDiscovery((function(t,n){var r=n.allow_friend_discovery;t?e(t,null):e(null,r)}))}),e)}},{key:"setAllowFriendDiscovery",value:function(e,t){var n=this,r=null,i=tt.parse(arguments,[new tt({type:"boolean"}),new tt({type:"callback"})]),s=C(i,3);return r=s[0],e=s[1],t=s[2],oe(this._iid,(function(t){r?t(r,null):U.get(n._iid).container.apiClient.setAllowFriendDiscovery({allowFriendDiscovery:e},(function(n,r){n?t(n,null):t(null,e)}))}),t)}},{key:"clearCachedMessages",value:function(e){var t=Ae.of(this._iid);return t?Promise.all(e.map((function(e){return t.clearByChannelUrl(e)}))):Promise.resolve([])}},{key:"_getCurrentUserDataKey",value:function(){return"sendbird:".concat(this._currentUserId,"@currentUserData")}},{key:"_populateVaultFromCurrentUserData",value:function(e){var t=U.get(this._iid),n=t.container.auth,r=x.get(this._iid).User,i=e.currentUser,s=e.maxUnreadCountOfSuperGroupChannel,a=e.profileImageEncryption,o=e.sessionKey,l=e.eKey,u=e.appInfo,c=e.connectedAt,d=e.firstConnectedAt,h=e.concurrentCallLimit,p=e.backOffDelay;i&&(this.currentUser=r.buildFromSerializedData(i)),s&&t.set("maxUnreadCountOfSuperGroupChannel",s),a&&t.set("profileImageEncryption",a),n?(o&&(n.sessionKey=o),l&&(n.ekey=l)):J.debug("Auth should have been created when populating current user data."),u&&t.set("appInfo",new $e(u)),c&&t.set("connectedAt",c),d&&t.set("firstConnectedAt",d),h&&t.set("concurrentCallLimit",h),p&&t.set("backOffDelay",p)}}],[{key:"version",get:function(){return T.SDK_VERSION}},{key:"LogLevel",get:function(){return J.supportedLogLevels}},{key:"getInstance",value:function(e){return e?Oi[e]:Ti}},{key:"getLogLevel",value:function(){return J.logLevel}},{key:"setLogLevel",value:function(e){var t=Object.values(J.supportedLogLevels);if(t.includes(e))J.logLevel=e;else{J.logLevel=J.defaultLogLevel;var n=t.map((function(e){return"'".concat(e,"'")})).join(", ");J.warn("`logLevel` parameter should be one of","".concat(n,","),"not `'".concat(e,"'`."),"Set to default log level","`".concat(J.defaultLogLevel,"`."))}}}]),e}();return ki})); \ No newline at end of file diff --git a/bower.json b/bower.json index 3ce9006..90ea726 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.1.1", + "version": "3.1.2", "authors": [ "Sendbird " ], diff --git a/package.json b/package.json index d95ed3a..041450d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.1.1", + "version": "3.1.2", "description": "Sendbird JavaScript SDK", "main": "SendBird.min.js", "dependencies": {