From 241baf9d0dd8f0cec907fab49d2728fa61f173e4 Mon Sep 17 00:00:00 2001 From: danney Date: Fri, 23 Sep 2022 18:01:38 +0900 Subject: [PATCH] v3.1.27 --- CHANGELOG.md | 3 +++ README.md | 5 +++-- SendBird.d.ts | 2 +- SendBird.min.js | 4 ++-- bower.json | 2 +- package.json | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2e03fe..59a4f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## v3.1.27 (SEP 23, 2022) +- Fixed onMessageUpdate being called for the same message in View after checking HugeGap when connecting or reconnecting +- Fixed a bug in group channel changelogs ## v3.1.26 (SEP 7, 2022) - Fixed wrong includeMetaArray property happening during changelog sync ## v3.1.25 (AUG 31, 2022) diff --git a/README.md b/README.md index d321dc9..0c1bbe4 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,8 @@ Additionally, migration guide for clients currently using SyncManager will be av ## Changelogs -## v3.1.26 (SEP 7, 2022) -- Fixed wrong includeMetaArray property happening during changelog sync +## v3.1.27 (SEP 23, 2022) +- Fixed onMessageUpdate being called for the same message in View after checking HugeGap when connecting or reconnecting +- Fixed a bug in group channel changelogs 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). diff --git a/SendBird.d.ts b/SendBird.d.ts index 2ffd9e8..811e795 100644 --- a/SendBird.d.ts +++ b/SendBird.d.ts @@ -1,5 +1,5 @@ /** - * Type Definitions for Sendbird SDK v3.1.26 + * Type Definitions for Sendbird SDK v3.1.27 * homepage: https://sendbird.com/ * git: https://github.com/sendbird/Sendbird-SDK-JavaScript */ diff --git a/SendBird.min.js b/SendBird.min.js index 8c6d92f..83a1453 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.26 + * Sendbird JavaScript SDK v3.1.27 */ -!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.26"},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=ji.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])},k(e,t)};function M(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 R=function(){return R=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&&(q=t)}},{key:"supportedLogLevels",get:function(){return K}},{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))};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(D||(D={}));var te=function(){function e(){}var t;return e.isFileLikeObject=function(e){return"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},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"undefined"!=typeof window&&"File"in window&&"undefined"!=typeof File&&e instanceof File},e.isBlob=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},e.isFileTypeBlob=function(e){return e===D.BLOB||e===D.FILE},e.convertBlobToBuffer=function(n){return L(void 0,void 0,void 0,(function(){var r;return P(t,(function(t){switch(t.label){case 0:return[4,e.convertFileToArrayBuffer(n)];case 1:return r=t.sent(),[2,Buffer.from(r)]}}))}))},e}(),ne=[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],re=[H.SESSION_TOKEN_EXPIRED,H.SESSION_TOKEN_REVOKED,H.USER_DEACTIVATED,H.NON_EXISTING_USER],ie=[H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED],se=function(){function e(){}return e.deepEqual=function(e,t){if(e!==t){var n=R({},e),r=R({},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&&ne.indexOf(e)>=0},e.isAutoResendableError=function(e){return e>0&&ie.indexOf(e)>=0},e.isNonAutoReconnectableError=function(e){return e>0&&re.indexOf(e)>=0},e.isFile=function(e){var t=te.isFileLikeObject(e);return t||(ee()?"undefined"!=typeof Buffer&&e instanceof Buffer:"undefined"!=typeof Blob?e instanceof Blob:"undefined"!=typeof File&&e instanceof File)},e}(),ae=function(){function e(e){var t=this;this.fields={},e&&Object.keys(e).forEach((function(n){t.fields[n]={value:e[n]},se.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 L(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,l,u,c,d,h,p=this;return P(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,f=ji.getAppVersion(),_="JS,".concat(T.OS_VERSION,",").concat(T.SDK_VERSION,",").concat(c);return f&&(_+=",".concat(f)),o.SendBird=_,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(),e instanceof s.default&&$()&&(o["Content-Type"]="multipart/form-data"),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":case"DELETE":d=a._createQuery(u,o);break;case"POST":case"PUT":d=u}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={headers:l,validateStatus:a._validateStatus,onUploadProgress:function(e){n.upload.progressHandler&&n.upload.progressHandler(e,n.upload.reqId)}};if(o instanceof s.default){var f=null;"function"==typeof AbortController?(f=new AbortController,p.signal=f.signal):(f=i.default.CancelToken.source(),p.cancelToken=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,p);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.add("expiring_session",!0),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;case a.MemberStateFilter.LEFT:l="left";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,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_CHANNEL_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:"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),se.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),se.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.nicknameStartsWithFilter,d=t.nicknameExactMatchFilter,h=t.channelNameContainsFilter,p=t.channelUrlsFilter,f=t.customTypesFilter,_=t.customTypeStartsWithFilter,g=t.memberStateFilter,y=t.superChannelFilter,m=t.publicChannelFilter,E=t.unreadChannelFilter,v=t.metadataOrderKeyFilter,b=t.metadataKey,C=t.metadataValues,A=t.metadataValueStartsWith,N=t.hiddenChannelFilter,S=t.searchFilter,I=t.includeFrozen,T=t.includeMetaData;return oe(this.sb._iid,(function(t){r.sb.ConnectionManager.ready((function(n,O){if(n)t(n,null);else{var U=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(O.userId)),k=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:g});f&&f.length>0&&k.add("custom_types",f),u&&k.add("members_nickname_contains",u),c&&k.add("members_nickname_startswith",c),d&&k.add("members_nickname",d),h&&k.add("name_contains",h),S&&S.hasOwnProperty("search_query")&&S.hasOwnProperty("search_fields")&&(k.add("search_query",S.search_query),k.add("search_fields",S.search_fields)),l&&l.userIds&&l.userIds.length>0&&(l.includeMode?(k.add("members_include_in",l.userIds),k.add("query_type",l.queryType.toUpperCase())):k.add("members_exactly_in",l.userIds)),p&&p.length>0&&k.add("channel_urls",p),k.add("super_mode",y),k.add("public_mode",m),k.add("unread_filter",E),v&&k.add("metadata_order_key",v),b&&k.add("metadata_key",b),C&&C.length>0&&k.add("metadata_values",C),A&&k.add("metadata_value_startswith",A),_&&k.add("custom_type_startswith",_),N&&k.add("hidden_mode",N),"boolean"==typeof I&&k.add("show_frozen",I),"boolean"==typeof T&&k.add("show_metadata",T),r.get(U,k,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),se.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),se.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.mentionedMessageTemplate,f=t.pushNotificationDeliveryOption,_=t.rootMessageId,g=t.parentMessageId,y=t.appleCriticalAlertOptions,m=t.pollId,E=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,v){if(t)n(t,null);else{var b=r.cls.FileMessageParams,C=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),A=new ae({message_type:"MESG",user_id:v.userId,message:a,mention_type:d,mentioned_user_ids:[]});null!=o&&A.add("data",o),null!=l&&A.add("custom_type",l),u&&A.add("translation_target_langs",u),c&&c.length>0&&A.add("sorted_metaarray",c.map((function(e){return e.encode()}))),d===r.cls.BaseMessageParams.MentionType.CHANNEL?A.add("mentioned_user_ids",[]):Array.isArray(h)&&h.length>0&&A.add("mentioned_user_ids",h),p&&A.add("mentioned_message_template",p),f&&f!==b.PushNotificationDeliveryOption.DEFAULT&&A.add("push_option",f),_&&A.add("root_message_id",_),g&&A.add("parent_message_id",g),y&&A.add("apple_critical_alert_options",y.serialize()),"number"==typeof m?A.add("poll_id",m):null===m&&A.add("poll_id",-1),E&&A.add("reply_to_channel",E),r.post(C,A,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,c=ji.getAppVersion();this.wsHost=n;try{var d="/?p=JS"+"&pv=".concat(encodeURIComponent(T.OS_VERSION))+"&sv=".concat(encodeURIComponent(T.SDK_VERSION))+"&ai=".concat(encodeURIComponent(this.sb.getApplicationId()));if(c&&(d+="&av=".concat(encodeURIComponent(c))),a.sessionKey?d+="&key=".concat(encodeURIComponent(a.sessionKey)):d+="&user_id=".concat(encodeURIComponent(e),"&access_token=").concat(encodeURIComponent(t)),d+="&active=1",d+="&SB-User-Agent=".concat(encodeURIComponent(l(o))),d+="&Request-Sent-Timestamp=".concat((new Date).getTime().toString()),d+="&include_extra_data=".concat(encodeURIComponent(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"].join(","))),u.handler&&(d+="&expiring_session=1"),this.sb.Options.includePollDetails&&(d+="&include_poll_details=1"),d+="&use_local_cache=1",this.ws=new this.WebSocket(this.wsHost+d),!this.ws)return this.sb.isReconnectingOnError=!0,void this.handler.onError({message:"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 h=!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}();!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"}(de||(de={}));var fe,_e={},ge=function(){function e(){this._observers=[]}return e.of=function(t){return _e[t]||(_e[t]=new e),_e[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;t1&&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 with a number of retries.",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();se.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}(),me=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&&se.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){J.warn("`ConnectionManager` will be deprecated."),this.networkHandlers[e]=t}},{key:"removeNetworkHandler",value:function(e){J.warn("`ConnectionManager` will be deprecated."),delete this.networkHandlers[e]}},{key:"removeAllNetworkHandler",value:function(){J.warn("`ConnectionManager` will be deprecated."),this.networkHandlers={}}},{key:"authenticate",value:function(e){var t=this;if(J.warn("`ConnectionManager` will be deprecated."),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(me.error,null)}}))}else e(me.error,null)}}]),e}(),ve=function(){this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,t){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},be=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=ji.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=ji.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,expiring_session:1},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.mentionedMessageTemplate,u=e.translationTargetLanguages,c=e.pushNotificationDeliveryOption,d=e.appleCriticalAlertOptions,h=e.requestId,p=void 0===h?null:h,f=e.silent,_=void 0!==f&&f,g=e.rootMessageId,y=void 0===g?null:g,m=e.parentMessageId,E=void 0===m?null:m,v=e.pollId,b=e.isReplyToChannel,C=void 0!==b&&b,A=x.get(this._iid),N=A.UserMessageParams,S=A.BaseMessageParams,I={};return I.channel_url=t,I.message=n,I.data=r,s&&s.length>0&&(I.metaarray=s.map((function(e){return e.encode()}))),a&&(I.mention_type=a),I.mentioned_user_ids=[],a===S.MentionType.CHANNEL?I.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(I.mentioned_user_ids=o),l&&(I.mentioned_message_template=l),i&&(I.custom_type=i),u&&u.length>0&&(I.target_langs=u),c&&c!==N.PushNotificationDeliveryOption.DEFAULT&&(I.push_option=c),d&&(I.apple_critical_alert_options=d.serialize()),_&&(I.silent=_),y&&(I.root_message_id=y),E&&(I.parent_message_id=E),"number"==typeof v?I.poll_id=v:null===v&&(I.poll_id=-1),C&&(I.reply_to_channel=C),new this("MESG",I,p)}},{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.mentionedMessageTemplate,_=void 0===f?null:f,g=e.metaArrayParams,y=void 0===g?null:g,m=e.pollId,E=x.get(this._iid).BaseMessageParams,v={};return v.channel_url=t,v.msg_id=n,null!=s&&void 0!==s&&(v.message=s),null!=o&&void 0!==o&&(v.data=o),null!=u&&void 0!==u&&(v.custom_type=u),d&&(v.mention_type=d),d===E.MentionType.CHANNEL?v.mentioned_user_ids=[]:Array.isArray(p)&&p.length>=0&&(v.mentioned_user_ids=p),_&&(v.mentioned_message_template=_),y&&(v.metaarray=y),r&&(v.apple_critical_alert_options=r.serialize()),"number"==typeof m?v.poll_id=m:null===m&&(v.poll_id=-1),new this("MEDI",v)}},{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 Ae++,String(Ae)}}]),e}(),Se=1048576,Ie=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*Se: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}),Object.defineProperty(e.prototype,"enabledChannelMemberShipHistory",{get:function(){return this._applicationAttributes.includes("channel_membership_history")},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/Se),e.use_reaction=this._useReaction,e.application_attributes=this._applicationAttributes,e.premium_feature_list=this._premiumFeatureList,e.disable_supergroup_mack=this._disableSupergroupMack,e},e}(),Te=function(){function e(e){this._source=e}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}),e}(),Oe=function(){},Ue={NAME_ALPHABETICAL:["name","-pk"],CHRONOLOGICAL:["-createdAt","-pk"],LATEST_LAST_MESSAGE:["-lastMessageCreatedAt","-createdAt","-pk"]},ke={LATEST:["channelUrl","-createdAt","-messageId"],LATEST_UNSENT:["channelUrl","sendingStatus","createdAt"],CHILD_MESSAGE_FIRST:["channelUrl","-parentMessageId","-createdAt"]},Me=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}(),Re=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.includes("*")&&!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}(),Le=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},Pe=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},we=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)))}},De=function(e){return new Promise((function(t,n){setTimeout((function(){return t()}),e)}))},He={};!function(e){e.SUCCEEDED="succeeded",e.UNSENT="unsent"}(fe||(fe={}));var Fe,Ge=function(){function e(e){var t=e.iid,n=e.collections;this._iid=t,this._collections=n,He[t]=this}return e.of=function(e){return He[e]},e.prototype._serialize=function(e){return e.serialize()},e.prototype._deserialize=function(e){if(e){var t=R(R({},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=R(R({},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._getMessageCollectionByType=function(e){return e?this._collections[e]:this._collections.succeeded},e.prototype._getIndexByCollection=function(e){return"UnsentMessage"===e.name?ke.LATEST_UNSENT:ke.LATEST},e.prototype._fetch=function(e,t,n){return L(this,void 0,void 0,(function(){var r,i,s=this;return P(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.parentMessageId&&r.parentMessageId!==n.parentMessageId)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:n.index,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 L(s,void 0,void 0,(function(){var t,r,i;return P(this,(function(s){switch(s.label){case 0:return t=this._deserialize(e),(r=e.messageParams)&&r.file&&te.isFileTypeBlob(r.fileType)&&"string"==typeof t._messageParams.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 L(this,void 0,void 0,(function(){var i,s,a=this;return P(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:r.index,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 L(a,void 0,void 0,(function(){var i,s,a;return P(this,(function(o){switch(o.label){case 0:return i=e.deserialize(t,n),(s=n.messageParams)&&s.file&&te.isFileTypeBlob(s.fileType)&&"string"==typeof i._messageParams.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 L(this,void 0,void 0,(function(){var n,r;return P(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.getPreviousAndNextMessages=function(e,t,n,r,i){return void 0===r&&(r=30),L(this,void 0,void 0,(function(){var s,a;return P(this,(function(o){switch(o.label){case 0:return[4,this.getPreviousMessages(e,t,n,r,i)];case 1:return s=o.sent(),[4,this.getNextMessages(e,t,n,r,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:ke.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._serializeMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i=this;return P(this,(function(s){switch(s.label){case 0:return n=this._getMessageCollectionByType(t),r=[],[4,Promise.all(e.map((function(e){return L(i,void 0,void 0,(function(){var t,i;return P(this,(function(s){switch(s.label){case 0:return(t=e.serialize())?((t=R({},t)).messageParams&&(t.messageParams=R({},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&&te.isBlob(e._messageParams.file)&&te.isFileTypeBlob(e._messageParams.fileType)?[4,n.saveBlob(e._messageParams.file,e.reqId)]:[3,2]):[3,3];case 1:i=s.sent(),t.messageParams.file=i,s.label=2;case 2:r.push(t),s.label=3;case 3:return[2]}}))}))})))];case 1:return s.sent(),[2,r]}}))}))},e.prototype.upsert=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c,d,h,p,f,_,g;return P(this,(function(y){switch(y.label){case 0:return this._localCacheEnabled?(n=ji.getInstance(this._iid),r=this._getMessageCollectionByType(t),[4,this._serializeMessages(e,t)]):[3,13];case 1:return i=y.sent(),[4,r.upsertMany(i)];case 2:if(y.sent(),t&&t!==fe.SUCCEEDED)return[3,13];s=[],a=[],o=0,y.label=3;case 3:return o0?(c=(u=s).concat,[4,this._locallyUpdateChildMessages(l,fe.SUCCEEDED)]):[3,6]:[3,7];case 4:return s=c.apply(u,[y.sent()]),h=(d=a).concat,[4,this._locallyUpdateChildMessages(l,fe.UNSENT)];case 5:a=h.apply(d,[y.sent()]),y.label=6;case 6:return o++,[3,3];case 7:return s.length>0?(p=this._getMessageCollectionByType(fe.SUCCEEDED),[4,this._serializeMessages(s,fe.SUCCEEDED)]):[3,10];case 8:return f=y.sent(),[4,p.upsertMany(f)];case 9:y.sent(),y.label=10;case 10:return a.length>0?(_=this._getMessageCollectionByType(fe.UNSENT),[4,this._serializeMessages(a,fe.UNSENT)]):[3,13];case 11:return g=y.sent(),[4,_.upsertMany(g)];case 12:y.sent(),y.label=13;case 13:return[2]}}))}))},e.prototype._locallyUpdateChildMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i;return P(this,(function(s){switch(s.label){case 0:return n=new Re,r=[],i=this._getMessageCollectionByType(t),[4,this.getAllChildMessages(e,n,i)];case 1:return s.sent().forEach((function(t){t.applyParentMessage(e)&&r.push(t)})),[2,r]}}))}))},e.prototype.remove=function(e,t){return L(this,void 0,void 0,(function(){var n,r;return P(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return i.sent(),n=this._getMessageCollectionByType(t),r={messageId:{"/in":e.map((function(e){return"".concat(e)}))}},[4,n.removeIf({where:r})];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.removeUnsentMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return t=e.channelUrl,n=e.sendingStatus,r=e.reqIds,i=[],this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return o.sent(),s=this._getMessageCollectionByType(fe.UNSENT),a={channelUrl:{"=":t}},n&&(a.sendingStatus={"=":n}),r&&r.length>0&&(a.reqId={"/in":r}),[4,s.removeIf({where:a})];case 2:i=o.sent(),o.label=3;case 3:return[2,i]}}))}))},e.prototype.removeFailedMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i,s;return P(this,(function(a){switch(a.label){case 0:return n=[],this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return a.sent(),r=this._getMessageCollectionByType(fe.UNSENT),i=ji.getInstance(this._iid),s={channelUrl:{"=":e},sendingStatus:{"=":i.MessageSendingStatus.FAILED}},t&&t.length>0&&(s.reqId={"/in":t}),[4,r.removeIf({where:s})];case 2:n=a.sent(),a.label=3;case 3:return[2,n]}}))}))},e.prototype.clearByChannelUrl=function(e){return L(this,void 0,void 0,(function(){var t=this;return P(this,(function(n){switch(n.label){case 0:return[4,Promise.all(Object.keys(fe).map((function(n){var r=t._getMessageCollectionByType(fe[n]),i={channelUrl:{"=":e}};return r.removeIf({where:i})})))];case 1:return n.sent(),[2]}}))}))},e.prototype.clear=function(e){return L(this,void 0,void 0,(function(){return P(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 L(this,void 0,void 0,(function(){var e=this;return P(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,Promise.all(Object.keys(fe).map((function(t){return e.clear(fe[t])})))]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAbove=function(e,t){return L(this,void 0,void 0,(function(){var n,r;return P(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?(n=this._getMessageCollectionByType(t),r={createdAt:{"<":e}},[4,n.removeIf({where:r})]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e}(),xe=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}(),je={},Be=function(e,t){return"sendbird:".concat(e,"@channel/").concat(t,"/message/sync")},Ve=function(){function e(e){var t=e.iid,n=e.channel,r=e.limit,i=void 0===r?Ze:r,s=this;this._prevSync=null,this._nextSync=null,this._syncRange=new xe({top:Number.MAX_SAFE_INTEGER,bottom:-1}),this._isPrevSyncComplete=!1,this._isNextSyncComplete=!1,this._iid=t,this._channel=n,this._limit=i;var a=x.get(this._iid).BaseChannel,o=U.get(this._iid),l=o.get("currentUserId"),u=o.get("store"),c=o.get("apiClient"),d=Ge.of(this._iid),h=ge.of(this._iid),p=Be(l,this._channel.url),f=o.container.concurrentCallLimit,_=o.container.backOffDelay;this._prevSync=new ut(p,(function(e){return L(s,void 0,void 0,(function(){var e,t,r,i,s,o,l,f,_,g=this;return P(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:null},[4,u.get(p)];case 1:return(t=y.sent())&&t.isPrevSyncComplete?[3,7]:(t&&(this._syncRange=t.range,this._isPrevSyncComplete=t.isPrevSyncComplete),r=Pe({channel:this._channel,ts:this._syncRange.top,prevLimit:this._limit}),[4,c.getMessageList(r)]);case 2:return i=y.sent(),s=[],o=i.messages.map((function(e){var t=a.buildMessage(e,g._channel);return(t.isUserMessage()||t.isFileMessage())&&t._isSentByMe()&&s.push(t.reqId),t})),l=this.getMinCreatedAt(o),this._syncRange.top=Math.min(this._syncRange.top,l),this._syncRange.bottom<0&&(this._syncRange.bottom=this.getMaxCreatedAt(o)),this._isPrevSyncComplete=o.length0?[4,d.removeUnsentMessages({channelUrl:this._channel.url,reqIds:s})]:[3,5];case 4:y.sent(),y.label=5;case 5:return f={range:this._syncRange,isPrevSyncComplete:this._isPrevSyncComplete,isNextSyncComplete:t?t.isNextSyncComplete:this._isNextSyncComplete},[4,u.set({key:p,value:f,generation:1})];case 6:return y.sent(),_={source:de.MESSAGE_BACKGROUND,payload:{channel:n,messages:o}},h.send(_),e.hasNext=!this._isPrevSyncComplete,[3,8];case 7:J.debug("Message collection background sync has finished."),e.hasNext=!1,y.label=8;case 8:return[2,e]}}))}))}),f,_),this._nextSync=new ut(p,(function(e){return L(s,void 0,void 0,(function(){var e,t,r,i,s,o,l,f,_,g=this;return P(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:null},[4,u.get(p)];case 1:return(t=y.sent())?(this._syncRange=t.range,r=Pe({channel:this._channel,ts:this._syncRange.bottom,nextLimit:this._limit}),[4,c.getMessageList(r)]):[3,7];case 2:return i=y.sent(),s=[],o=i.messages.map((function(e){var t=a.buildMessage(e,g._channel);return(t.isUserMessage()||t.isFileMessage())&&t._isSentByMe()&&s.push(t.reqId),t})),l=this.getMaxCreatedAt(o),this._syncRange.bottom=Math.max(this._syncRange.bottom,l),this._isNextSyncComplete=o.length0?[4,d.removeUnsentMessages({channelUrl:this._channel.url,reqIds:s})]:[3,5];case 4:y.sent(),y.label=5;case 5:return f={range:this._syncRange,isPrevSyncComplete:t?t.isPrevSyncComplete:this._isPrevSyncComplete,isNextSyncComplete:this._isNextSyncComplete},[4,u.set({key:p,value:f,generation:1})];case 6:y.sent(),_={source:de.MESSAGE_BACKGROUND,payload:{channel:n,messages:o}},h.send(_),e.hasNext=!this._isNextSyncComplete,y.label=7;case 7:return[2,e]}}))}))}),f,_)}return e.of=function(t,n,r){return void 0===r&&(r=Ze),je[t]||(je[t]={}),je[t][n.url]||(je[t][n.url]=new e({iid:t,channel:n,limit:r})),je[t][n.url]},Object.defineProperty(e.prototype,"priority",{set:function(e){this._prevSync.priority=e,this._nextSync.priority=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"range",{get:function(){return this._syncRange},enumerable:!1,configurable:!0}),e.prototype.resume=function(){J.debug("Message collection background sync has resumed."),this._isPrevSyncComplete||this._prevSync.resume(null),this._isNextSyncComplete||this._nextSync.resume(null)},e.prototype.pause=function(){J.debug("Message collection background sync has paused."),this._prevSync.stop(),this._nextSync.stop()},e.prototype.getMinCreatedAt=function(e){var t=Number.MAX_SAFE_INTEGER;return e.forEach((function(e){var n=e.createdAt;nt&&(t=n)})),t},e}(),qe={},Ke=function(e,t){return"sendbird:".concat(e,"@channel/").concat(t,"/message/changelogs")},ze=function(){function e(e){var t=e.iid,n=e.channel,r=this;this._token=0,this._sync=null,this._iid=t,this._channel=n;var i=x.get(this._iid).BaseChannel,s=U.get(this._iid),a=s.get("currentUserId"),o=s.get("store"),l=s.get("apiClient"),u=s.container.localCacheEnabled,c=Ge.of(this._iid),d=ge.of(this._iid),h=Ke(a,this._channel.url);this._sync=new ut(h,(function(e){return L(r,void 0,void 0,(function(){var e,t,r,a,p,f,_,g,y,m=this;return P(this,(function(E){switch(E.label){case 0:return e={hasNext:!0,nextParams:""},u?[4,o.get(h)]:[3,2];case 1:return r=E.sent(),[3,3];case 2:r=null,E.label=3;case 3:t=r,this._token=t?t.token:s.get("firstConnectedAt")/1e3,a={channelUrl:this._channel.url,isOpenChannel:this._channel.isOpenChannel(),includeMetaArray:!0,includeReactions:!0,includeReplies:!0,includeParentMessageText:!0,includeThreadInfo:!0},"number"==typeof this._token?a.timestamp=this._token:a.token=this._token,E.label=4;case 4:return E.trys.push([4,12,,15]),[4,l.getMessageChangeLogs(a)];case 5:return p=E.sent(),f=p.updated.map((function(e){return i.buildMessage(e,m._channel)})),_={updatedMessages:f,deletedMessageIds:p.deleted.map((function(e){return parseInt(e.message_id)}))},e.hasNext=p.has_more,e.nextParams=this._token=p.next,u?(g=[],f.forEach((function(e){(e.isUserMessage()||e.isFileMessage())&&e._isSentByMe()&&g.push(e.reqId)})),g.length>0?[4,c.removeUnsentMessages({channelUrl:this._channel.url,reqIds:g})]:[3,7]):[3,11];case 6:E.sent(),E.label=7;case 7:return[4,c.upsert(f)];case 8:return E.sent(),[4,c.remove(_.deletedMessageIds)];case 9:return E.sent(),[4,o.set({key:h,value:{token:this._token},generation:1})];case 10:E.sent(),E.label=11;case 11:return J.debug("Message collection changelog sync update messages count: ",_.updatedMessages.length),J.debug("Message collection changelog sync deleted message ids count: ",_.deletedMessageIds.length),y={source:de.MESSAGE_CHANGELOG,payload:R({channel:n},_)},d.send(y),[2,e];case 12:return E.sent().isInvalidTokenError?[4,o.remove(h)]:[3,14];case 13:E.sent(),E.label=14;case 14:return[3,15];case 15:return[2]}}))}))}))}return e.of=function(t,n){return qe[t]||(qe[t]={}),qe[t][n.url]||(qe[t][n.url]=new e({iid:t,channel:n})),qe[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",e.CACHE_ONLY="cache_only"}(Fe||(Fe={}));var Ye,Qe=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}(),We=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},Je=function(){function e(){}return e.prototype.isNetworkConnected=function(){return!("undefined"==typeof navigator||!navigator.onLine)},e.ready=function(){return L(this,void 0,void 0,(function(){return P(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"}(Ye||(Ye={}));var Xe,Ze=100,$e=new xe({top:Number.MAX_SAFE_INTEGER,bottom:0}),et=new Map,tt=function(e){return"sendbird@message/fill/".concat(e,"/").concat(We())},nt=function(){function e(e){var t=e.iid,n=e.channel,r=e.startingPoint,i=e.filter,s=e.limit,a=void 0===s?100:s,o=this;this._hugeGapCheckTimer=null,this._messages=[],this._syncRange=new xe(R({},$e)),this._hasPrevious=!0,this._hasNext=!0,this._unsentMessages=[],this._iid=t,this._channel=n,this._startingPoint=r,this._filter=i,this._limit=a,this._syncLimit=Math.max(a,Ze),this._eventObserver={onevent:function(e){return L(o,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onMessagesAdded:Oe,onMessagesUpdated:Oe,onMessagesDeleted:Oe,onChannelUpdated:Oe,onChannelDeleted:Oe,onHugeGapDetected:Oe};var l=U.get(this._iid);this._localCacheEnabled=l.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=Ve.of(this._iid,this._channel,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=ze.of(this._iid,this._channel),this._connectionObserver={onConnect:function(){o._checkHugeGap(),o._localCacheEnabled&&o._backgroundSync.resume(),o._changelogSync.resume()},onDisconnect:function(){return L(o,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,Je.ready()];case 1:return e.sent()||(this._previousFillSync.stop(),this._nextFillSync.stop(),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},this._previousFillSync=new ut(tt("prev"),(function(e){return L(o,void 0,void 0,(function(){var t,n,r;return P(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 Me(de.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 ut(tt("next"),(function(e){return L(o,void 0,void 0,(function(){var t,n,r;return P(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 Me(de.MESSAGE_FILL,t[0].sendingStatus),this._addMessagesToView(t,{context:r}),[2,{hasNext:t.length0){this._removeMatchingUnsentMessagesFromView(o);var u=new Me(t,o[0].sendingStatus);this._addMessagesToView(o,{context:u})}if(l&&l.length>0)if((p=this._removeMessagesFromView(l,{})).length>0){u=new Me(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}}break;case de.LOCAL_MESSAGE_PENDING_CREATED:case de.LOCAL_MESSAGE_RESEND_STARTED:case de.LOCAL_MESSAGE_CANCELED:var c=r,d=(a=c.channel,c.message);u=new Me(t,d.sendingStatus);a.url===this._channel.url&&this._upsertUnsentMessagesToView([d],{context:u});break;case de.EVENT_MESSAGE_SENT:var h=r;a=h.channel,d=h.message;if(a.url===this._channel.url){var p=this._removeMatchingUnsentMessagesFromView([d]);if(this._hasNext){if(p.length>0){u=new Me(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,a,p)}}else{this._addMessagesToView([d],{});var u=new Me(t,d.sendingStatus);p.length>0?this._eventHandler.onMessagesUpdated(u,a,[d]):this._eventHandler.onMessagesAdded(u,a,[d])}}break;case de.EVENT_MESSAGE_RECEIVED:var f=r;a=f.channel,d=f.message;if(a.url===this._channel.url&&!this._hasNext){u=new Me(t,d.sendingStatus);this._addMessagesToView([d],{context:u})}break;case de.LOCAL_MESSAGE_FAILED:var _=r;a=_.channel,d=_.message;if(a.url===this._channel.url&&d.sendingStatus===i.MessageSendingStatus.FAILED){u=new Me(t,d.sendingStatus);this._upsertUnsentMessagesToView([d],{context:u})}break;case de.EVENT_MESSAGE_UPDATED:var g=r;a=g.channel,d=g.message;if(a.url===this._channel.url){u=new Me(t,d.sendingStatus);this._addMessagesToView([d],{context:u,isUpdateOnly:!0})}break;case de.EVENT_MESSAGE_DELETED:var y=r,m=(a=y.channel,y.messageId);if(a.url===this._channel.url)if(et.delete(m),(p=this._removeMessagesFromView([m],{})).length>0){u=new Me(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}break;case de.EVENT_DELIVERY_RECEIPT_UPDATED:case de.EVENT_READ_RECEIPT_UPDATED:if((a=r.channel).isGroupChannel()){o=[];for(var E=0,v=this._messages;E0?et.set(d.messageId,T):et.delete(d.messageId))}if(o.length>0){u=new Me(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}break;case de.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?et.set(d.messageId,T):et.delete(d.messageId))}if(o.length>0){u=new Me(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}else{u=new Te(t);this._eventHandler.onChannelDeleted(u,a.url)}break;case de.EVENT_CHANNEL_CHANGED:case de.EVENT_USER_RECEIVED_INVITATION:case de.EVENT_USER_JOINED:case de.EVENT_CHANNEL_FROZEN:case de.EVENT_CHANNEL_UNFROZEN:case de.EVENT_CHANNEL_HIDDEN:case de.EVENT_CHANNEL_UNHIDDEN:case de.EVENT_USER_MUTED:case de.EVENT_USER_UNMUTED:case de.EVENT_TYPING_STATUS_UPDATED:case de.EVENT_OPERATOR_UPDATED:case de.EVENT_CHANNEL_METADATA_UPDATED:case de.EVENT_CHANNEL_METADATA_DELETED:case de.EVENT_CHANNEL_METACOUNTER_UPDATED:case de.EVENT_CHANNEL_METACOUNTER_DELETED:a=r.channel,u=new Te(t);this._eventHandler.onChannelUpdated(u,a);break;case de.EVENT_CHANNEL_DELETED:a=r.channel,u=new Te(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 L(this,void 0,void 0,(function(){var e,n,i,a;return P(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={}),L(this,void 0,void 0,(function(){var n,r,i,s;return P(this,(function(a){switch(a.label){case 0:return n=t.context,r=void 0===n?null:n,i=Ge.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._removeMatchingUnsentMessagesFromView(e,{context:r}),[4,i.upsert(e,fe.SUCCEEDED)];case 2:return a.sent(),this._addMessagesToView(e,{context:r}),[2]}}))}))},e.prototype._checkHugeGap=function(){return L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_=this;return P(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=Ge.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.hasNext?this._messages[this._messages.length-1].createdAt:Number.MAX_SAFE_INTEGER,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(R(R({},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 Me(de.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 Me(de.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._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},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=ji.getInstance(this._iid),o=[],l=[],u=[],c=0,d=e;c=0){if(l.push(h),this._messages[p]=h,h.updatedAt>0){var _=this._updateChildMessagesInView(h);l=l.concat(_)}}else if(!s){var g=Le(this._messages,h);o.push(h),this._messages.splice(g,0,h)}}else p>=0&&(u.push(h),this._messages.splice(p,1))}}r&&(o.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,o),l.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,l),u.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,u))},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=Le(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._removeMatchingUnsentMessagesFromView=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=ji.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&&!se.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._processAutoResendRegisteredPendingMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h;return P(this,(function(p){switch(p.label){case 0:return t=Ge.of(e._iid),n=ge.of(e._iid),(r=new Re).sendingStatus=e.MessageSendingStatus.PENDING,[4,t.getAllUnsentMessages(r)];case 1:i=p.sent(),s=0,a=i,p.label=2;case 2:return s0?Math.min.apply(Math,this._messages.map((function(e){return e.createdAt}))):Number.MAX_SAFE_INTEGER,[4,Je.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadPrevious() from the cache."),[4,Ge.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),we(this._syncRange,["prev"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return L(this,void 0,void 0,(function(){var e,t;return P(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,Je.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadNext() from the cache."),[4,Ge.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),we(this._syncRange,["next"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.removeFailedMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i;return P(this,(function(s){switch(s.label){case 0:return t=ji.getInstance(this._iid),n=Ge.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 L(this,void 0,void 0,(function(){var e;return P(this,(function(t){switch(t.label){case 0:return e=ji.getInstance(this._iid),[4,Ge.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),ge.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setMessageCollectionHandler=function(e){this._eventHandler=e},e}(),rt=new Map,it=new Map,st=new Map,at=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,i=void 0===r?2:r,s=t.backOffDelay,a=void 0===s?0:s,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=i,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],$()?(rt[this._holdersKey]||(rt[this._holdersKey]=[]),it[this._resolversKey]||(it[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return L(o,void 0,void 0,(function(){var t,n;return P(this,(function(r){if(this._localResolversData.length>0&&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=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));n.length>0?window.localStorage.setItem(o._resolversKey,JSON.stringify(n)):window.localStorage.removeItem(o._resolversKey),o._localAcquiredKeys.forEach((function(e){return o.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-rt[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return $()?it[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if($())return st[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){$()?st[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return L(this,void 0,void 0,(function(){var e;return P(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,L(void 0,void 0,void 0,(function(){return P(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=Ye.BACKGROUND_SYNC_CLOSE),L(this,void 0,void 0,(function(){var t,n=this;return P(this,(function(r){return $()?[2,new Promise((function(t){var r={key:We(),resolver:function(e){return t(e)},priority:e};switch(e){case Ye.USER_CALL:case Ye.FILL:case Ye.BACKGROUND_SYNC_OPEN:for(var i=it[n._resolversKey],s=-1,a=0;ai[a].priority&&(s=a);if(s>=0){it[n._resolversKey].splice(s,0,r);break}case Ye.BACKGROUND_SYNC_CLOSE:it[n._resolversKey].push(r)}n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){var i=We(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e};switch(e){case Ye.USER_CALL:case Ye.FILL:case Ye.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 Ye.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($()){if((t=rt[this._holdersKey].indexOf(e))>=0)return rt[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),n.length>0?window.localStorage.setItem(this._holdersKey,JSON.stringify(n)):window.localStorage.removeItem(this._holdersKey),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($()){if(rt[this._holdersKey].length0?window.localStorage.setItem(this._resolversKey,JSON.stringify(r)):window.localStorage.removeItem(this._resolversKey),window.localStorage.setItem(this._holdersKey,JSON.stringify(w(w([],t,!0),[e],!1))),this._localAcquiredKeys.push(e);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(w([],t,!0)),newValue:JSON.stringify(w(w([],t,!0),[e],!1))});return dispatchEvent(s),(0,n.resolver)(e),!0}}return!1},e.prototype._getLocalHoldersData=function(){var e=window.localStorage[this._holdersKey];return void 0!==e?JSON.parse(e):[]},e.prototype._getLocalResolversData=function(){var e=window.localStorage[this._resolversKey];return void 0!==e?JSON.parse(e):[]},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Xe||(Xe={}));var ot,lt=function(){},ut=function(){function e(e,t,n,r){void 0===n&&(n=2),void 0===r&&(r=10),this._worker=null,this._state=Xe.IDLE,this._retryCount=0,this._retryLimit=3,this._isPaused=!1,this.priority=Ye.BACKGROUND_SYNC_CLOSE,this.onProgress=lt,this.onStop=lt,this.onError=lt,this.onEnd=lt,this._key=e,this._worker=t,this._semaphore=new at({key:e,concurrentCallLimit:n,backOffDelay:r})}return Object.defineProperty(e.prototype,"isIdle",{get:function(){return this._state===Xe.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isRunning",{get:function(){return this._state===Xe.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDone",{get:function(){return this._state===Xe.END},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPaused",{get:function(){return this._isPaused},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),e.prototype.resume=function(e,t){return void 0===t&&(t=!1),this._isPaused=!1,this.isDone&&t&&(this._state=Xe.IDLE),this.run(e)},e.prototype.run=function(e){return L(this,void 0,void 0,(function(){var t,n,r;return P(this,(function(i){switch(i.label){case 0:return this._isPaused||!this.isIdle?[3,5]:(t=this,[4,this._semaphore.acquire(this.priority)]);case 1:t._key=i.sent(),this._state=Xe.RUNNING,i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this._worker(e)];case 3:return n=i.sent(),this._retryCount=0,this.onProgress(n),n.hasNext?(this._state=Xe.IDLE,this._isPaused?(this._semaphore.release(this._key),this.onStop()):(this.run(n.nextParams),this._semaphore.release(this._key))):(this._state=Xe.END,this._semaphore.release(this._key),this.onEnd(),this._isPaused&&this.onStop()),[3,5];case 4:return r=i.sent(),J.warn("Collection sync run error: ",r),this._state=Xe.IDLE,this._semaphore.release(this._key),this.onError(r),this._retryCount=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 4:return p.sent(),[4,u.set({key:h,value:{token:this._token,range:this._syncRange,completed:this._completed,primaryKeyIndex:this._pkIndex},generation:1})];case 5:return p.sent(),a={source:de.CHANNEL_BACKGROUND,payload:{channels:i}},d.send(a),[3,9];case 6:return p.sent().isInvalidTokenError?[4,u.remove(h)]:[3,8];case 7:p.sent(),p.label=8;case 8:return[3,9];case 9:return[3,11];case 10:J.debug("Group channel collection background sync has finished."),e.hasNext=!1,p.label=11;case 11:return[2,e]}}))}))}))}return e.of=function(t,n){return void 0===n&&(n=mt),ct[t]||(ct[t]=new e({iid:t,limit:n})),ct[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}(),ht={},pt=function(){function e(e){var t=e.iid,n=this;this._token=0,this._sync=null,this._pkIndex=Date.now(),this._iid=t;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=bt.of(this._iid),c=ge.of(this._iid),d="sendbird:".concat(s,"@groupchannel/changelogs");this._sync=new ut(d,(function(e){return L(n,void 0,void 0,(function(){var e,t,n,i,s,h,p,f=this;return P(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:(t=n)&&(this._token=t.token,this._pkIndex=t.primaryKeyIndex),i={},"number"==typeof this._token?i.ts=this._token:i.token=this._token,_.label=4;case 4:return _.trys.push([4,10,,13]),[4,o.getMyGroupChannelChangeLogs(i)];case 5: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,9];case 6:return _.sent(),[4,u.remove(h.deletedChannelUrls)];case 7:return _.sent(),[4,a.set({key:d,value:{token:this._token,primaryKeyIndex:this._pkIndex},generation:1})];case 8:_.sent(),_.label=9;case 9:return p={source:de.CHANNEL_CHANGELOG,payload:h},c.send(p),[2,e];case 10:return _.sent().isInvalidTokenError?[4,a.remove(d)]:[3,12];case 11:_.sent(),_.label=12;case 12:return[3,13];case 13:return[2]}}))}))}))}return e.of=function(t){return ht[t]||(ht[t]=new e({iid:t})),ht[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}(),ft=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 yt(e[s],t,n)>0?s:s+1}return e.length},gt=function(e,t){return t-e},yt=function(e,t,n){switch(n){case ot.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=gt(e.cachedPrimaryKey,t.cachedPrimaryKey))}return s}r=e.createdAt;return 0===(s=t.createdAt-r)&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ot.CHRONOLOGICAL:return 0===(s=t.createdAt-e.createdAt)&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ot.CHANNEL_NAME_ALPHABETICAL:var s;return 0===(s=e.name.localeCompare(t.name))&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s}},mt=40;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical"}(ot||(ot={}));var Et=function(){function e(e){var t=e.iid,n=e.filter,r=e.order,i=e.limit,s=void 0===i?20:i,a=this;this._channels=[],this._token=null,this._hasMore=!0,this._iid=t,this._filter=n,this._order=r,this._limit=s,this._syncLimit=Math.max(s,mt),this._eventObserver={onevent:function(e){return L(a,void 0,void 0,(function(){return P(this,(function(t){return[2,this._handleEvent(e)]}))}))}},this._eventHandler={onChannelsAdded:Oe,onChannelsUpdated:Oe,onChannelsDeleted:Oe};var o=U.get(this._iid);this._localCacheEnabled=o.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=dt.of(this._iid,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=pt.of(this._iid),ge.of(this._iid).addObserver(this._eventObserver),this._connectionStateObserver={onConnect:function(){a._localCacheEnabled&&a._backgroundSync.resume(),a._changelogSync.resume()},onDisconnect:function(){return L(a,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,Je.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 Te(n);switch(n){case de.CHANNEL_BACKGROUND:break;case de.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 de.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 de.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 de.EVENT_USER_BANNED:case de.EVENT_USER_UNBANNED:break;case de.EVENT_USER_MUTED:case de.EVENT_USER_UNMUTED:case de.EVENT_TYPING_STATUS_UPDATED:case de.EVENT_OPERATOR_UPDATED:case de.EVENT_CHANNEL_METADATA_UPDATED:case de.EVENT_CHANNEL_METADATA_DELETED:case de.EVENT_CHANNEL_METACOUNTER_UPDATED:case de.EVENT_CHANNEL_METACOUNTER_DELETED:h=r.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case de.EVENT_READ_RECEIPT_UPDATED:case de.EVENT_USER_RECEIVED_INVITATION:case de.EVENT_USER_JOINED:case de.EVENT_CHANNEL_FROZEN:case de.EVENT_CHANNEL_UNFROZEN:case de.EVENT_CHANNEL_HIDDEN:case de.EVENT_CHANNEL_UNHIDDEN:case de.EVENT_CHANNEL_CHANGED:h=r.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case de.EVENT_CHANNEL_DELETED:var f=r.channelUrl;this._removeChannelsFromView([f],{context:s})}},e.prototype._getRemoteChannels=function(){return L(this,void 0,void 0,(function(){var e,t,n,r;return P(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(R(R({},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,bt.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 L(this,void 0,void 0,(function(){var e,t,n,r,i;return P(this,(function(s){switch(s.label){case 0:return this._hasMore?[4,Je.ready()]:[3,5];case 1:return s.sent()?[3,3]:(J.debug("Group channel collection loadMore() from the cache."),e=bt.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(),ge.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setGroupChannelCollectionHandler=function(e){this._eventHandler=e},e.GroupChannelOrder=ot,e}(),vt={},bt=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,vt[t]=this}return e.of=function(e){return vt[e]},e.prototype._serialize=function(e){var t=this._createPk();return e.cachedPrimaryKey=t,R(R({},e.serialize()),{lastMessageCreatedAt:e.lastMessage?e.lastMessage.createdAt:-1,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 L(this,void 0,void 0,(function(){var r,i,s,a,o,l,u,c=this;return P(this,(function(d){switch(d.label){case 0:if(!this._localCacheEnabled)return[3,2];switch(r=Ue.LATEST_LAST_MESSAGE,t){case ot.CHANNEL_NAME_ALPHABETICAL:r=Ue.NAME_ALPHABETICAL;break;case ot.CHRONOLOGICAL:r=Ue.CHRONOLOGICAL;break;case ot.LATEST_LAST_MESSAGE:r=Ue.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 ot.LATEST_LAST_MESSAGE:if(n.lastMessageCreatedAt>s)return!1;if(n.lastMessageCreatedAt===s&>(l,n.pk)>=0)return!1;if(n.lastMessageCreatedAt<0){if(n.createdAt>a)return!1;if(n.createdAt===a&>(l,n.pk)>=0)return!1}break;case ot.CHANNEL_NAME_ALPHABETICAL:var r=n.name.localeCompare(o);if(r<0)return!1;if(0===r&>(l,n.pk)>=0)return!1;break;case ot.CHRONOLOGICAL:if(n.createdAt>a)return!1;if(n.createdAt===a&>(l,n.pk)>=0)return!1}return e.match(c._deserialize(n))},index:r},[4,this._collection.query(u).fetch({limit:n.limit})];case 1:return[2,d.sent().map((function(e){return c._deserialize(e)}))];case 2:return[2,[]]}}))}))},e.prototype.getNextContainerToken=function(e,t){switch(e){case ot.LATEST_LAST_MESSAGE:return t.length>0?{lastMessageCreatedAt:(n=t[t.length-1]).lastMessage?n.lastMessage.createdAt:-1,createdAt:n.createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{lastMessageCreatedAt:Number.MAX_SAFE_INTEGER,createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ot.CHRONOLOGICAL:return t.length>0?{createdAt:(n=t[t.length-1]).createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ot.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 L(this,void 0,void 0,(function(){var t;return P(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),L(this,void 0,void 0,(function(){return P(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 L(this,void 0,void 0,(function(){var t,n=this;return P(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 L(this,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this._collection.removeIf({where:{url:{"/in":e}}})]:[3,3];case 1:return t.sent(),[4,ji.getInstance(this._iid).clearCachedMessages(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return L(this,void 0,void 0,(function(){return P(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}(),Ct=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}(),At=function(e){return Object.keys(e).forEach((function(t){e[t]&&"object"==typeof e[t]&&At(e[t])})),Object.freeze(e)},Nt=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),At(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}(),St={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},It=new WeakMap,Tt=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.mentionedMessageTemplate=null,this.sendingStatus=null,It.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 Nt.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 se.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=ji.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;if(e.hasOwnProperty("msg_id")&&e.msg_id&&(this.messageId=parseInt(e.msg_id)),e.hasOwnProperty("type"))switch(e.type){case"MESG":this.messageType=o.MESSAGE_TYPE_USER;break;case"FILE":this.messageType=o.MESSAGE_TYPE_FILE;break;case"BRDM":case"ADMM":this.messageType=o.MESSAGE_TYPE_ADMIN}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&&It.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:"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=me.parse(arguments,[new me({type:Ct,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=t)return this.parentMessage=e,!0}return!1}},{key:"_setRootMessageId",value:function(e){It.set(this,e)}}],[{key:"MESSAGE_TYPE_BASE",get:function(){return"base"}},{key:"MESSAGE_TYPE_ADMIN",get:function(){return"admin"}},{key:"MESSAGE_TYPE_USER",get:function(){return"user"}},{key:"MESSAGE_TYPE_FILE",get:function(){return"file"}},{key:"SendingStatus",get:function(){return{NONE:"none",PENDING:"pending",FAILED:"failed",CANCELED:"canceled",SUCCEEDED:"succeeded"}}},{key:"ReplyType",get:function(){return{ALL:"all",NONE:"none",ONLY_REPLY_TO_CHANNEL:"only_reply_to_channel"}}},{key:"getMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.BaseChannel,s=r.MessageRetrievalParams,a=null,o=me.parse(arguments,[new me({type:s,constraint:function(e){return e._validate()}}),new me({type:"callback"})]),u=C(o,3);return a=u[0],e=u[1],t=u[2],oe(this._iid,(function(t){if(a)t(a,null);else{var r=x.get(n._iid),s=r.GroupChannel,o=r.OpenChannel;switch(e.channelType){case i.CHANNEL_TYPE_GROUP:s.getChannel(e.channelUrl,T.INTERNAL_CALL,(function(r,s){if(ji.getInstance(n._iid).getErrorFirstCallback()){var a=[r,s];s=a[0],r=a[1]}s?t(s,null):U.get(n._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,n){if(e)t(e,null);else{var s=i.buildMessage(n,r);t(null,s)}}))}));break;case i.CHANNEL_TYPE_OPEN:o.getChannel(e.channelUrl,T.INTERNAL_CALL,(function(r,s){if(ji.getInstance(n._iid).getErrorFirstCallback()){var a=[r,s];s=a[0],r=a[1]}s?t(s,null):U.get(n._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,n){if(e)t(e,null);else{var s=i.buildMessage(n,r);t(null,s)}}))}))}}}),t)}}]),e}(),Ot=function(){function e(e){this.nickname="",this.plainProfileUrl="",this.userId="",this.connectionStatus="",this.lastSeenAt=null,this.metaData={},this.isActive=!0,this.friendDiscoveryKey=null,this.friendName=null,this._preferredLanguages=null,this.requireAuth=null,e&&this.__update(e)}return e.objectify=function(e){var t=e.userId,n=void 0===t?null:t,r=e.nickname,i=void 0===r?"":r,s=e.plainProfileUrl,a=void 0===s?"":s,o=e.connectionStatus,l=void 0===o?"":o,u=e.lastSeenAt,c=void 0===u?0:u,d=e.metaData,h=void 0===d?{}:d,p=e.isActive,f=void 0===p||p,_=e.friendDiscoveryKey,g=void 0===_?null:_,y=e.friendName,m=void 0===y?null:y,E=e.preferredLanguages,v=void 0===E?null:E,b=e.requireAuth;return{user_id:n,nickname:i,profile_url:a,is_online:l,last_seen_at:c,metadata:h,is_active:f,friend_discovery_key:g,friend_name:m,preferred_languages:v,require_auth_for_profile_image:void 0!==b&&b}},e.buildFromSerializedData=function(e){var t=x.get(this._iid).User,n=Nt.deserialize(e);return new t(t.objectify(n))},Object.defineProperty(e.prototype,"preferredLanguages",{get:function(){return this._preferredLanguages},enumerable:!1,configurable:!0}),e.prototype.__update=function(t){var n=U.get(this._iid).container.auth;t.hasOwnProperty("guest_id")&&(this.userId=t.guest_id),t.hasOwnProperty("user_id")&&(this.userId=t.user_id),t.hasOwnProperty("name")&&(this.nickname=t.name),t.hasOwnProperty("nickname")&&(this.nickname=t.nickname),t.hasOwnProperty("require_auth_for_profile_image")?this.requireAuth=t.require_auth_for_profile_image:this.requireAuth=null,(t.hasOwnProperty("image")||t.hasOwnProperty("profile_url"))&&(this.plainProfileUrl=t.image||t.profile_url||"",Object.defineProperty(this,"profileUrl",{value:this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(n.eKey):this.plainProfileUrl,configurable:!0,writable:!1})),t.hasOwnProperty("is_online")?t.is_online===e.NON_AVAILABLE?this.connectionStatus=e.NON_AVAILABLE:this.connectionStatus=t.is_online?e.ONLINE:e.OFFLINE:this.connectionStatus=e.NON_AVAILABLE,t.hasOwnProperty("last_seen_at")?this.lastSeenAt=parseInt(t.last_seen_at):this.lastSeenAt=0,t.hasOwnProperty("metadata")?this.metaData=t.metadata:this.metaData={},t.hasOwnProperty("is_active")?this.isActive=void 0===t.is_active||t.is_active:this.isActive=!0,t.hasOwnProperty("friend_discovery_key")?this.friendDiscoveryKey=t.friend_discovery_key:this.friendDiscoveryKey=null,t.hasOwnProperty("friend_name")?this.friendName=t.friend_name:this.friendName=null,t.hasOwnProperty("preferred_languages")?this._preferredLanguages=t.preferred_languages||null:this._preferredLanguages=null},e.prototype._updateMetaData=function(e,t){var n=this;void 0===t&&(t=!1);var r=x.get(this._iid).GroupChannel;Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]})),Object.keys(r.cachedChannels).forEach((function(e){if(r.cachedChannels.hasOwnProperty(e)){var t=r.cachedChannels[e];if(t.memberMap.hasOwnProperty(n.userId))t.memberMap[n.userId].metaData=n.metaData}}))},e.prototype.serialize=function(){return Nt.serialize(this,(function(e){e.hasOwnProperty("_preferredLanguages")&&(e.preferredLanguages=e._preferredLanguages,delete e._preferredLanguages)}))},e.prototype.getOriginalProfileUrl=function(){var e="";if(((e=(e=this.plainProfileUrl.indexOf("://")>-1?this.plainProfileUrl.split("/")[2]:this.plainProfileUrl.split("/")[0]).split("?")[0]).indexOf("sendbird.com")>-1||e.indexOf("sendbirdtest.com")>-1||e.indexOf("intoz.com")>-1||e.indexOf("file-local")>-1)&&this.plainProfileUrl.indexOf(e+"/profile_images/")>-1){var 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=me.parse(arguments,[new me({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new me({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=me.parse(arguments,[new me({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 me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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}(),Ut={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},kt=new WeakMap,Mt=new WeakMap,Rt=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,kt.set(this,{}),Mt.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 Ot(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):this._refreshMetaData(e.metadata,-1)),e.hasOwnProperty("cached_primary_key")&&(this.cachedPrimaryKey=e.cached_primary_key)}},{key:"_addOrUpdateCachedMetaData",value:function(e,t){var n=this,r=kt.get(this);Object.keys(e).forEach((function(i){var s=r[i],a=e[i];s?t>s.updatedAt&&(s.value=a,s.updatedAt=t,s.isRemoved=!1):r[i]={value:a,updatedAt:t,isRemoved:!1},bt.of(n._iid).upsert([n]).then((function(){})).catch((function(e){J.error(e)}))}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var n=this,r=kt.get(this);e.forEach((function(e){var i=r[e];i?t>i.updatedAt&&(i.isRemoved=!0,i.updatedAt=t):r[e]={value:null,updatedAt:t,isRemoved:!0},bt.of(n._iid).upsert([n]).then((function(){})).catch((function(e){J.error(e)}))}))}},{key:"_refreshMetaData",value:function(e,t){var n={};Object.keys(e).forEach((function(r){n[r]={value:e[r],updatedAt:t,isRemoved:!1}})),kt.set(this,n)}},{key:"_clearCachedMetaData",value:function(){kt.set(this,{})}},{key:"cachedPrimaryKey",get:function(){return Mt.get(this)},set:function(e){Mt.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 Nt.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),t.metadata=e.getCachedMetaData(),e.cachedPrimaryKey&&(t.cachedPrimaryKey=e.cachedPrimaryKey)}))}},{key:"getMessageChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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=ji.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=me.parse(g,[new me({type:"number"}),new me({type:"boolean"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(g,[new me({type:"number"}),new me({type:"boolean"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(g,[new me({type:"number"}),new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"number"}),new me({type:"string",constraint:function(e){return Object.values(Ut).includes(e)}}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getPreviousAndNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getPreviousMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getPreviousAndNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getMessagesByTimestamp",value:function(e,t,n){return this._getMessageList(e,Ut.TIMESTAMP,t,n)}},{key:"getMessagesByMessageId",value:function(e,t,n){return this._getMessageList(e,Ut.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.mentionedUsers,d=e.mentionedMessageTemplate,h=e.pushNotificationDeliveryOption,p=e.rootMessageId,f=e.parentMessageId,_=e.translationTargetLanguages,g=e.appleCriticalAlertOptions,y=e.pollId,m=e.silent,E=void 0!==m&&m,v=e.isReplyToChannel,b=e.messageParams,C=e.oldMessage,A=void 0===C?null:C,N=e.isManualResend,S=void 0!==N&&N,I=e.callback,T=x.get(this._iid),O=T.Command,k=T.UserMessage,M=ji.getInstance(this._iid),R=Ge.of(this._iid),L=bt.of(this._iid),P=ge.of(this._iid),w=U.get(this._iid).container.localCacheEnabled;n||(n=O.generateRequestId());var D={};Array.isArray(_)&&_.forEach((function(e){return D[e]=""}));var F=k.objectify({messageId:0,reqId:n,user:M.currentUser||{},channel:this,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedUsers:c,mentionedMessageTemplate:d,rootMessageId:p,parentMessageId:f,translations:D,silent:E,appleCriticalAlertOptions:g,isReplyToChannel:v,messageParams:b,createdAt:(new Date).getTime()}),G=new k(F);if(G.requestState=M.MessageRequestState.PENDING,G.sendingStatus=M.MessageSendingStatus.PENDING,G.requestedMentionUserIds=u,G._messageParams=b,!M.currentUser){var j=new H("Connection should be made first.",H.CONNECTION_REQUIRED),B=new k(F);return B.requestState=M.MessageRequestState.FAILED,B.sendingStatus=M.MessageSendingStatus.FAILED,B.requestedMentionUserIds=u,B.errorCode=j.code,I(j,B),G}return(!t.isGroupChannel()||A&&A._isAutoResendRegistered?Promise.resolve():R.upsert([G],fe.UNSENT).then((function(){P.send({source:S?de.LOCAL_MESSAGE_RESEND_STARTED:de.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:t,message:G}})}))).then((function(){var e=O.bMessage({channelUrl:t.url,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedMessageTemplate:d,requestId:n,rootMessageId:p,parentMessageId:f,silent:E,translationTargetLanguages:_,pushNotificationDeliveryOption:h,appleCriticalAlertOptions:g,pollId:y,isReplyToChannel:v});(G.reqId=e.requestId,t.isGroupChannel()&&M.getConnectionState()!==M.ConnectionState.OPEN&&M.currentUser&&!M.connecting&&!M.reconnecting&&"string"==typeof s&&0===s.indexOf("SB_VIDEOCHAT"))?U.get(M._iid).container.apiClient.sendUserMessage({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),message:r,data:i,customType:s,translationTargetLanguages:_,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedMessageTemplate:d,pushNotificationDeliveryOption:h,rootMessageId:p,parentMessageId:f,appleCriticalAlertOptions:g,pollId:y,isReplyToChannel:v},(function(e,r){var i=null;if(e){if(G._isAutoResendRegistered&&se.isAutoResendableError(e.code))return;(i=new k(F)).requestState=M.MessageRequestState.FAILED,i.requestedMentionUserIds=u,A&&(i._isAutoResendRegistered=A._isAutoResendRegistered),e.code===H.REQUEST_CANCELED?(i.sendingStatus=M.MessageSendingStatus.CANCELED,R.removeUnsentMessages({channelUrl:t.url,sendingStatus:M.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){P.send({source:de.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(new H(e.message,e.code),i)}))):(i.errorCode=e.code,i.sendingStatus=M.MessageSendingStatus.FAILED,w&&se.isAutoResendableError(e.code)&&(i.sendingStatus=M.MessageSendingStatus.PENDING,i.errorCode=0,i._isAutoResendRegistered=!0),R.upsert([i],fe.UNSENT).then((function(){nt._completeCurrentAndProcessNextAutoResend(M,i),P.send({source:de.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){var t=i._clone();t.sendingStatus=M.MessageSendingStatus.FAILED,t.errorCode=e.code,t._isAutoResendRegistered=!1,I&&I(new H(e.message,e.code),t)})))}else{for(var s in(i=new k(r)).reqId=n,i.requestState=M.MessageRequestState.SUCCEEDED,i.sendingStatus=M.MessageSendingStatus.SUCCEEDED,A&&(i._isAutoResendRegistered=A._isAutoResendRegistered),t.lastMessage=i,M.channelHandlers){M.channelHandlers[s].onChannelChanged(t)}L.upsert([t]).then((function(){P.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return R.removeUnsentMessages({channelUrl:t.url,sendingStatus:M.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return R.upsert([i],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(M,i),P.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(null,i)}))}})):M.sendCommand(e,(function(r,i){if(M.getErrorFirstCallback()){var s=[r,i];i=s[0],r=s[1]}if(i){if(G._isAutoResendRegistered&&se.isAutoResendableError(i.code))return;var a=new k(F);a.reqId=e.requestId,a.requestState=M.MessageRequestState.FAILED,i.code===H.REQUEST_CANCELED?(a.sendingStatus=M.MessageSendingStatus.CANCELED,t.isGroupChannel()&&R.removeUnsentMessages({channelUrl:t.url,sendingStatus:M.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){P.send({source:de.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:a}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(new H(i.message,i.code),a)}))):(a.sendingStatus=M.MessageSendingStatus.FAILED,a.errorCode=i.code,a.requestedMentionUserIds=u,t.isGroupChannel()?(w&&se.isAutoResendableError(i.code)&&(a.sendingStatus=M.MessageSendingStatus.PENDING,a.errorCode=0,a._isAutoResendRegistered=!0),R.upsert([a],fe.UNSENT).then((function(){return nt._completeCurrentAndProcessNextAutoResend(M,a),P.send({source:de.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:a}})})).catch((function(e){J.error(e)})).finally((function(){var e=a._clone();e.sendingStatus=M.MessageSendingStatus.FAILED,e.errorCode=i.code,e._isAutoResendRegistered=!1,I&&I(new H(i.message,i.code),e)}))):I&&I(new H(i.message,i.code),a))}else{var o=new k(l(l({},r.getJsonElement()),{},{messageParams:b}));o.reqId=n,o.requestState=M.MessageRequestState.SUCCEEDED,o.sendingStatus=M.MessageSendingStatus.SUCCEEDED,A&&(o._isAutoResendRegistered=A._isAutoResendRegistered);var c=M.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),se.deepEqual(c.metaData,o._sender.metaData)||(c.metaData=o._sender.metaData)),t.isGroupChannel()){t.lastMessage=o,Object.keys(M.channelHandlers).forEach((function(e){M.channelHandlers[e].onChannelChanged(t)}));var d=ge.of(t._iid);bt.of(t._iid).upsert([t]).then((function(){d.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return R.removeUnsentMessages({channelUrl:t.url,sendingStatus:M.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return R.upsert([o],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(M,o),d.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:t,message:o}})})).catch((function(e){J.error(e)})).finally((function(){I&&I(null,o)}))}else I&&I(null,o)}}))})),G}},{key:"sendUserMessage",value:function(){var e=me.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=me.error}else n=me.error;else n=me.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,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,messageParams:r,callback:function(e,n){o?t(e,n):t(n,e)}})):(o?t(me.error,null):t(null,me.error),null)}},{key:"_autoResendUserMessage",value:function(e){var t=this,n=ji.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=ji.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=me.parse(arguments,[new me({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 me({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=me.parse(d,[new me({type:"number"}),new me({type:c}),new me({type:"callback"})]),_=C(f,4);h=_[0],e=_[1],p=_[2],i=_[3];break;case 5:p=new c;var g=me.parse(d,[new me({type:"number"}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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,mentionedMessageTemplate:p.mentionedMessageTemplate})),r=ji.getInstance(s._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}var a=null;if(!n&&(a=new u(l(l({},e.getJsonElement()),{},{messageParams:p})),s.isGroupChannel())){var o=!1;s.lastMessage?(s.lastMessage.createdAt=0}}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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=se.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=me.error;return se.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,n=ji.getInstance(this._iid),r=x.get(this._iid),i=r.Command,s=r.FileMessage,a=l(l({},e),{},{messageId:0,reqId:null!==(t=e.reqId)&&void 0!==t?t:i.generateRequestId(),user:n.currentUser||{},channel:this,plainUrl:"string"==typeof e.file?e.file:"",thumbnails:e.thumbnailSizes.map((function(e){return{url:"",plainUrl:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}})),sendingStatus:n.MessageSendingStatus.PENDING,createdAt:(new Date).getTime()}),o=s.objectify(a);return new s(o)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this,t=me.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=ji.getInstance(this._iid);if(o&&o.currentUser||(n.error=new H("Connection should be made first.",H.CONNECTION_REQUIRED)),this.isGroupChannel()){var l=Ge.of(this._iid),u=ge.of(this._iid);l.upsert([s],fe.UNSENT).then((function(){u.send({source:de.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(me.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=me.parse(arguments,[new me({type:s,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===r.url&&Array.isArray(e.thumbnails)}}),new me({type:"file",optionalIf:function(e){var t,n,r=!!e[0].plainUrl,i=se.isFile(null===(t=e[0])||void 0===t||null===(n=t.messageParams)||void 0===n?void 0:n.file);return r||i},defaultValue:null}),new me({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,s=new a;s._reqId=e.reqId,e.plainUrl?s.fileUrl=e.plainUrl:t?s.file=t:se.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)&&(s.file=e.messageParams.file),s.fileName=e.name,s.fileSize=e.size,s.mimeType=e.type,s.data=e.data,s.customType=e.customType,s.mentionType=e.mentionType,s.mentionedUserIds=e.requestedMentionUserIds,s.metaArrays=e.metaArrays,s.thumbnailSizes=e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),s.appleCriticalAlertOptions=e.appleCriticalAlertOptions,r.sendFileMessage(s,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=me.parse(c,[new me({type:"number"}),new me({type:u}),new me({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 _=me.parse(c,[new me({type:"number"}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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=ji.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=!1;i.lastMessage?(i.lastMessage.createdAt0}}),new me({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=ji.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=me.parse(arguments,[new me({type:Tt}),new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new me({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=Ge.of(n._iid),a=ge.of(n._iid);s.remove([e.messageId],fe.SUCCEEDED).then((function(){a.send({source:de.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=me.parse(arguments,[new me({type:e}),new me({type:s}),new me({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(me.error,null):r(null,me.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);f.forEach((function(e){return""}));var _=a.PushNotificationDeliveryOption.DEFAULT;return t._sendUserMessage(l(l({},n),{},{reqId:null,pushNotificationDeliveryOption:_,translationTargetLanguages:f,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=me.parse(arguments,[new me({type:e}),new me({type:o}),new me({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(me.error,null):r(null,me.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=ji.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,M=y.requireAuth,R=y.messageSurvivalSeconds,L=y.silent,P=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:M,messageSurvivalSeconds:R,silent:L,createdAt:(new Date).getTime(),appleCriticalAlertOptions:P}),q=new o(V);if(q.requestState=g.MessageRequestState.PENDING,q.sendingStatus=g.MessageSendingStatus.PENDING,!g.currentUser){var K=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=K.code,f?r(K,z):r(z,K),q}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:M,pushNotificationDeliveryOption:B,silent:L,appleCriticalAlertOptions:P});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=ge.of(i._iid);bt.of(i._iid).upsert([t]).then((function(){c.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).catch((function(e){J.error(e)})),Ge.of(i._iid).upsert([l]).then((function(){c.send({source:de.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:M,pushNotificationDeliveryOption:B,appleCriticalAlertOptions:P},(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)}})),q}},{key:"addOperators",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({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 me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({type:"string"}),new me({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=kt.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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,r){if(r&&r.ts){var i=r.metadata;n._addOrUpdateCachedMetaData(i,r.ts),t(e,i)}else t(e,r)}))}),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(n,r){if(r&&r.ts){var i=r.metadata;t._refreshMetaData(i,r.ts),e(n,i)}else e(n,r)}))}),e)}},{key:"createMetaData",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=ji.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(me.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=me.parse(arguments,[new me({type:Tt}),new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new me({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 me({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=me.parse(arguments,[new me({type:Tt}),new me({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 me({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=me.parse(arguments,[new me({type:s.ReportCategory}),new me({type:"string"}),new me({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=ji.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=me.parse(arguments,[new me({type:Ot}),new me({type:a.ReportCategory}),new me({type:"string"}),new me({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=ji.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=me.parse(arguments,[new me({type:Tt}),new me({type:a.ReportCategory}),new me({type:"string"}),new me({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=ji.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}(),Lt=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):Rt.CHANNEL_TYPE_GROUP,this.channel=t.hasOwnProperty("channel")?t.channel:null)}return h(e,[{key:"isGroupChannel",value:function(){return this.channelType===Rt.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===Rt.CHANNEL_TYPE_OPEN}}]),e}();Lt.CATEGORY_NONE=0,Lt.CATEGORY_CHANNEL_ENTER=10102,Lt.CATEGORY_CHANNEL_EXIT=10103,Lt.CATEGORY_USER_CHANNEL_MUTE=10201,Lt.CATEGORY_USER_CHANNEL_UNMUTE=10200,Lt.CATEGORY_USER_CHANNEL_BAN=10601,Lt.CATEGORY_USER_CHANNEL_UNBAN=10600,Lt.CATEGORY_CHANNEL_FREEZE=10701,Lt.CATEGORY_CHANNEL_UNFREEZE=10700,Lt.CATEGORY_TYPING_START=10900,Lt.CATEGORY_TYPING_END=10901,Lt.CATEGORY_CHANNEL_JOIN=1e4,Lt.CATEGORY_CHANNEL_LEAVE=10001,Lt.CATEGORY_CHANNEL_OPERATOR_UPDATE=10002,Lt.CATEGORY_CHANNEL_INVITE=10020,Lt.CATEGORY_CHANNEL_DECLINE_INVITE=10022,Lt.CATEGORY_CHANNEL_PROP_CHANGED=11e3,Lt.CATEGORY_CHANNEL_DELETED=12e3,Lt.CATEGORY_CHANNEL_META_DATA_CHANGED=11100,Lt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED=11200,Lt.CATEGORY_CHANNEL_HIDE=13e3,Lt.CATEGORY_CHANNEL_UNHIDE=13001;var Pt=h((function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0)}));Pt.CATEGORY_USER_BLOCK=20001,Pt.CATEGORY_USER_UNBLOCK=2e4,Pt.CATEGORY_FRIEND_DISCOVERED=20900;var wt=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,M=A.ackStateMap,R=new r(e),L=R.getJsonElement();if(L.hasOwnProperty("unread_cnt")&&"object"===u(L.unread_cnt)){var P=!1,w=L.unread_cnt.ts;"number"==typeof w&&w>O.ts&&(O.all!==L.unread_cnt.all&&(P=!0),O.all=L.unread_cnt.all>=0?L.unread_cnt.all:0,L.unread_cnt.custom_types&&Object.keys(L.unread_cnt.custom_types).forEach((function(e){O.custom_types[e]!==L.unread_cnt.custom_types[e]&&(P=!0),O.custom_types[e]=L.unread_cnt.custom_types[e]})),P=P&&O.ts>0,O.ts=w),P&&Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onTotalUnreadMessageCountUpdated(O.all,O.custom_types)}))}var D=R.requestId;if(D){var F=M[D];if(F){clearTimeout(F.timer);var G=F.handler;G&&("EROR"===R.command?G(new H(L.message,L.code),null):G(null,R)),M.hasOwnProperty(D)&&delete M[D]}}else{N&&"LOGI"!==R.command&&N.refreshTimer();var x,j=bt.of(this.sb._iid),B=Ge.of(this.sb._iid),V=ge.of(this.sb._iid);switch(R.command){case"LOGI":if(this.sb.loginTimer)if(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,L.hasOwnProperty("error"))this.sb.isSessionOpened=!1,this.sb.loginHandler(new H(L.message,L.code),null);else{if(this.sb.isSessionOpened=!0,L.hasOwnProperty("key")&&(S.sessionKey=L.key),L.hasOwnProperty("ekey")&&(S.eKey=L.ekey),L.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(L)),"number"==typeof L.ping_interval&&L.ping_interval>0&&C.set("pingInterval",1e3*L.ping_interval),"number"==typeof L.pong_timeout&&L.pong_timeout>0&&C.set("pongTimeout",1e3*L.pong_timeout),"number"==typeof L.login_ts){var q=1e3*L.login_ts;C.set("connectedAt",q);var K=C.container,z=K.firstConnectedAt,Y=K.localCacheEnabled,Q=K.store;if(!z){var W=q;if(Y){var X=(x=this.sb.currentUser.userId,"sendbird:".concat(x,"@firstConnectedAt"));Q.get(X).then((function(e){e&&(W=e.ts)})).catch((function(e){t.handleCacheError(e)})).finally((function(){C.set("firstConnectedAt",W)}))}else C.set("firstConnectedAt",W)}}if(L.hasOwnProperty("reconnect")&&"object"===u(L.reconnect)){var Z=L.reconnect,$=C.container.wsAdapter;Z.hasOwnProperty("interval")&&"number"==typeof Z.interval&&($.reconnectParams.interval=Z.interval),Z.hasOwnProperty("max_interval")&&"number"==typeof Z.max_interval&&($.reconnectParams.maxInterval=Z.max_interval),Z.hasOwnProperty("mul")&&"number"==typeof Z.mul&&($.reconnectParams.multiplier=Z.mul),Z.hasOwnProperty("retry_cnt")&&"number"==typeof Z.retry_cnt&&($.reconnectParams.retryCount=Z.retry_cnt)}"number"==typeof L.max_unread_cnt_on_super_group?C.set("maxUnreadCountOfSuperGroupChannel",L.max_unread_cnt_on_super_group):C.set("maxUnreadCountOfSuperGroupChannel",T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),L.profile_image_encryption&&C.set("profileImageEncryption",!0),N&&N.start(),L.hasOwnProperty("file_upload_size_limit")&&L.hasOwnProperty("premium_feature_list")&&L.hasOwnProperty("emoji_hash")&&C.set("appInfo",new Ie(L)),L.hasOwnProperty("concurrent_call_limit")&&L.hasOwnProperty("back_off_delay")&&(C.set("concurrentCallLimit",L.concurrent_call_limit),C.set("backOffDelay",L.back_off_delay)),this.sb.loginHandler(null,this.sb.currentUser)}break;case"EXPR":var ee=new H("The session would be expired.",L.reason||H.SESSION_KEY_EXPIRED);k.refreshSessionIfExpiredError(ee).then((function(){})).catch((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var te=null;if("MESG"===R.command?te=new h(L):"FILE"===R.command?te=new p(L):"BRDM"!==R.command&&"ADMM"!==R.command||(te=new f(L)),te){var ne=this.sb.currentUser?this.sb.currentUser.userId:null,re=te.silent,ie=!!L.force_update_last_message,ae=te._sender&&te._sender.userId===ne;if(te.isGroupChannel()){var oe=c.cachedChannels.hasOwnProperty(te.channelUrl);c.getChannel(te.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:te.channelUrl,messageId:te.messageId});t.sb.sendCommand(s)}if(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,te._sender&&e.memberMap.hasOwnProperty(te._sender.userId)){var a=e.memberMap[te._sender.userId];a.nickname!==te._sender.nickname&&(a.nickname=te._sender.nickname),a.plainProfileUrl!==te._sender.plainProfileUrl&&(a.plainProfileUrl=te._sender.plainProfileUrl),se.deepEqual(a.metaData,te._sender.metaData)||(a.metaData=te._sender.metaData),a.isBlockedByMe!==te._sender.isBlockedByMe&&(a.isBlockedByMe=te._sender.isBlockedByMe)}var o=t.sb.currentUser;o&&ae&&(o.nickname!==te._sender.nickname&&(o.nickname=te._sender.nickname),o.plainProfileUrl!==te._sender.plainProfileUrl&&(o.plainProfileUrl=te._sender.plainProfileUrl),se.deepEqual(o.metaData,te._sender.metaData)||(o.metaData=te._sender.metaData));var l=!1;if(te.mentionType===_.MentionType.CHANNEL)ae||(l=!0);else if(te.mentionType===_.MentionType.USERS)for(var u=0;u=le.createAt,a=t.sb.currentUser;a&&he&&(a.nickname!==le._sender.nickname&&(a.nickname=le._sender.nickname),a.plainProfileUrl!==le._sender.plainProfileUrl&&(a.plainProfileUrl=le._sender.plainProfileUrl),se.deepEqual(a.metaData,le._sender.metaData)||(a.metaData=le._sender.metaData));var o=!1,l=!1;if(!he&&!s&&L&&L.hasOwnProperty("old_values")){var u=L.old_values.mention_type||le.mentionType,c=L.old_values.mentioned_user_ids||le.mentionedUsers.map((function(e){return e.userId}));if(u===_.MentionType.USERS&&le.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)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.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:de.EVENT_READ_RECEIPT_UPDATED,payload:{channel:e,user:me.reader}})))}));break;case"MRCT":var ve=String(L.channel_type),be=String(L.channel_url),Ce=g.createFromJson(L);switch(ve){case o.CHANNEL_TYPE_GROUP:c.getChannel(be,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(R.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,Ce)})),B.get("".concat(Ce.messageId)).then((function(n){n&&(n.applyReactionEvent(Ce),B.upsert([n]).then((function(){V.send({source:de.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:Ce}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(be,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(R.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,Ce)})),V.send({source:de.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:Ce}}))}))}break;case"DLVR":var Ae=String(L.channel_url),Ne=L.hasOwnProperty("updated")?L.updated:null,Se=c.cachedChannels.hasOwnProperty(Ae);c.getChannel(Ae,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(Ne).forEach((function(n){t.sb.currentUser&&n===t.sb.currentUser.userId&&(i=!0),Se&&e.updateDeliveryReceipt(n,parseInt(Ne[n]))})),c.cachedChannels[e.url]=e,i&&1===Object.keys(Ne).length||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onDeliveryReceiptUpdated(e)})),V.send({source:de.EVENT_DELIVERY_RECEIPT_UPDATED,payload:{channel:e}}))}}));break;case"MTHD":var Te=String(L.channel_url),Oe=String(L.channel_type),Ue=m.createFromJson(L);switch(Oe){case o.CHANNEL_TYPE_GROUP:c.getChannel(Te,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,Ue)})),B.get("".concat(Ue.targetMessageId)).then((function(n){n&&(n.applyThreadInfoUpdateEvent(Ue),B.upsert([n]).then((function(){V.send({source:de.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:Ue}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(Te,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,Ue)})),V.send({source:de.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:Ue}}))}))}break;case"MCNT":if(L.hasOwnProperty("group_channels")&&Array.isArray(L.group_channels)){var ke,Me=[],Re=I(L.group_channels);try{for(Re.s();!(ke=Re.n()).done;){var Le=ke.value;if(Le){var Pe=c.cachedChannels[Le.channel_url];if(Pe&&Pe.isBroadcast)Pe.setLatestMemberCount(Le.member_count,Le.joined_member_count,Le.ts)&&Me.push(Pe)}}}catch(e){Re.e(e)}finally{Re.f()}Me.length>0&&(Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelMemberCountChanged(Me)})),j.upsert(Me).then((function(){var e,t=I(Me);try{for(t.s();!(e=t.n()).done;){var n=e.value;V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:n}})}}catch(e){t.e(e)}finally{t.f()}})).catch((function(e){t.handleCacheError(e)})))}if(L.hasOwnProperty("open_channels")&&Array.isArray(L.open_channels)){var we,De=[],He=I(L.open_channels);try{for(He.s();!(we=He.n()).done;){var Fe=we.value;if(Fe){var xe=d.cachedChannels[Fe.channel_url];if(xe)xe.setLatestParticipantCount(Fe.participant_count,Fe.ts)&&De.push(xe)}}}catch(e){He.e(e)}finally{He.f()}if(De.length>0){Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelParticipantCountChanged(De)}));var je,Be=I(De);try{for(Be.s();!(je=Be.n()).done;){var Ve=je.value;V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:Ve}})}}catch(e){Be.e(e)}finally{Be.f()}}}break;case"PEDI":var qe=E.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollUpdated(qe)}));break;case"VOTE":var Ke=v.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollVoted(Ke)}));break;case"SYEV":var ze=new Lt(L),Ye=L.ts;switch(ze.category){case Lt.CATEGORY_CHANNEL_JOIN:case Lt.CATEGORY_CHANNEL_LEAVE:c.getChannel(ze.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(R.command,"`"),ze.category);else{var a=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,o=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null,l=!1;if(ze.category===Lt.CATEGORY_CHANNEL_JOIN){(ze.data.hasOwnProperty("users")?ze.data.users:[ze.data]).forEach((function(n){e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,L.ts):(n.state=s.JOINED,e.addMember(new s(n),Ye),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])})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_JOINED,payload:{channel:e,user:r}})})).catch((function(e){t.handleCacheError(e)}))}))}else{var u=new i(ze.data);if(t.sb.currentUser&&u.userId===t.sb.currentUser.userId?(e.isPublic||c.removeCachedChannel(ze.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,L.ts);else C.container.appInfo.enabledChannelMemberShipHistory?(e.memberMap[u.userId].state=c.MemberStateFilter.LEFT,e.memberCount=ze.data.member_count):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])})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_LEFT,payload:{channel:e,user:u}})})).catch((function(e){t.handleCacheError(e)}))}}}));break;case Lt.CATEGORY_CHANNEL_OPERATOR_UPDATE:ze.isGroupChannel()?c.getChannel(ze.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(R.command,"`"),ze.category);else{for(var s=ze.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:s}})})).catch((function(e){t.handleCacheError(e)}))}})):ze.isOpenChannel()&&d.getChannel(ze.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(R.command,"`"),ze.category):(e.operators=ze.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)})))}));break;case Lt.CATEGORY_CHANNEL_INVITE:c.getChannel(ze.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(R.command,"`"),ze.category);else{var a=null;ze.data&&ze.data.inviter&&Object.keys(ze.data.inviter).length>0&&(a=new i(ze.data.inviter));for(var o=[],l=0;l0&&(s=new i(ze.data.inviter));var a=new i(ze.data.invitee);if(t.sb.currentUser&&a.userId===t.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||c.removeCachedChannel(ze.channelUrl)),e.isSuper||e.isBroadcast){var o=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,l=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null;e.setLatestMemberCount(o,l,L.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_DECLINED_INVITATION,payload:{channel:e,inviter:s,invitee:a}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_TYPING_START:case Lt.CATEGORY_TYPING_END:c.getChannel(ze.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(R.command,"`"),ze.category);else{var s=new i(ze.data);ze.category===Lt.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_TYPING_STATUS_UPDATED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_CHANNEL_ENTER:case Lt.CATEGORY_CHANNEL_EXIT:d.getChannel(ze.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(R.command,"`"),ze.category);else{var s=ze.data.hasOwnProperty("participant_count")?ze.data.participant_count:null,a=e.setLatestParticipantCount(s,L.ts),o=new i(ze.data);ze.category===Lt.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:de.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:de.EVENT_CHANNEL_EXIT,payload:{channel:e,user:o}}))}}));break;case Lt.CATEGORY_USER_CHANNEL_MUTE:case Lt.CATEGORY_USER_CHANNEL_UNMUTE:var Qe=ze.category===Lt.CATEGORY_USER_CHANNEL_MUTE,We=l({},ze.data);Qe&&(We.restriction_type=a.RestrictionType.MUTED);var Je=Qe?new a(We):new i(ze.data),Xe=Qe?"muted":"unmuted";ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category):Qe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,Je)})),V.send({source:de.EVENT_USER_MUTED,payload:{channel:e,user:Je}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,Je)})),V.send({source:de.EVENT_USER_UNMUTED,payload:{channel:e,user:Je}}))})):c.getChannel(ze.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(R.command,"`"),ze.category):(t.sb.currentUser&&Je.userId===t.sb.currentUser.userId&&(e.myMutedState=Xe),Array.isArray(e.members)&&e.members.filter((function(e){return e&&e.userId===Je.userId})).forEach((function(e){e.isMuted=Qe,e.restrictionInfo=new b(We)})),Qe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,Je)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_MUTED,payload:{channel:e,user:Je}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,Je)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_UNMUTED,payload:{channel:e,user:Je}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Lt.CATEGORY_USER_CHANNEL_BAN:case Lt.CATEGORY_USER_CHANNEL_UNBAN:var Ze=ze.category===Lt.CATEGORY_USER_CHANNEL_BAN,$e=l({},ze.data);Ze&&($e.restriction_type=a.RestrictionType.BANNED);var et=Ze?new a($e):new i(ze.data);ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category);else if(Ze){if(t.sb.currentUser&&et.userId===t.sb.currentUser.userId)delete d.enteredChannels[ze.channelUrl],t.cls.FileMessageQueue.delete(ze.channelUrl);Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,et)})),V.send({source:de.EVENT_USER_BANNED,payload:{channel:e,user:et}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,et)})),V.send({source:de.EVENT_USER_UNBANNED,payload:{channel:e,user:et}})})):c.getChannel(ze.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(R.command,"`"),ze.category);else if(Ze){if(t.sb.currentUser&&et.userId===t.sb.currentUser.userId&&(e.isPublic||c.removeCachedChannel(ze.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var i=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,s=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null;e.setLatestMemberCount(i,s,L.ts)}else e.removeMember(et),e.updateJoinedMemberCount();Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,et)})),V.send({source:de.EVENT_USER_BANNED,payload:{channel:e,user:et}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,et)})),V.send({source:de.EVENT_USER_UNBANNED,payload:{channel:e,user:et}})}));break;case Lt.CATEGORY_CHANNEL_FREEZE:case Lt.CATEGORY_CHANNEL_UNFREEZE:ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category):(e.isFrozen=ze.data.freeze,d.cachedChannels[e.url]=e,ze.category===Lt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),V.send({source:de.EVENT_CHANNEL_FROZEN,payload:{channel:e}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),V.send({source:de.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})))})):c.getChannel(ze.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(R.command,"`"),ze.category):(e.isFrozen=ze.data.freeze,c.cachedChannels[e.url]=e,ze.category===Lt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Lt.CATEGORY_CHANNEL_DELETED:ze.isGroupChannel()?c.removeCachedChannel(ze.channelUrl):d.removeCachedChannel(ze.channelUrl);var tt=ze.channelUrl,nt=ze.isGroupChannel()?"group":"open";Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelDeleted(tt,nt)})),j.remove([tt]).then((function(){V.send({source:de.EVENT_CHANNEL_DELETED,payload:{channelUrl:tt,channelType:nt}})})).catch((function(e){t.handleCacheError(e)}));break;case Lt.CATEGORY_CHANNEL_PROP_CHANGED:ze.isOpenChannel()?d.getChannelWithoutCache(ze.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(R.command,"`"),ze.category):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:e}}))})):c.getChannelWithoutCache(ze.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(R.command,"`"),ze.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_CHANNEL_META_DATA_CHANGED:case Lt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var rt=ze.data.hasOwnProperty("created"),it=ze.data.hasOwnProperty("updated"),st=ze.data.hasOwnProperty("deleted");(ze.isOpenChannel()?d.getChannel(ze.channelUrl,T.INTERNAL_CALL):c.getChannel(ze.channelUrl,T.INTERNAL_CALL)).then((function(e){var n=ze.data.created,r=ze.data.updated,i=ze.data.deleted;Object.keys(t.sb.channelHandlers).forEach((function(s){var a=t.sb.channelHandlers[s];if(ze.category===Lt.CATEGORY_CHANNEL_META_DATA_CHANGED){var o=L.ts;rt&&e._addOrUpdateCachedMetaData(n,o),it&&e._addOrUpdateCachedMetaData(r,o),st&&e._markAsDeletedCachedMetaData(i,o),rt&&a.onMetaDataCreated(e,n),it&&a.onMetaDataUpdated(e,r),st&&a.onMetaDataDeleted(e,i),(rt||it)&&V.send({source:de.EVENT_CHANNEL_METADATA_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),st&&V.send({source:de.EVENT_CHANNEL_METADATA_DELETED,payload:{channel:e,metaData:l({},i)}})}else rt&&a.onMetaCountersCreated(e,n),it&&a.onMetaCountersUpdated(e,r),st&&a.onMetaCountersDeleted(e,i),(rt||it)&&V.send({source:de.EVENT_CHANNEL_METACOUNTER_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),st&&V.send({source:de.EVENT_CHANNEL_METACOUNTER_DELETED,payload:{channel:e,metaData:l({},i)}})}))})).catch((function(e){return J.debug("Discard command:","`".concat(R.command,"`"),ze.category)}));break;case Lt.CATEGORY_CHANNEL_HIDE:case Lt.CATEGORY_CHANNEL_UNHIDE:c.getChannel(ze.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(R.command,"`"),ze.category):ze.category===Lt.CATEGORY_CHANNEL_HIDE?(e.isHidden=!0,ze.data&&(ze.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=ze.data.allow_auto_unhide?c.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:c.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),ze.data.hasOwnProperty("hide_previous_messages")&&ze.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),L.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=L.ts_message_offset),c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelHidden(e)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_UNHIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)})))}))}break;case"USEV":var at=new Lt(L);switch(at.category){case Pt.CATEGORY_USER_BLOCK:case Pt.CATEGORY_USER_UNBLOCK:var ot=at.data.blocker.user_id,lt=at.data.blockee.user_id;Object.keys(c.cachedChannels).forEach((function(e){var n=c.cachedChannels[e];try{t.sb.currentUser&&(t.sb.currentUser.userId===ot?n.memberMap[lt].isBlockedByMe=at.category===Pt.CATEGORY_USER_BLOCK:t.sb.currentUser.userId===lt&&(n.memberMap[ot].isBlockingMe=at.category===Pt.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Pt.CATEGORY_FRIEND_DISCOVERED:var ut=at.data.friend_discoveries.map((function(e){return new i(e)}));Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onFriendsDiscovered(ut)}))}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:J.debug("Discard command:","`".concat(R.command,"`"))}}}},{key:"handleCacheError",value:function(e){J.error(e)}}]),e}(),Dt=200,Ht={},Ft={},Gt=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(r.state=n.State.SENDING,navigator&&"boolean"==typeof navigator.onLine)if(navigator.onLine){for(0===this.latestTimestampToSendMessage&&(this.latestTimestampToSendMessage=(new Date).getTime()-Dt);(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.error.code===H.REQUEST_FAILED&&(t.error=new H("Failed to upload a file.",H.NETWORK_ERROR)),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)):Je.ready().then((function(e){e?n._uploadFile(t,(function(e){t.error&&t.error.code===H.REQUEST_FAILED&&(t.error=new H("Failed to upload a file.",H.NETWORK_ERROR)),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=ji.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=ji.getInstance(this._iid),s=bt.of(this._iid),a=Ge.of(this._iid),o=ge.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:de.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],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||r?f(null,d):f(d,null)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}if(h){if(d&&d._isAutoResendRegistered&&se.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:de.LOCAL_MESSAGE_CANCELED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||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:de.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")})):(n&&se.isAutoResendableError(h.code)&&(d.sendingStatus=i.MessageSendingStatus.PENDING,d.errorCode=0,d._isAutoResendRegistered=!0),a.upsert([d],fe.UNSENT).then((function(){nt._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:de.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&&(f.isPromisifyCallback||r?f(p,t):f(t,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))))}f&&(f.isPromisifyCallback||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(){Ft[this._iid]={}}},{key:"queueMap",get:function(){return Ft[this._iid]||(Ft[this._iid]={}),Ft[this._iid]}},{key:"uploadRequest",get:function(){return Ht[this._iid]||(Ht[this._iid]={}),Ht[this._iid]}}]),e}();Gt.Job=function(){return h((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||Gt.State.PENDING,this.error=o,this.response=u}))}();var xt,jt={},Bt=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,f=e.disableLogger,_=void 0!==f&&f;return jt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=d,this.transactionApplyDelay=p,this.disableLogger=_,jt[t]=this),jt[t]}return e.get=function(e){return jt[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_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",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"}(xt||(xt={}));var Vt,qt=function(e){function t(n){var r=n.code,i=void 0===r?xt.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return M(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:xt.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:xt.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:xt.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:xt.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:xt.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:xt.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:xt.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,"storeEncryptionInvalid",{get:function(){return new t({code:xt.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:xt.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:xt.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:xt.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:xt.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:xt.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:xt.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:xt.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:xt.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:xt.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:xt.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:xt.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:xt.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:xt.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:xt.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:xt.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:xt.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"}(Vt||(Vt={}));var Kt,zt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw qt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return zt(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]=zt(e[r],t);return t.delete(e),n}return e},Yt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw qt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Qt=function(e,t){for(var n=0,r=0;r>>0)%t},Wt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Jt=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!Jt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Jt(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(!(Yt(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Yt(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Yt(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Yt(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)},Xt=function(){},Zt=function(){return Promise.resolve()},$t=function(e){return e},en=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Kt||(Kt={}));var tn,nn,rn,sn=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?$t:a,l=e.backward,u=void 0===l?Zt:l,c=e.forward,d=void 0===c?Zt:c,h=e.complete,p=void 0===h?Xt: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 L(this,void 0,void 0,(function(){var e,t,n;return P(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 L(this,void 0,void 0,(function(){var e,t,n;return P(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}(),an=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*Yt(this._indexer.origin[u].columnValues[i],this.condition[s][l])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*Yt(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===rn.PERSISTENT&&(r.state=nn.PERSISTENT),t!==rn.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)_n.includes(this._items[t].state)&&_n.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===nn.VOLATILE})),r=n.length-this._limit;if(r>0){for(var i=[],s=0,a=this._items;s0?r--:i.push(o)}this._items=i}}}},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!==nn.VOLATILE}))},e}(),mn=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(un(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(un(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=[]),L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c;return P(this,(function(d){switch(d.label){case 0:n=yn.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 R(R({},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=yn.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=En.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 L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return n=Bt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,yn.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(a=s?En.createFromCacheItem(s):new En({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 L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return e=dn(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=yn.get(this.dbname),i=0,s=n;i")),this._transaction=s,this._store=a,this._transaction.on(tn.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(tn.ERROR,this.indexerKey,(function(){return o.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 L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d;return P(this,(function(h){switch(h.label){case 0:return[4,(e=yn.get(this.dbname)).find(this._store,this.indexerKey,rn.PERSISTENT)];case 1:return(t=h.sent())?[3,7]:(n=dn(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),i=0,s=r,h.label=3;case 3:return i-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Sn.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))},e.prototype._sendSync=function(){var e;this.isHost&&this._send(Sn.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return L(this,void 0,void 0,(function(){var e=this;return P(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=Nn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Sn.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Sn.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return L(this,void 0,void 0,(function(){var e;return P(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Sn.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),Mn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Vt.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=w([[r]],s.filter((function(e){return bn.createKey(e)!==o.keyName})),!0),this._keyHash=i,this._store=a,this._mutex=new kn(function(e,t){return"".concat(un(e,t),".lock")}(t,n)),this._blobContainer=new fn({dbname:t,collectionName:n,store:a}),this._transaction=new mn({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return L(this,void 0,void 0,(function(){var r;return P(this,(function(i){switch(i.label){case 0:return r=cn(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 L(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p=this;return P(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=Bt.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 vn({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 bn.createKey(e)})),a=n?n.indexes.map((function(e){return bn.createKey(e)})):[],o=0,l=a;o0&&!r.some((function(t){switch(t){case qn.CHANNEL_NAME:return e.name.toLowerCase().includes(n.toLowerCase());case qn.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 Vn.AND:if(o.some((function(e){return!u.includes(e)})))return!1;break;case Vn.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.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var h=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!==h})))return!1}if(this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){case Kn.JOINED:if("joined"!==e.myMemberState)return!1;break;case Kn.INVITED:if("invited"!==e.myMemberState)return!1;break;case Kn.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Kn.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Wn.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Wn.HIDDEN:if(!e.isHidden)return!1;break;case Wn.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Wn.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Qn.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Yn.PUBLIC:if(!e.isPublic||"none"===e.myMemberState)return!1;break;case Yn.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case zn.SUPER:if(!e.isSuper)return!1;break;case zn.NON_SUPER:if(e.isSuper)return!1}return!0},e.QueryType=Vn,e.SearchField=qn,e.MemberStateFilter=Kn,e.SuperChannelFilter=zn,e.PublicChannelFilter=Yn,e.UnreadChannelFilter=Qn,e.HiddenChannelFilter=Wn,e}(),$n=function(){function e(e){var t=e.iid;this._iid=t,this._filter=new Zn,this._filter.iid=this._iid,this._order=ot.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 Et({iid:this._iid,filter:this._filter,order:this._order,limit:this._limit})},e}(),er=function(){function e(e){var t=e.iid,n=e.channel;this._iid=t,this._channel=n,this._startingPoint=Date.now(),this._filter=new Re,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 nt({iid:this._iid,channel:this._channel,startingPoint:this._startingPoint,filter:this._filter,limit:this._limit})},e}(),tr={},nr={},rr=new WeakMap,ir=new WeakMap,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=Rt.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},rr.set(y(r),{}),ir.set(y(r),{start:0,end:0}),sr.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 er({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 me({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){return e(me.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string",optional:!0,defaultValue:""}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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>=sr.get(this)&&(sr.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=me.parse(arguments,[new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!0}),new me({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=ji.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=bt.of(t._iid),o=ge.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:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}}),o.send({source:de.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 Tt&&!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=ji.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof Tt&&!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=ji.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof Tt&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],n=ji.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=ir.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=ji.getInstance(this._iid),t=(new Date).getTime(),n=e.Options.typingIndicatorThrottle;("number"!=typeof n||n<1e3||n>9e3)&&(n=1e3);var r=ir.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=rr.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=rr.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=rr.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=rr.get(this);t?n[e.userId]={user:e,ts:(new Date).getTime()}:delete n[e.userId]}},{key:"isTyping",value:function(){var e=rr.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=me.parse(arguments,[new me({type:s,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new me({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=ji.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=me.parse(arguments,[new me({type:i.PushTriggerOption}),new me({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=me.parse(arguments,[new me({type:i.CountPreference}),new me({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",LEFT:"left"}}},{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{ALL:"all",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 tr[this._iid]||(tr[this._iid]={}),tr[this._iid]}},{key:"createGroupChannelCollection",value:function(){return new $n({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=Nt.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,metadata:d.metadata,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(){tr[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.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(me.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(me.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}return oe(this._iid,(function(e){return e(me.error,null)}),n)}},{key:"createChannelWithUserIds",value:function(){var e=me.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(me.error,null)}),t)}return t?r.createChannel(s,t):r.createChannel(s)}},{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 nr[this._iid]||0},set:function(e){nr[this._iid]=e}},{key:"getChannelCount",value:function(e,t){return ji.getInstance(this._iid).getGroupChannelCount(e,t)}},{key:"getUnreadItemCount",value:function(e,t){return ji.getInstance(this._iid).getUnreadItemCount(e,t)}},{key:"getTotalUnreadMessageCount",value:function(){var e=me.toArray(arguments),t="function"==typeof e[e.length-1]?e.pop():null,n=ji.getInstance(this._iid);return n.getTotalUnreadMessageCount.apply(n,A(e).concat([t]))}},{key:"getTotalUnreadChannelCount",value:function(e){return ji.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),n}(Rt),or=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 M(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=Nt.deserialize(e);return new t(t.objectify(R({},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||ar.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}),Object.defineProperty(t,"LEFT",{get:function(){return"left"},enumerable:!1,configurable:!0}),t}(Ot),lr=function(e){function t(t){var n=e.call(this,t)||this;return n.role="",n.isBlockedByMe=!1,t&&n._update(t),n}return M(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=Nt.deserialize(e);return new t(t.objectify(R({},n)))},t.prototype.parse=function(e){this._update(e)},t.prototype._update=function(e){this.role=e.role||ar.Role.NONE,e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)},t}(Ot),ur=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}(Ot),cr=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}(),dr=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}(),hr=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}(),pr={},fr={},_r=new WeakMap,gr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=Rt.CHANNEL_TYPE_OPEN,r.participantCount=0,_r.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=ji.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,ge.of(t._iid).send({source:de.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=ji.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),ge.of(t._iid).send({source:de.EVENT_CHANNEL_EXIT,payload:{channel:t}}),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,t=me.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(me.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})),n?this.updateChannel(a,n):this.updateChannel(a)}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]),n?this.updateChannel(o,n):this.updateChannel(o)}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],n?this.updateChannel(l,n):this.updateChannel(l)}return oe(this._iid,(function(e){return e(me.error,null)}),n)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=me.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return t?this.updateChannel(params,t):this.updateChannel(params);default:return oe(this._iid,(function(e){return e(me.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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string",optional:!0,defaultValue:""}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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>=_r.get(this)&&(_r.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 pr[this._iid]||(pr[this._iid]={}),pr[this._iid]}},{key:"enteredChannels",get:function(){return fr[this._iid]||(fr[this._iid]={}),fr[this._iid]}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.OpenChannel,i=Nt.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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.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(me.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(me.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=me.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return t?this.createChannel.apply(this,A(e).concat([t])):this.createChannel.apply(this,A(e));default:return oe(this._iid,(function(e){return e(me.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(){pr[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){fr[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,x.get(this._iid).OpenChannelListQuery)}}]),n}(Rt),yr="default",mr=function(){function e(e){this.name=yr,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?yr:t,r=e.volume;return{name:n,volume:void 0===r?1:r}},e.prototype.serialize=function(){return Nt.serialize(this)},e}(),Er=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}(),vr=new WeakMap,br=function(){function e(t){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],vr.set(this,null),this._parentMessageId=null,this._reqId=null,this.data=null,this.customType=null,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this.isReplyToChannel=!1,this.mentionedMessageTemplate=null,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)){if(0===e.length)return this._cachedMentionedUserIds=[],void(this._mentionedUserIds=[]);for(var t=ji.getInstance(this._iid),n=0;n-1&&this._mentionedUserIds.every((function(e){return"string"==typeof e}))&&("string"==typeof this.mentionedMessageTemplate||null===this.mentionedMessageTemplate)&&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 mr)&&"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.mentionedMessageTemplate,o=void 0===a?null:a,l=t.cachedMentionedUsers,u=void 0===l?[]:l,c=t.cachedMentionedUserIds,d=void 0===c?[]:c,h=t.metaArrays,p=void 0===h?[]:h,f=t.parentMessageId,_=void 0===f?null:f,g=t.pushNotificationDeliveryOption,y=void 0===g?null:g,m=t.appleCriticalAlertOptions,E=void 0===m?null:m,v=t.isReplyToChannel;return{mention_type:r,mentioned_user_ids:s,mentioned_message_template:o,cached_mentioned_users:u,cached_mentioned_user_ids:d,meta_arrays:p,parent_message_id:_,push_notification_delivery_option:y,apple_critical_alert_options:E,is_reply_to_channel:void 0!==v&&v}}},{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),Cr=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&&"number"==typeof r?new this(t,n,r):null},e.objectify=function(e){return{key:e.key,user_ids:e.userIds,updated_at:e.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}(),Nr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.MESSAGE_TYPE_USER,r.message=null,r._sender=null,r.translations={},r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r.plugins=[],r.poll=null,r._messageParams=null,e&&r._update(e),r}return h(n,[{key:"applyPollUpdateEvent",value:function(e){var t=x.get(this._iid),n=t.Poll,r=t.PollUpdateEvent,i=null,s=me.parse(arguments,[new me({type:r,constraint:function(e){return Object.values(n.Status).includes(e.status)}})]),a=C(s,2);if(i=a[0],e=a[1],!i&&this.poll&&this.poll.id===e.poll.id){if(e.status===n.Status.REMOVED)return this.poll=new n(n.objectify(this.poll)),this.poll.details.status=e.status,!0;if(this.poll.details.updatedAt0?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 Cr(e.message_params))}},{key:"sender",get:function(){var e=ji.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(this._sender&&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),se.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=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&se.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:"_isSentByMe",value:function(){var e=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.SUCCEEDED&&0===this.updatedAt&&this._sender&&this._sender.userId===e.currentUser.userId}}],[{key:"objectify",value:function(e){var t=ji.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.Reaction,_=n.AppleCriticalAlertOptions,g=n.Poll,y=n.UserMessageParams,m=e.messageId,E=e.messageType,v=void 0===E?Tt.MESSAGE_TYPE_BASE:E,b=e.reqId,C=void 0===b?"":b,A=e.user,N=e.channel,S=void 0===N?null:N,I=e.channelUrl,T=void 0===I?"":I,O=e.channelType,U=void 0===O?r.CHANNEL_TYPE_OPEN:O,k=e.message,M=e.data,R=void 0===M?"":M,L=e.customType,P=void 0===L?"":L,w=e.mentionType,D=void 0===w?i.MentionType.USERS:w,H=e.mentionedUsers,F=void 0===H?[]:H,G=e.mentionedUserIds,j=void 0===G?[]:G,B=e.mentionedMessageTemplate,V=void 0===B?null:B,q=e.requestedMentionUserIds,K=void 0===q?[]:q,z=e.reactions,Y=void 0===z?[]:z,Q=e.metaArrays,W=void 0===Q?[]:Q,J=e.rootMessageId,X=void 0===J?0:J,Z=e.parentMessageId,$=void 0===Z?0:Z,ee=e.parentMessageText,te=void 0===ee?"":ee,ne=e.threadInfo,re=void 0===ne?null:ne,ie=e.isReplyToChannel,se=void 0!==ie&&ie,ae=e.parentMessage,oe=void 0===ae?null:ae,le=e.translations,ue=void 0===le?{}:le,ce=e.sendingStatus,de=e.errorCode,he=void 0===de?0:de,pe=e.silent,fe=void 0!==pe&&pe,_e=e.isGlobalBlocked,ge=void 0!==_e&&_e,ye=e.messageSurvivalSeconds,me=void 0===ye?-1:ye,Ee=e.ogMetaData,ve=void 0===Ee?null:Ee,be=e.isOperatorMessage,Ce=void 0!==be&&be,Ae=e.plugins,Ne=void 0===Ae?[]:Ae,Se=e.appleCriticalAlertOptions,Ie=e.poll,Te=void 0===Ie?null:Ie,Oe=e.createdAt,Ue=e.updatedAt,ke=void 0===Ue?0:Ue,Me=e.messageParams,Re=void 0===Me?null:Me,Le=e.isAutoResendRegistered,Pe=void 0!==Le&&Le,we={};switch(we.req_id=C,we.msg_id=m,v){case Tt.MESSAGE_TYPE_USER:we.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:we.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:we.type="ADMM"}if(we.user=s.objectify(l({},A)),we.channel_url=S?S.url:T,we.channel_type=S?S.channelType:U,we.message=k,we.data=R,we.custom_type=P,we.translations=ue,we.is_global_block=!!ge,we.ts=Oe,we.updated_at=ke,we.mention_type=D,we.mentioned_users=F.map((function(e){return a.objectify(e)})),we.mentioned_user_ids=j,we.mentioned_message_template=V,we.requested_mention_user_ids=K,we.reactions=Y.map((function(e){return f.objectify(e)})),we.metaarray={},W.forEach((function(e){var t=e.key;we.metaarray[t]=e.value})),we.metaarray_key_order=W.map((function(e){return e.key})),we.root_message_id=X,we.parent_message_id=$,we.parent_message_text=te,re&&(we.thread_info=d.objectify(re)),we.is_reply_to_channel=se,oe)switch(oe.messageType){case Tt.MESSAGE_TYPE_USER:we.parent_message_info=o._objectifySerializedData(oe);break;case Tt.MESSAGE_TYPE_FILE:we.parent_message_info=u._objectifySerializedData(oe);break;case Tt.MESSAGE_TYPE_ADMIN:we.parent_message_info=c._objectifySerializedData(oe)}return we.sending_status=m>0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ce&&(we.sending_status=ce),we.silent=!!fe,we.error_code=he,we.message_survival_seconds=me,ve&&(we.og_tag=h.objectify(ve)),we.is_op_msg=!!Ce,we.plugins=Ne.map((function(e){return p.objectify(e)})),Te&&(we.poll=g.objectify(Te)),Se&&(we.apple_critical_alert_options=_.objectify(Se)),Re&&(we.message_params=y.objectify(Re)),we.is_auto_resend_registered=Pe,we}},{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){return this.objectify({messageId:t,reqId:e,user:n,channel:r,message:i,data:s,customType:a,mentionType:p,mentionedUsers:f,mentionedUserIds:E,mentionedMessageTemplate:v,requestedMentionUserIds:C,reactions:h,metaArrays:d,rootMessageId:_,parentMessageId:g,parentMessageText:y,threadInfo:m,translations:o,sendingStatus:b,errorCode:A,isGlobalBlocked:l,messageSurvivalSeconds:N,ogMetaData:S,isOperatorMessage:I,plugins:T,appleCriticalAlertOptions:O,poll:U,createdAt:u,updatedAt:c,messageParams:k})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).UserMessage,n=Nt.deserialize(e);return new t(this._objectifySerializedData(n))}},{key:"_objectifySerializedData",value:function(e){return x.get(this._iid).UserMessage.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,messageParams:e.messageParams?new Cr(Cr.objectify(e.messageParams)):null}))}}]),n}(Tt),Sr=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){se.isFile(e)&&(this._fileUrl=null,this._file=e,te.isFile(e)?this._fileType=D.FILE:te.isBlob(e)?this._fileType=D.BLOB:te.isFileLikeObject(e)?this._fileType=D.BLOB_LIKE_OBJECT:"string"==typeof e&&(this._fileType=D.URL))}},{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({},br._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}(br),Ir=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.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=ji.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 Sr(e.message_params))}},{key:"sender",get:function(){var e=ji.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(this._sender&&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),se.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=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&se.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&&te.isBlob(t)&&(e._messageParams.file=t.slice())}return e}},{key:"_isSentByMe",value:function(){var e=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.SUCCEEDED&&0===this.updatedAt&&this._sender&&this._sender.userId===e.currentUser.userId}}],[{key:"objectify",value:function(e){var t=ji.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.Reaction,f=n.FileMessageParams,_=n.AppleCriticalAlertOptions,g=e.messageId,y=e.messageType,m=void 0===y?Tt.MESSAGE_TYPE_BASE:y,E=e.reqId,v=void 0===E?"":E,b=e.user,C=void 0===b?{}:b,A=e.channel,N=e.plainUrl,S=e.name,I=void 0===S?null:S,T=e.type,O=e.size,U=void 0===O?0:O,k=e.data,M=void 0===k?"":k,R=e.customType,L=void 0===R?"":R,P=e.mentionType,w=void 0===P?i.MentionType.USERS:P,D=e.mentionedUsers,H=void 0===D?[]:D,F=e.mentionedUserIds,G=void 0===F?[]:F,j=e.requestedMentionUserIds,B=void 0===j?[]:j,V=e.reactions,q=void 0===V?[]:V,K=e.metaArrays,z=void 0===K?[]:K,Y=e.rootMessageId,Q=void 0===Y?0:Y,W=e.parentMessageId,J=void 0===W?0:W,X=e.parentMessageText,Z=void 0===X?"":X,$=e.threadInfo,ee=void 0===$?null:$,te=e.isReplyToChannel,ne=void 0!==te&&te,re=e.parentMessage,ie=void 0===re?null:re,se=e.thumbnails,ae=void 0===se?[]:se,oe=e.requireAuth,le=void 0!==oe&&oe,ue=e.sendingStatus,ce=e.errorCode,de=void 0===ce?0:ce,he=e.silent,pe=void 0!==he&&he,fe=e.isGlobalBlocked,_e=void 0!==fe&&fe,ge=e.messageSurvivalSeconds,ye=void 0===ge?-1:ge,me=e.ogMetaData,Ee=void 0===me?null:me,ve=e.isOperatorMessage,be=void 0!==ve&&ve,Ce=e.appleCriticalAlertOptions,Ae=e.createdAt,Ne=e.updatedAt,Se=void 0===Ne?0:Ne,Ie=e.messageParams,Te=void 0===Ie?null:Ie,Oe=e.isAutoResendRegistered,Ue=void 0!==Oe&&Oe,ke={};switch(ke.req_id=v,ke.msg_id=g,m){case Tt.MESSAGE_TYPE_USER:ke.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:ke.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:ke.type="ADMM"}ke.user=s.objectify(l({},C)),ke.channel_url=A.url,ke.channel_type=A.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,ke.url=N,ke.name=I,ke.type=T,ke.size=U,ke.custom=M,ke.custom_type=L,ke.thumbnails=ae,ke.require_auth=le,ke.is_global_block=!!_e,ke.ts=Ae,ke.updated_at=Se,ke.mention_type=w,ke.mentioned_users=H.map((function(e){return a.objectify(e)})),ke.mentioned_user_ids=G,ke.requested_mention_user_ids=B,ke.reactions=q.map((function(e){return p.objectify(e)})),ke.metaarray={};for(var Me=0;Me0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ue&&(ke.sending_status=ue),ke.silent=!!pe,ke.error_code=de,ke.message_survival_seconds=ye,Ee&&(ke.og_tag=h.objectify(Ee)),ke.is_op_msg=!!be,Ce&&(ke.apple_critical_alert_options=_.objectify(Ce)),Te&&(ke.message_params=f.objectify(Te)),ke.is_auto_resend_registered=Ue,ke}},{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,M){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:M})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).FileMessage,n=Nt.deserialize(e);return new t(this._objectifySerializedData(n))}},{key:"_objectifySerializedData",value:function(e){return x.get(this._iid).FileMessage.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,messageParams:e.messageParams?new Sr(Sr.objectify(e.messageParams)):null}))}}]),n}(Tt),Tr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.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=t.Reaction,d=e.messageId,h=e.messageType,p=void 0===h?Tt.MESSAGE_TYPE_BASE:h,f=e.channel,_=e.message,g=e.data,y=void 0===g?"":g,m=e.customType,E=void 0===m?"":m,v=e.mentionType,b=void 0===v?r.MentionType.USERS:v,C=e.mentionedUsers,A=void 0===C?[]:C,N=e.mentionedMessageTemplate,S=void 0===N?null:N,I=e.reactions,T=void 0===I?[]:I,O=e.metaArrays,U=void 0===O?[]:O,k=e.rootMessageId,M=void 0===k?0:k,R=e.parentMessageId,L=void 0===R?0:R,P=e.parentMessageText,w=void 0===P?"":P,D=e.threadInfo,H=void 0===D?null:D,F=e.isReplyToChannel,G=void 0!==F&&F,j=e.parentMessage,B=void 0===j?null:j,V=e.translations,q=void 0===V?{}:V,K=e.silent,z=void 0!==K&&K,Y=e.ogMetaData,Q=void 0===Y?null:Y,W=e.createdAt,J=e.updatedAt,X=void 0===J?0:J,Z={msg_id:d,channel_url:f.url,channel_type:f.channelType===n.CHANNEL_TYPE_OPEN?n.CHANNEL_TYPE_OPEN:n.CHANNEL_TYPE_GROUP,message:_,data:y,custom_type:E,silent:z,ts:W,updated_at:X};switch(p){case Tt.MESSAGE_TYPE_USER:Z.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:Z.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:Z.type="ADMM"}Z.translations=q,Z.mention_type=b,Z.mentioned_users=A.map((function(e){return o.objectify(e)})),Z.mentioned_message_template=S,Z.reactions=T.map((function(e){return c.objectify(e)})),Z.metaarray={};for(var $=0;$0&&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(me.error,null)}),e)}}]),e}(),Lr=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(me.error,null)}),e)}}]),e}(),Pr=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(me.error,null)}),e)}}]),e}(),wr=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(me.error,null)}),e)}}]),e}(),Dr=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.nicknameStartsWithFilter="",this.nicknameExactMatchFilter="",this.channelNameContainsFilter="",this.memberStateFilter=ar.MemberStateFilter.ALL,this.customTypesFilter=[],this.channelUrlsFilter=[],this.superChannelFilter=ar.SuperChannelFilter.ALL,this.publicChannelFilter=ar.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=ar.UnreadChannelFilter.ALL,this.metadataOrderKeyFilter=null,this.metadataKey=null,this.metadataValues=[],this.metadataValueStartsWith=null,this.hiddenChannelFilter=ar.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 Nt.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.nicknameStartsWithFilter||"string"!=typeof t.nicknameExactMatchFilter||"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(me.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=Nt.deserialize(e),r=t.createMyGroupChannelListQuery();return Object.keys(n).forEach((function(e){r.hasOwnProperty(e)&&(r[e]=n[e])})),r}}]),e}(),Hr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.mutedMemberFilter=e.MutedMemberFilter.ALL,this.memberStateFilter=ar.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;if("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))if(t.isLoading)e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(t.hasNext){t.isLoading=!0;var a=U.get(t._iid);t.memberStateFilter===r.MemberStateFilter.LEFT&&(t.memberStateFilter=r.MemberStateFilter.ALL),a.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)}))}else e(null,[]);else e(me.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}(),Fr=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(me.error,null)}),e)}}]),e}(),Gr=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(me.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}(),xr=new WeakMap,jr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",xr.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=xr.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(me.error,null)}),e)}}]),e}(),Br=new WeakMap,Vr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t&&Br.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:Br.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(me.error,null)}),e)}}]),e}(),qr=new WeakMap,Kr=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},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,qr.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 qr.get(this).keyword}},{key:"limit",get:function(){return qr.get(this).limit}},{key:"reverse",get:function(){return qr.get(this).reverse}},{key:"exactMatch",get:function(){return qr.get(this).exactMatch}},{key:"channelUrl",get:function(){return qr.get(this).channelUrl}},{key:"channelCustomType",get:function(){return qr.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return qr.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return qr.get(this).messageTimestampTo}},{key:"order",get:function(){return qr.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=qr.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(me.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,qr.get(t).nextToken=a.end_cursor),t.isLoading=!1,e(n,o)}))):e(null,[])}),e)}}]),e}(),zr=new WeakMap,Yr=new WeakMap,Qr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,Yr.set(this,Number.MAX_SAFE_INTEGER),zr.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=me.parse(arguments,[new me({type:"number",optional:!0,defaultValue:this.limit}),new me({type:"boolean",optional:!0,defaultValue:this.reverse}),new me({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 me({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=me.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=zr.get(i);U.get(i._iid).container.apiClient.getMessageList({channel:s,token:Yr.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(me.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,Xr=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.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),Xr.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!Jr.get(this)}},{key:"hasNext",get:function(){return!!Xr.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),Xr.set(t,!!a),e(null,s)}}))):e(null,[]):e(me.error,null)}),e)}}]),e}(),$r=new WeakMap,ei=new WeakMap,ti=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,$r.set(this,!1),ei.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!$r.get(this)}},{key:"hasNext",get:function(){return!!ei.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?($r.set(t,!0),U.get(t._iid).container.apiClient.getPollOptionVoterList(l({},t),(function(n,r){if(n)$r.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,$r.set(t,!1),ei.set(t,!!a),e(null,s)}}))):e(null,[]):e(me.error,null)}),e)}}]),e}(),ni=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)&&(se.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}(),ri=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||se.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}(),ii=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}(Cr),si=h((function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=ar.SuperChannelFilter.ALL})),ai=function(e){f(n,e);var t=E(n);function n(){return c(this,n),t.call(this)}return h(n)}(si),oi=function(e){f(n,e);var t=E(n);function n(){return c(this,n),t.call(this)}return h(n)}(si),li=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}(),ui=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=ji.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}(),ci=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}(),di=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}(),hi=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}(),pi=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}(),fi=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}(),_i=function(){this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},gi=function(){this.onFriendsDiscovered=function(){},this.onTotalUnreadMessageCountUpdated=function(){}},yi=h((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){}})),mi=h((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}})),Ei=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}(),vi=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}(),bi=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}(),Ci=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}(),Ai=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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"array",constraint:function(e){return e.every((function(e){return"number"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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}(),Ni=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}(),Si=new WeakMap,Ii=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,Si.set(this,null),this._update(t)}return h(e,[{key:"lastVotedAt",get:function(){return Si.get(this)}},{key:"update",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({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(me.error,null)}),e)}}]),e}(),Ui=new WeakMap,ki=function(){function e(t){c(this,e),this.isLoading=!1,Ui.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(me.parse(i,[new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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(me.parse(i,[new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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(me.parse(s,[new me({type:"number"}),new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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}(),Mi=0,Ri=1,Li=2,Pi=function(){function e(t){var n=this;c(this,e),this.state=Mi,this._value=null,this._reason=null;var r=function(e){n.state===Mi&&(n.state=Li,n._reason=e)};if("function"!=typeof t)throw"Promise resolver ".concat(t," is not a function");try{t((function(e){n.state===Mi&&(n.state=Ri,n._value=e)}),r)}catch(e){r(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 Mi:setTimeout((function(){return r.then(t,n)}),2);break;case Ri:t&&"function"==typeof t&&(i=t(this._value));break;case Li: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 Mi:setTimeout((function(){return n.catch(t)}),2);break;case Ri:break;case Li:r=t(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(t){var n=this,r=this;switch(this.state){case Mi:setTimeout((function(){return n.finally(t)}),2);break;case Ri:case Li: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),wi();var r=!1;if((n.newInstance||!Hi||Hi&&n.appId!==Hi.getApplicationId()&&Hi.getConnectionState()===Hi.ConnectionState.CLOSED)&&(r=!0,Hi=this),r){try{if(!n.hasOwnProperty("appId"))return J.warn("Must be set appId."),Hi=null,null}catch(e){return J.warn("Must be set appId."),Hi=null,null}var i=Xn.create();Object.defineProperty(this,"_iid",{get:function(){return i}}),Fi[i]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new Ee(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:Rt.MessageTypeFilter},this.GroupChannelFilter=Zn,this.MessageFilter=Re,this.GroupChannelCollection={GroupChannelOrder:ot},this.MessageCollection={MessageCollectionInitPolicy:Fe},this.CollectionEventSource=de,this._currentUserId=null;var s={User:Ot,Member:or,RestrictedUser:ur,GroupChannel:ar,OpenChannel:gr,UserMessage:Nr,FileMessage:Ir,AdminMessage:Tr,GroupChannelListQuery:Dr,MemberListQuery:Hr,GroupChannelParams:ni,OpenChannelParams:ri,BaseMessageParams:br,UserMessageParams:Cr,FileMessageParams:Sr,ScheduledUserMessageParams:ii,GroupChannelTotalUnreadMessageCountParams:ai,GroupChannelTotalUnreadChannelCountParams:oi,MessageRetrievalParams:li,MessageListParams:ui,ThreadedMessageListParams:ci,MessageChangeLogsParams:di,GroupChannelChangeLogsParams:hi,PollParams:pi,PollRetrievalParams:fi,MessageMetaArray:Er,UserEventHandler:gi,SessionHandler:ve,ChannelHandler:yi,ConnectionHandler:_i,AppleCriticalAlertOptions:mr,Poll:Ai,PollOption:Ii},a={SessionManager:be,BaseChannel:Rt,BaseMessage:Tt,UserListQuery:Oi,ApplicationUserListQuery:Rr,BannedUserListQuery:Lr,BlockedUserListQuery:Pr,FriendListQuery:wr,MutedUserListQuery:Fr,OpenChannelListQuery:Gr,OperatorListQuery:jr,ParticipantListQuery:Vr,MessageListQuery:ki,PreviousMessageListQuery:Qr,MessageSearchQuery:Kr,PublicGroupChannelListQuery:Wr,PollListQuery:Zr,PollVoterListQuery:ti,ScheduledUserMessage:Or,ThreadInfo:Ei,ThreadInfoUpdateEvent:Ur,OGMetaData:vi,OGImage:bi,Plugin:Ci,Command:Ne,Sender:lr,ReadStatus:mi,Reaction:Ar,ReactionEvent:Ct,Emoji:hr,EmojiCategory:dr,EmojiContainer:cr,PollDetails:Ni,PollUpdateEvent:kr,PollVoteEvent:Mr,RestrictionInfo:Ti,FileMessageQueue:Gt},o=new x(this._iid,l(l({},s),a));this.BaseMessage={ReplyType:Tt.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 ye(this),commandHandler:new wt(this),onlineDetector:new Ce(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 Hn({encryption:u}),preference:null,auth:new F,appInfo:null,pingInterval:15e3,pongTimeout:5e3,connectedAt:0,extensions:{},supportedExtensionKeys:["sb_uikit","sb_syncmanager","device-os-platform"],getUserAgentWithExtensions:function(e){var t=$()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(T.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},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<=Di&&(this._websocketResponseTimeout=e)},includePollDetails:!1};var d=pe.of(i);d.addObserver({onConnect:function(){t.isCacheEnabled&&!t.getIsProcessingAutoResend()&&(0===t.getAutoResendQueue().length?nt._processAutoResendRegisteredPendingMessages(t).then((function(){nt._processNextAutoResend(t)})):nt._processNextAutoResend(t))},onDisconnect:function(){}})}return Hi}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 Gi}},{key:"setDebugMode",value:function(e){Gi=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:"setOnlineListener",value:function(e){U.get(this._iid).container.onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){U.get(this._iid).container.onlineDetector.setOfflineListener(e)}},{key:"getMemoryStoreForDebugging",value:function(){var e=U.get(this._iid);return e.container.debugCache&&e.container.store instanceof wn?e.container.store:null}},{key:"useMemoryAsDatabaseForDebugging",value:function(){var e=U.get(this._iid);e.container.debugCache=!0,e.container.store=new wn}},{key:"useAsyncStorageAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Fn({AsyncStorage:e,encryption:t.container.encryption})}},{key:"useMMKVAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Gn({MMKV: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){if(0===e)i.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[Ue.NAME_ALPHABETICAL,Ue.CHRONOLOGICAL,Ue.LATEST_LAST_MESSAGE]},{collectionName:"SucceededMessage",keyName:"messageId",index:[ke.LATEST,ke.CHILD_MESSAGE_FIRST]},{collectionName:"UnsentMessage",keyName:"reqId",index:[ke.LATEST_UNSENT,ke.CHILD_MESSAGE_FIRST]}]).then((function(){return t()})).catch((function(e){throw e}));else t()})),i.on("error",(function(e){e?e.code===xt.STORE_NOT_AVAILABLE||e.code===xt.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING?t(null):(J.error("Database initialize failed with an error: ",e),t(e)):t(null)})),i.on("success",(function(){r.container.currentUserId=e,new bt({iid:n._iid,collection:i.collection("GroupChannel")}),new Ge({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 bt({iid:n._iid,collection:null}),new Ge({iid:n._iid,collections:{succeeded:null,unsent:null}}),t(null)}),t)}},{key:"clearCachedData",value:function(){var e=U.get(this._iid),t=e.container,n=t.localCacheEnabled,r=t.nestdb;return new Promise((function(t,i){n&&r?(r.close(),r.reset().then((function(){J.debug("Database clear succeeded."),e.container.nestdb=null,t()})).catch((function(e){J.error("Database clear failed with an error: ",e),i(e)}))):t()}))}},{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;u&&u.start();var d=null,h=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new me({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],(n||r)&&J.debug("Please note that apiHost and wsHost are for internal use only."),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).then((function(){if(c)return nt._processNonAutoResendRegisteredPendingMessages(s)})):h.lock((function(n){s.initializeDatabase(e).then((function(){n(),l.connect(e,t)})).then((function(){if(c)return nt._processNonAutoResendRegisteredPendingMessages(s)})).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.clearCachedData().finally((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 as the app goes background.",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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){if(i)n(i,null);else{var s=U.get(r._iid);s.container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:t},(function(i,a){var o=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),t&&(r.currentUser.plainProfileUrl=t,Object.defineProperty(r.currentUser,"profileUrl",{value:r.currentUser.requireAuth?"".concat(r.currentUser.plainProfileUrl,"?auth=").concat(s.container.auth.eKey):r.currentUser.plainProfileUrl,configurable:!0,writable:!1}))),o=r.currentUser),n(i,o)}))}}),n)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,t,n){var r=this,i=null,s=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"file",nullable:!0}),new me({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){if(i)n(i,null);else{var s=U.get(r._iid);s.container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:t},(function(t,i){var a=null;t||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url,Object.defineProperty(r.currentUser,"profileUrl",{value:r.currentUser.requireAuth?"".concat(r.currentUser.plainProfileUrl,"?auth=").concat(s.container.auth.eKey):r.currentUser.plainProfileUrl,configurable:!0,writable:!1}))),a=r.currentUser),n(t,a)}))}}),n)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"array",optional:!0,nullable:!0,defaultValue:null}),new me({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:c,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:"array",optional:!0,nullable:!0,defaultValue:null}),new me({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:c,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({type:"number",constraint:function(e){return e>0}}),new me({type:"number",constraint:function(e){return e>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new me({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 Ot(n)),t(e,r)}))}),t)}},{key:"unblockUser",value:function(e,t){var n=null,r=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new me({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(me.error,null)}),t)}},{key:"getGroupChannelCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=me.parse(arguments,[new me({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new me({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,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadChannelCountParams,a=null,o=me.parse(arguments,[new me({type:"object",optional:!0,defaultValue:null,constraint:function(e){return e instanceof s}}),new me({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=null,s=i.SuperChannelFilter.ALL;e&&(r=e.channelCustomTypesFilter,s=e.superChannelFilter),U.get(n._iid).container.apiClient.getTotalUnreadChannelCount({customTypesFilter:r,superChannelFilter:s},(function(e,n){var r=null;e||(r=parseInt(n.unread_count)),t(e,r)}))}}),t)}},{key:"getTotalUnreadMessageCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadMessageCountParams,a=null,o=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.length>0&&e.every((function(e){return Object.keys(ar.UnreadItemKey).map((function(e){return ar.UnreadItemKey[e]})).indexOf(e)>-1}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new me({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(me.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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){ar.cachedChannels[e]&&(n.currentUser&&ar.cachedChannels[e].updateReadReceipt(n.currentUser.userId,i),ar.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).then((function(e){return e.markAsDelivered()})).catch((function(e){return J.debug(e)}))}},{key:"getFriendChangeLogsByToken",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({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=this,n=Ge.of(this._iid);if(n){var r=U.get(this._iid).container.store;return Promise.all(e.map((function(e){return new Promise((function(i,s){n.clearByChannelUrl(e).then((function(){var n=Be(t._currentUserId,e);return r.remove(n)})).then((function(){var n=Ke(t._currentUserId,e);return r.remove(n)})).then((function(){i()})).catch((function(e){s(e)}))}))})))}return 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 Ie(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?Fi[e]:Hi}},{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,"`."))}}},{key:"getAppVersion",value:function(){return xi}},{key:"setAppVersion",value:function(e){"string"==typeof e&&$()&&(xi=e)}}]),e}();return ji})); \ 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.27"},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=ji.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}(),M=function(e,t){return M=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])},M(e,t)};function k(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}M(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var R=function(){return R=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&&(q=t)}},{key:"supportedLogLevels",get:function(){return K}},{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))};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(D||(D={}));var te=function(){function e(){}var t;return e.isFileLikeObject=function(e){return"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},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"undefined"!=typeof window&&"File"in window&&"undefined"!=typeof File&&e instanceof File},e.isBlob=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},e.isFileTypeBlob=function(e){return e===D.BLOB||e===D.FILE},e.convertBlobToBuffer=function(n){return L(void 0,void 0,void 0,(function(){var r;return P(t,(function(t){switch(t.label){case 0:return[4,e.convertFileToArrayBuffer(n)];case 1:return r=t.sent(),[2,Buffer.from(r)]}}))}))},e}(),ne=[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],re=[H.SESSION_TOKEN_EXPIRED,H.SESSION_TOKEN_REVOKED,H.USER_DEACTIVATED,H.NON_EXISTING_USER],ie=[H.WEBSOCKET_CONNECTION_CLOSED,H.WEBSOCKET_CONNECTION_FAILED],se=function(){function e(){}return e.deepEqual=function(e,t){if(e!==t){var n=R({},e),r=R({},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&&ne.indexOf(e)>=0},e.isAutoResendableError=function(e){return e>0&&ie.indexOf(e)>=0},e.isNonAutoReconnectableError=function(e){return e>0&&re.indexOf(e)>=0},e.isFile=function(e){var t=te.isFileLikeObject(e);return t||(ee()?"undefined"!=typeof Buffer&&e instanceof Buffer:"undefined"!=typeof Blob?e instanceof Blob:"undefined"!=typeof File&&e instanceof File)},e}(),ae=function(){function e(e){var t=this;this.fields={},e&&Object.keys(e).forEach((function(n){t.fields[n]={value:e[n]},se.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 L(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,l,u,c,d,h,p=this;return P(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,f=ji.getAppVersion(),_="JS,".concat(T.OS_VERSION,",").concat(T.SDK_VERSION,",").concat(c);return f&&(_+=",".concat(f)),o.SendBird=_,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(),e instanceof s.default&&$()&&(o["Content-Type"]="multipart/form-data"),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":case"DELETE":d=a._createQuery(u,o);break;case"POST":case"PUT":d=u}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={headers:l,validateStatus:a._validateStatus,onUploadProgress:function(e){n.upload.progressHandler&&n.upload.progressHandler(e,n.upload.reqId)}};if(o instanceof s.default){var f=null;"function"==typeof AbortController?(f=new AbortController,p.signal=f.signal):(f=i.default.CancelToken.source(),p.cancelToken=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,p);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.add("expiring_session",!0),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;case a.MemberStateFilter.LEFT:l="left";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,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_CHANNEL_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:"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),se.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),se.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.nicknameStartsWithFilter,d=t.nicknameExactMatchFilter,h=t.channelNameContainsFilter,p=t.channelUrlsFilter,f=t.customTypesFilter,_=t.customTypeStartsWithFilter,g=t.memberStateFilter,y=t.superChannelFilter,m=t.publicChannelFilter,E=t.unreadChannelFilter,v=t.metadataOrderKeyFilter,b=t.metadataKey,C=t.metadataValues,A=t.metadataValueStartsWith,N=t.hiddenChannelFilter,S=t.searchFilter,I=t.includeFrozen,T=t.includeMetaData;return oe(this.sb._iid,(function(t){r.sb.ConnectionManager.ready((function(n,O){if(n)t(n,null);else{var U=e.Path.MYGROUPCHANNELS.replace("%s",encodeURIComponent(O.userId)),M=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:g});f&&f.length>0&&M.add("custom_types",f),u&&M.add("members_nickname_contains",u),c&&M.add("members_nickname_startswith",c),d&&M.add("members_nickname",d),h&&M.add("name_contains",h),S&&S.hasOwnProperty("search_query")&&S.hasOwnProperty("search_fields")&&(M.add("search_query",S.search_query),M.add("search_fields",S.search_fields)),l&&l.userIds&&l.userIds.length>0&&(l.includeMode?(M.add("members_include_in",l.userIds),M.add("query_type",l.queryType.toUpperCase())):M.add("members_exactly_in",l.userIds)),p&&p.length>0&&M.add("channel_urls",p),M.add("super_mode",y),M.add("public_mode",m),M.add("unread_filter",E),v&&M.add("metadata_order_key",v),b&&M.add("metadata_key",b),C&&C.length>0&&M.add("metadata_values",C),A&&M.add("metadata_value_startswith",A),_&&M.add("custom_type_startswith",_),N&&M.add("hidden_mode",N),"boolean"==typeof I&&M.add("show_frozen",I),"boolean"==typeof T&&M.add("show_metadata",T),r.get(U,M,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),se.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),se.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.mentionedMessageTemplate,f=t.pushNotificationDeliveryOption,_=t.rootMessageId,g=t.parentMessageId,y=t.appleCriticalAlertOptions,m=t.pollId,E=t.isReplyToChannel;this.sb.ConnectionManager.ready((function(t,v){if(t)n(t,null);else{var b=r.cls.FileMessageParams,C=s?e.Path.OPENCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)):e.Path.GROUPCHANNELS_CHANNELURL_MESSAGES.replace("%s",encodeURIComponent(i)),A=new ae({message_type:"MESG",user_id:v.userId,message:a,mention_type:d,mentioned_user_ids:[]});null!=o&&A.add("data",o),null!=l&&A.add("custom_type",l),u&&A.add("translation_target_langs",u),c&&c.length>0&&A.add("sorted_metaarray",c.map((function(e){return e.encode()}))),d===r.cls.BaseMessageParams.MentionType.CHANNEL?A.add("mentioned_user_ids",[]):Array.isArray(h)&&h.length>0&&A.add("mentioned_user_ids",h),p&&A.add("mentioned_message_template",p),f&&f!==b.PushNotificationDeliveryOption.DEFAULT&&A.add("push_option",f),_&&A.add("root_message_id",_),g&&A.add("parent_message_id",g),y&&A.add("apple_critical_alert_options",y.serialize()),"number"==typeof m?A.add("poll_id",m):null===m&&A.add("poll_id",-1),E&&A.add("reply_to_channel",E),r.post(C,A,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,c=ji.getAppVersion();this.wsHost=n;try{var d="/?p=JS"+"&pv=".concat(encodeURIComponent(T.OS_VERSION))+"&sv=".concat(encodeURIComponent(T.SDK_VERSION))+"&ai=".concat(encodeURIComponent(this.sb.getApplicationId()));if(c&&(d+="&av=".concat(encodeURIComponent(c))),a.sessionKey?d+="&key=".concat(encodeURIComponent(a.sessionKey)):d+="&user_id=".concat(encodeURIComponent(e),"&access_token=").concat(encodeURIComponent(t)),d+="&active=1",d+="&SB-User-Agent=".concat(encodeURIComponent(l(o))),d+="&Request-Sent-Timestamp=".concat((new Date).getTime().toString()),d+="&include_extra_data=".concat(encodeURIComponent(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"].join(","))),u.handler&&(d+="&expiring_session=1"),this.sb.Options.includePollDetails&&(d+="&include_poll_details=1"),d+="&use_local_cache=1",this.ws=new this.WebSocket(this.wsHost+d),!this.ws)return this.sb.isReconnectingOnError=!0,void this.handler.onError({message:"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 h=!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}();!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"}(de||(de={}));var fe,_e={},ge=function(){function e(){this._observers=[]}return e.of=function(t){return _e[t]||(_e[t]=new e),_e[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;t1&&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 with a number of retries.",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();se.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}(),me=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&&se.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){J.warn("`ConnectionManager` will be deprecated."),this.networkHandlers[e]=t}},{key:"removeNetworkHandler",value:function(e){J.warn("`ConnectionManager` will be deprecated."),delete this.networkHandlers[e]}},{key:"removeAllNetworkHandler",value:function(){J.warn("`ConnectionManager` will be deprecated."),this.networkHandlers={}}},{key:"authenticate",value:function(e){var t=this;if(J.warn("`ConnectionManager` will be deprecated."),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(me.error,null)}}))}else e(me.error,null)}}]),e}(),ve=function(){this.onSessionExpired=function(){},this.onSessionTokenRequired=function(e,t){return e(null)},this.onSessionError=function(e){},this.onSessionRefreshed=function(){},this.onSessionClosed=function(){}},be=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=ji.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=ji.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,expiring_session:1},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.mentionedMessageTemplate,u=e.translationTargetLanguages,c=e.pushNotificationDeliveryOption,d=e.appleCriticalAlertOptions,h=e.requestId,p=void 0===h?null:h,f=e.silent,_=void 0!==f&&f,g=e.rootMessageId,y=void 0===g?null:g,m=e.parentMessageId,E=void 0===m?null:m,v=e.pollId,b=e.isReplyToChannel,C=void 0!==b&&b,A=x.get(this._iid),N=A.UserMessageParams,S=A.BaseMessageParams,I={};return I.channel_url=t,I.message=n,I.data=r,s&&s.length>0&&(I.metaarray=s.map((function(e){return e.encode()}))),a&&(I.mention_type=a),I.mentioned_user_ids=[],a===S.MentionType.CHANNEL?I.mentioned_user_ids=[]:Array.isArray(o)&&o.length>0&&(I.mentioned_user_ids=o),l&&(I.mentioned_message_template=l),i&&(I.custom_type=i),u&&u.length>0&&(I.target_langs=u),c&&c!==N.PushNotificationDeliveryOption.DEFAULT&&(I.push_option=c),d&&(I.apple_critical_alert_options=d.serialize()),_&&(I.silent=_),y&&(I.root_message_id=y),E&&(I.parent_message_id=E),"number"==typeof v?I.poll_id=v:null===v&&(I.poll_id=-1),C&&(I.reply_to_channel=C),new this("MESG",I,p)}},{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.mentionedMessageTemplate,_=void 0===f?null:f,g=e.metaArrayParams,y=void 0===g?null:g,m=e.pollId,E=x.get(this._iid).BaseMessageParams,v={};return v.channel_url=t,v.msg_id=n,null!=s&&void 0!==s&&(v.message=s),null!=o&&void 0!==o&&(v.data=o),null!=u&&void 0!==u&&(v.custom_type=u),d&&(v.mention_type=d),d===E.MentionType.CHANNEL?v.mentioned_user_ids=[]:Array.isArray(p)&&p.length>=0&&(v.mentioned_user_ids=p),_&&(v.mentioned_message_template=_),y&&(v.metaarray=y),r&&(v.apple_critical_alert_options=r.serialize()),"number"==typeof m?v.poll_id=m:null===m&&(v.poll_id=-1),new this("MEDI",v)}},{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 Ae++,String(Ae)}}]),e}(),Se=1048576,Ie=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*Se: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}),Object.defineProperty(e.prototype,"enabledChannelMemberShipHistory",{get:function(){return this._applicationAttributes.includes("channel_membership_history")},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/Se),e.use_reaction=this._useReaction,e.application_attributes=this._applicationAttributes,e.premium_feature_list=this._premiumFeatureList,e.disable_supergroup_mack=this._disableSupergroupMack,e},e}(),Te=function(){function e(e){this._source=e}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}),e}(),Oe=function(){},Ue={NAME_ALPHABETICAL:["name","-pk"],CHRONOLOGICAL:["-createdAt","-pk"],LATEST_LAST_MESSAGE:["-lastMessageCreatedAt","-createdAt","-pk"]},Me={LATEST:["channelUrl","-createdAt","-messageId"],LATEST_UNSENT:["channelUrl","sendingStatus","createdAt"],CHILD_MESSAGE_FIRST:["channelUrl","-parentMessageId","-createdAt"]},ke=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}(),Re=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.includes("*")&&!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}(),Le=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},Pe=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},we=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)))}},De=function(e){return new Promise((function(t,n){setTimeout((function(){return t()}),e)}))},He={};!function(e){e.SUCCEEDED="succeeded",e.UNSENT="unsent"}(fe||(fe={}));var Fe,Ge=function(){function e(e){var t=e.iid,n=e.collections;this._iid=t,this._collections=n,He[t]=this}return e.of=function(e){return He[e]},e.prototype._serialize=function(e){return e.serialize()},e.prototype._deserialize=function(e){if(e){var t=R(R({},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=R(R({},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._getMessageCollectionByType=function(e){return e?this._collections[e]:this._collections.succeeded},e.prototype._getIndexByCollection=function(e){return"UnsentMessage"===e.name?Me.LATEST_UNSENT:Me.LATEST},e.prototype._fetch=function(e,t,n){return L(this,void 0,void 0,(function(){var r,i,s=this;return P(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.parentMessageId&&r.parentMessageId!==n.parentMessageId)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:n.index,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 L(s,void 0,void 0,(function(){var t,r,i;return P(this,(function(s){switch(s.label){case 0:return t=this._deserialize(e),(r=e.messageParams)&&r.file&&te.isFileTypeBlob(r.fileType)&&"string"==typeof t._messageParams.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 L(this,void 0,void 0,(function(){var i,s,a=this;return P(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:r.index,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 L(a,void 0,void 0,(function(){var i,s,a;return P(this,(function(o){switch(o.label){case 0:return i=e.deserialize(t,n),(s=n.messageParams)&&s.file&&te.isFileTypeBlob(s.fileType)&&"string"==typeof i._messageParams.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 L(this,void 0,void 0,(function(){var n,r;return P(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.getPreviousAndNextMessages=function(e,t,n,r,i){return void 0===r&&(r=30),L(this,void 0,void 0,(function(){var s,a;return P(this,(function(o){switch(o.label){case 0:return[4,this.getPreviousMessages(e,t,n,r,i)];case 1:return s=o.sent(),[4,this.getNextMessages(e,t,n,r,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:Me.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._serializeMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i=this;return P(this,(function(s){switch(s.label){case 0:return n=this._getMessageCollectionByType(t),r=[],[4,Promise.all(e.map((function(e){return L(i,void 0,void 0,(function(){var t,i;return P(this,(function(s){switch(s.label){case 0:return(t=e.serialize())?((t=R({},t)).messageParams&&(t.messageParams=R({},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&&te.isBlob(e._messageParams.file)&&te.isFileTypeBlob(e._messageParams.fileType)?[4,n.saveBlob(e._messageParams.file,e.reqId)]:[3,2]):[3,3];case 1:i=s.sent(),t.messageParams.file=i,s.label=2;case 2:r.push(t),s.label=3;case 3:return[2]}}))}))})))];case 1:return s.sent(),[2,r]}}))}))},e.prototype.upsert=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c,d,h,p,f,_,g;return P(this,(function(y){switch(y.label){case 0:return this._localCacheEnabled?(n=ji.getInstance(this._iid),r=this._getMessageCollectionByType(t),[4,this._serializeMessages(e,t)]):[3,13];case 1:return i=y.sent(),[4,r.upsertMany(i)];case 2:if(y.sent(),t&&t!==fe.SUCCEEDED)return[3,13];s=[],a=[],o=0,y.label=3;case 3:return o0?(c=(u=s).concat,[4,this._locallyUpdateChildMessages(l,fe.SUCCEEDED)]):[3,6]:[3,7];case 4:return s=c.apply(u,[y.sent()]),h=(d=a).concat,[4,this._locallyUpdateChildMessages(l,fe.UNSENT)];case 5:a=h.apply(d,[y.sent()]),y.label=6;case 6:return o++,[3,3];case 7:return s.length>0?(p=this._getMessageCollectionByType(fe.SUCCEEDED),[4,this._serializeMessages(s,fe.SUCCEEDED)]):[3,10];case 8:return f=y.sent(),[4,p.upsertMany(f)];case 9:y.sent(),y.label=10;case 10:return a.length>0?(_=this._getMessageCollectionByType(fe.UNSENT),[4,this._serializeMessages(a,fe.UNSENT)]):[3,13];case 11:return g=y.sent(),[4,_.upsertMany(g)];case 12:y.sent(),y.label=13;case 13:return[2]}}))}))},e.prototype._locallyUpdateChildMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i;return P(this,(function(s){switch(s.label){case 0:return n=new Re,r=[],i=this._getMessageCollectionByType(t),[4,this.getAllChildMessages(e,n,i)];case 1:return s.sent().forEach((function(t){t.applyParentMessage(e)&&r.push(t)})),[2,r]}}))}))},e.prototype.remove=function(e,t){return L(this,void 0,void 0,(function(){var n,r;return P(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return i.sent(),n=this._getMessageCollectionByType(t),r={messageId:{"/in":e.map((function(e){return"".concat(e)}))}},[4,n.removeIf({where:r})];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.removeUnsentMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return t=e.channelUrl,n=e.sendingStatus,r=e.reqIds,i=[],this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return o.sent(),s=this._getMessageCollectionByType(fe.UNSENT),a={channelUrl:{"=":t}},n&&(a.sendingStatus={"=":n}),r&&r.length>0&&(a.reqId={"/in":r}),[4,s.removeIf({where:a})];case 2:i=o.sent(),o.label=3;case 3:return[2,i]}}))}))},e.prototype.removeFailedMessages=function(e,t){return L(this,void 0,void 0,(function(){var n,r,i,s;return P(this,(function(a){switch(a.label){case 0:return n=[],this._localCacheEnabled?[4,De(500)]:[3,3];case 1:return a.sent(),r=this._getMessageCollectionByType(fe.UNSENT),i=ji.getInstance(this._iid),s={channelUrl:{"=":e},sendingStatus:{"=":i.MessageSendingStatus.FAILED}},t&&t.length>0&&(s.reqId={"/in":t}),[4,r.removeIf({where:s})];case 2:n=a.sent(),a.label=3;case 3:return[2,n]}}))}))},e.prototype.clearByChannelUrl=function(e){return L(this,void 0,void 0,(function(){var t=this;return P(this,(function(n){switch(n.label){case 0:return[4,Promise.all(Object.keys(fe).map((function(n){var r=t._getMessageCollectionByType(fe[n]),i={channelUrl:{"=":e}};return r.removeIf({where:i})})))];case 1:return n.sent(),[2]}}))}))},e.prototype.clear=function(e){return L(this,void 0,void 0,(function(){return P(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 L(this,void 0,void 0,(function(){var e=this;return P(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,Promise.all(Object.keys(fe).map((function(t){return e.clear(fe[t])})))]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearAbove=function(e,t){return L(this,void 0,void 0,(function(){var n,r;return P(this,(function(i){switch(i.label){case 0:return this._localCacheEnabled?(n=this._getMessageCollectionByType(t),r={createdAt:{"<":e}},[4,n.removeIf({where:r})]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e}(),xe=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}(),je={},Be=function(e,t){return"sendbird:".concat(e,"@channel/").concat(t,"/message/sync")},Ve=function(){function e(e){var t=e.iid,n=e.channel,r=e.limit,i=void 0===r?Ze:r,s=this;this._prevSync=null,this._nextSync=null,this._syncRange=new xe({top:Number.MAX_SAFE_INTEGER,bottom:-1}),this._isPrevSyncComplete=!1,this._isNextSyncComplete=!1,this._iid=t,this._channel=n,this._limit=i;var a=x.get(this._iid).BaseChannel,o=U.get(this._iid),l=o.get("currentUserId"),u=o.get("store"),c=o.get("apiClient"),d=Ge.of(this._iid),h=ge.of(this._iid),p=Be(l,this._channel.url),f=o.container.concurrentCallLimit,_=o.container.backOffDelay;this._prevSync=new ut(p,(function(e){return L(s,void 0,void 0,(function(){var e,t,r,i,s,o,l,f,_,g=this;return P(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:null},[4,u.get(p)];case 1:return(t=y.sent())&&t.isPrevSyncComplete?[3,7]:(t&&(this._syncRange=t.range,this._isPrevSyncComplete=t.isPrevSyncComplete),r=Pe({channel:this._channel,ts:this._syncRange.top,prevLimit:this._limit}),[4,c.getMessageList(r)]);case 2:return i=y.sent(),s=[],o=i.messages.map((function(e){var t=a.buildMessage(e,g._channel);return(t.isUserMessage()||t.isFileMessage())&&t._isSentByMe()&&s.push(t.reqId),t})),l=this.getMinCreatedAt(o),this._syncRange.top=Math.min(this._syncRange.top,l),this._syncRange.bottom<0&&(this._syncRange.bottom=this.getMaxCreatedAt(o)),this._isPrevSyncComplete=o.length0?[4,d.removeUnsentMessages({channelUrl:this._channel.url,reqIds:s})]:[3,5];case 4:y.sent(),y.label=5;case 5:return f={range:this._syncRange,isPrevSyncComplete:this._isPrevSyncComplete,isNextSyncComplete:t?t.isNextSyncComplete:this._isNextSyncComplete},[4,u.set({key:p,value:f,generation:1})];case 6:return y.sent(),_={source:de.MESSAGE_BACKGROUND,payload:{channel:n,messages:o}},h.send(_),e.hasNext=!this._isPrevSyncComplete,[3,8];case 7:J.debug("Message collection background sync has finished."),e.hasNext=!1,y.label=8;case 8:return[2,e]}}))}))}),f,_),this._nextSync=new ut(p,(function(e){return L(s,void 0,void 0,(function(){var e,t,r,i,s,o,l,f,_,g=this;return P(this,(function(y){switch(y.label){case 0:return e={hasNext:!0,nextParams:null},[4,u.get(p)];case 1:return(t=y.sent())?(this._syncRange=t.range,r=Pe({channel:this._channel,ts:this._syncRange.bottom,nextLimit:this._limit}),[4,c.getMessageList(r)]):[3,7];case 2:return i=y.sent(),s=[],o=i.messages.map((function(e){var t=a.buildMessage(e,g._channel);return(t.isUserMessage()||t.isFileMessage())&&t._isSentByMe()&&s.push(t.reqId),t})),l=this.getMaxCreatedAt(o),this._syncRange.bottom=Math.max(this._syncRange.bottom,l),this._isNextSyncComplete=o.length0?[4,d.removeUnsentMessages({channelUrl:this._channel.url,reqIds:s})]:[3,5];case 4:y.sent(),y.label=5;case 5:return f={range:this._syncRange,isPrevSyncComplete:t?t.isPrevSyncComplete:this._isPrevSyncComplete,isNextSyncComplete:this._isNextSyncComplete},[4,u.set({key:p,value:f,generation:1})];case 6:y.sent(),_={source:de.MESSAGE_BACKGROUND,payload:{channel:n,messages:o}},h.send(_),e.hasNext=!this._isNextSyncComplete,y.label=7;case 7:return[2,e]}}))}))}),f,_)}return e.of=function(t,n,r){return void 0===r&&(r=Ze),je[t]||(je[t]={}),je[t][n.url]||(je[t][n.url]=new e({iid:t,channel:n,limit:r})),je[t][n.url]},Object.defineProperty(e.prototype,"priority",{set:function(e){this._prevSync.priority=e,this._nextSync.priority=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"range",{get:function(){return this._syncRange},enumerable:!1,configurable:!0}),e.prototype.resume=function(){J.debug("Message collection background sync has resumed."),this._isPrevSyncComplete||this._prevSync.resume(null),this._isNextSyncComplete||this._nextSync.resume(null)},e.prototype.pause=function(){J.debug("Message collection background sync has paused."),this._prevSync.stop(),this._nextSync.stop()},e.prototype.getMinCreatedAt=function(e){var t=Number.MAX_SAFE_INTEGER;return e.forEach((function(e){var n=e.createdAt;nt&&(t=n)})),t},e}(),qe={},Ke=function(e,t){return"sendbird:".concat(e,"@channel/").concat(t,"/message/changelogs")},ze=function(){function e(e){var t=e.iid,n=e.channel,r=this;this._token=0,this._sync=null,this._iid=t,this._channel=n;var i=x.get(this._iid).BaseChannel,s=U.get(this._iid),a=s.get("currentUserId"),o=s.get("store"),l=s.get("apiClient"),u=s.container.localCacheEnabled,c=Ge.of(this._iid),d=ge.of(this._iid),h=Ke(a,this._channel.url);this._sync=new ut(h,(function(e){return L(r,void 0,void 0,(function(){var e,t,r,a,p,f,_,g,y,m=this;return P(this,(function(E){switch(E.label){case 0:return e={hasNext:!0,nextParams:""},u?[4,o.get(h)]:[3,2];case 1:return r=E.sent(),[3,3];case 2:r=null,E.label=3;case 3:t=r,this._token=t?t.token:s.get("firstConnectedAt")/1e3,a={channelUrl:this._channel.url,isOpenChannel:this._channel.isOpenChannel(),includeMetaArray:!0,includeReactions:!0,includeReplies:!0,includeParentMessageText:!0,includeThreadInfo:!0},"number"==typeof this._token?a.timestamp=this._token:a.token=this._token,E.label=4;case 4:return E.trys.push([4,12,,15]),[4,l.getMessageChangeLogs(a)];case 5:return p=E.sent(),f=p.updated.map((function(e){return i.buildMessage(e,m._channel)})),_={updatedMessages:f,deletedMessageIds:p.deleted.map((function(e){return parseInt(e.message_id)}))},e.hasNext=p.has_more,e.nextParams=this._token=p.next,u?(g=[],f.forEach((function(e){(e.isUserMessage()||e.isFileMessage())&&e._isSentByMe()&&g.push(e.reqId)})),g.length>0?[4,c.removeUnsentMessages({channelUrl:this._channel.url,reqIds:g})]:[3,7]):[3,11];case 6:E.sent(),E.label=7;case 7:return[4,c.upsert(f)];case 8:return E.sent(),[4,c.remove(_.deletedMessageIds)];case 9:return E.sent(),[4,o.set({key:h,value:{token:this._token},generation:1})];case 10:E.sent(),E.label=11;case 11:return J.debug("Message collection changelog sync update messages count: ",_.updatedMessages.length),J.debug("Message collection changelog sync deleted message ids count: ",_.deletedMessageIds.length),y={source:de.MESSAGE_CHANGELOG,payload:R({channel:n},_)},d.send(y),[2,e];case 12:return E.sent().isInvalidTokenError?[4,o.remove(h)]:[3,14];case 13:E.sent(),E.label=14;case 14:return[3,15];case 15:return[2]}}))}))}))}return e.of=function(t,n){return qe[t]||(qe[t]={}),qe[t][n.url]||(qe[t][n.url]=new e({iid:t,channel:n})),qe[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",e.CACHE_ONLY="cache_only"}(Fe||(Fe={}));var Ye,Qe=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}(),We=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},Je=function(){function e(){}return e.prototype.isNetworkConnected=function(){return!("undefined"==typeof navigator||!navigator.onLine)},e.ready=function(){return L(this,void 0,void 0,(function(){return P(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"}(Ye||(Ye={}));var Xe,Ze=100,$e=new xe({top:Number.MAX_SAFE_INTEGER,bottom:0}),et=new Map,tt=function(e){return"sendbird@message/fill/".concat(e,"/").concat(We())},nt=function(){function e(e){var t=e.iid,n=e.channel,r=e.startingPoint,i=e.filter,s=e.limit,a=void 0===s?100:s,o=this;this._hugeGapCheckTimer=null,this._messages=[],this._syncRange=new xe(R({},$e)),this._hasPrevious=!0,this._hasNext=!0,this._unsentMessages=[],this._iid=t,this._channel=n,this._startingPoint=r,this._filter=i,this._limit=a,this._syncLimit=Math.max(a,Ze),this._eventObserver={onevent:function(e){return L(o,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return[4,this._handleEvent(e)];case 1:return t.sent(),[2]}}))}))}},this._eventHandler={onMessagesAdded:Oe,onMessagesUpdated:Oe,onMessagesDeleted:Oe,onChannelUpdated:Oe,onChannelDeleted:Oe,onHugeGapDetected:Oe};var l=U.get(this._iid);this._localCacheEnabled=l.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=Ve.of(this._iid,this._channel,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=ze.of(this._iid,this._channel),this._connectionObserver={onConnect:function(){o._checkHugeGap(),o._localCacheEnabled&&o._backgroundSync.resume(),o._changelogSync.resume()},onDisconnect:function(){return L(o,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,Je.ready()];case 1:return e.sent()||(this._previousFillSync.stop(),this._nextFillSync.stop(),this._localCacheEnabled&&this._backgroundSync.pause(),this._changelogSync.pause()),[2]}}))}))}},this._previousFillSync=new ut(tt("prev"),(function(e){return L(o,void 0,void 0,(function(){var t,n,r;return P(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 ke(de.MESSAGE_FILL,t[0].sendingStatus),this._addOnlyMessageToView(t,{context:r}),[2,{hasNext:t.length=n,nextParams:this._syncRange.top}]):[2,{hasNext:!1,nextParams:0}]}}))}))})),this._nextFillSync=new ut(tt("next"),(function(e){return L(o,void 0,void 0,(function(){var t,n,r;return P(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 ke(de.MESSAGE_FILL,t[0].sendingStatus),this._addOnlyMessageToView(t,{context:r}),[2,{hasNext:t.length0){this._removeMatchingUnsentMessagesFromView(o);var u=new ke(t,o[0].sendingStatus);this._addMessagesToView(o,{context:u})}if(l&&l.length>0)if((p=this._removeMessagesFromView(l,{})).length>0){u=new ke(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}}break;case de.LOCAL_MESSAGE_PENDING_CREATED:case de.LOCAL_MESSAGE_RESEND_STARTED:case de.LOCAL_MESSAGE_CANCELED:var c=r,d=(a=c.channel,c.message);u=new ke(t,d.sendingStatus);a.url===this._channel.url&&this._upsertUnsentMessagesToView([d],{context:u});break;case de.EVENT_MESSAGE_SENT:var h=r;a=h.channel,d=h.message;if(a.url===this._channel.url){var p=this._removeMatchingUnsentMessagesFromView([d]);if(this._hasNext){if(p.length>0){u=new ke(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,a,p)}}else{this._addMessagesToView([d],{});var u=new ke(t,d.sendingStatus);p.length>0?this._eventHandler.onMessagesUpdated(u,a,[d]):this._eventHandler.onMessagesAdded(u,a,[d])}}break;case de.EVENT_MESSAGE_RECEIVED:var f=r;a=f.channel,d=f.message;if(a.url===this._channel.url&&!this._hasNext){u=new ke(t,d.sendingStatus);this._addMessagesToView([d],{context:u})}break;case de.LOCAL_MESSAGE_FAILED:var _=r;a=_.channel,d=_.message;if(a.url===this._channel.url&&d.sendingStatus===i.MessageSendingStatus.FAILED){u=new ke(t,d.sendingStatus);this._upsertUnsentMessagesToView([d],{context:u})}break;case de.EVENT_MESSAGE_UPDATED:var g=r;a=g.channel,d=g.message;if(a.url===this._channel.url){u=new ke(t,d.sendingStatus);this._addMessagesToView([d],{context:u,isUpdateOnly:!0})}break;case de.EVENT_MESSAGE_DELETED:var y=r,m=(a=y.channel,y.messageId);if(a.url===this._channel.url)if(et.delete(m),(p=this._removeMessagesFromView([m],{})).length>0){u=new ke(t,p[0].sendingStatus);this._eventHandler.onMessagesDeleted(u,this._channel,p)}break;case de.EVENT_DELIVERY_RECEIPT_UPDATED:case de.EVENT_READ_RECEIPT_UPDATED:if((a=r.channel).isGroupChannel()){o=[];for(var E=0,v=this._messages;E0?et.set(d.messageId,T):et.delete(d.messageId))}if(o.length>0){u=new ke(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}break;case de.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?et.set(d.messageId,T):et.delete(d.messageId))}if(o.length>0){u=new ke(t,o[0].sendingStatus);this._eventHandler.onMessagesUpdated(u,a,o)}}else{u=new Te(t);this._eventHandler.onChannelDeleted(u,a.url)}break;case de.EVENT_CHANNEL_CHANGED:case de.EVENT_USER_RECEIVED_INVITATION:case de.EVENT_USER_JOINED:case de.EVENT_CHANNEL_FROZEN:case de.EVENT_CHANNEL_UNFROZEN:case de.EVENT_CHANNEL_HIDDEN:case de.EVENT_CHANNEL_UNHIDDEN:case de.EVENT_USER_MUTED:case de.EVENT_USER_UNMUTED:case de.EVENT_TYPING_STATUS_UPDATED:case de.EVENT_OPERATOR_UPDATED:case de.EVENT_CHANNEL_METADATA_UPDATED:case de.EVENT_CHANNEL_METADATA_DELETED:case de.EVENT_CHANNEL_METACOUNTER_UPDATED:case de.EVENT_CHANNEL_METACOUNTER_DELETED:a=r.channel,u=new Te(t);this._eventHandler.onChannelUpdated(u,a);break;case de.EVENT_CHANNEL_DELETED:a=r.channel,u=new Te(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 L(this,void 0,void 0,(function(){var e,n,i,a;return P(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={}),L(this,void 0,void 0,(function(){var n,r,i,s;return P(this,(function(a){switch(a.label){case 0:return n=t.context,r=void 0===n?null:n,i=Ge.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._removeMatchingUnsentMessagesFromView(e,{context:r}),[4,i.upsert(e,fe.SUCCEEDED)];case 2:return a.sent(),[2]}}))}))},e.prototype._checkHugeGap=function(){return L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d,h,p,f,_=this;return P(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=Ge.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.hasNext?this._messages[this._messages.length-1].createdAt:Number.MAX_SAFE_INTEGER,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(R(R({},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 ke(de.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,5]);case 4:g.sent(),this._addOnlyMessageToView(h,{context:p}),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 ke(de.MESSAGE_FILL,h[0].sendingStatus),[4,this._upsertRemotelyFetchedMessages(h,{context:p})]):[3,11];case 10:g.sent(),this._addOnlyMessageToView(h,{context:p}),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._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._addOnlyMessageToView=function(e,t){void 0===t&&(t={});var n=t.context,r=void 0===n?null:n;t.isUpdateOnly;for(var i=ji.getInstance(this._iid),s=[],a=0,o=e;a0&&this._eventHandler.onMessagesAdded(r,this._channel,s)},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=ji.getInstance(this._iid),o=[],l=[],u=[],c=0,d=e;c=0){if(l.push(h),this._messages[p]=h,h.updatedAt>0){var _=this._updateChildMessagesInView(h);l=l.concat(_)}}else if(!s){var g=Le(this._messages,h);o.push(h),this._messages.splice(g,0,h)}}else p>=0&&(u.push(h),this._messages.splice(p,1))}}r&&(o.length>0&&this._eventHandler.onMessagesAdded(r,this._channel,o),l.length>0&&this._eventHandler.onMessagesUpdated(r,this._channel,l),u.length>0&&this._eventHandler.onMessagesDeleted(r,this._channel,u))},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=Le(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._removeMatchingUnsentMessagesFromView=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=ji.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&&!se.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._processAutoResendRegisteredPendingMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h;return P(this,(function(p){switch(p.label){case 0:return t=Ge.of(e._iid),n=ge.of(e._iid),(r=new Re).sendingStatus=e.MessageSendingStatus.PENDING,[4,t.getAllUnsentMessages(r)];case 1:i=p.sent(),s=0,a=i,p.label=2;case 2:return s0?Math.min.apply(Math,this._messages.map((function(e){return e.createdAt}))):Number.MAX_SAFE_INTEGER,[4,Je.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadPrevious() from the cache."),[4,Ge.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),we(this._syncRange,["prev"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return L(this,void 0,void 0,(function(){var e,t;return P(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,Je.ready()]):[3,5];case 1:return n.sent()?[3,3]:(J.debug("Message collection loadNext() from the cache."),[4,Ge.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),we(this._syncRange,["next"],this._messages),[2,t];case 5:return[2,[]]}}))}))},e.prototype.removeFailedMessages=function(e){return L(this,void 0,void 0,(function(){var t,n,r,i;return P(this,(function(s){switch(s.label){case 0:return t=ji.getInstance(this._iid),n=Ge.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 L(this,void 0,void 0,(function(){var e;return P(this,(function(t){switch(t.label){case 0:return e=ji.getInstance(this._iid),[4,Ge.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),ge.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setMessageCollectionHandler=function(e){this._eventHandler=e},e}(),rt=new Map,it=new Map,st=new Map,at=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,i=void 0===r?2:r,s=t.backOffDelay,a=void 0===s?0:s,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=i,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],$()?(rt[this._holdersKey]||(rt[this._holdersKey]=[]),it[this._resolversKey]||(it[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return L(o,void 0,void 0,(function(){var t,n;return P(this,(function(r){if(this._localResolversData.length>0&&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=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));n.length>0?window.localStorage.setItem(o._resolversKey,JSON.stringify(n)):window.localStorage.removeItem(o._resolversKey),o._localAcquiredKeys.forEach((function(e){return o.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-rt[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return $()?it[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if($())return st[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){$()?st[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return L(this,void 0,void 0,(function(){var e;return P(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,L(void 0,void 0,void 0,(function(){return P(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=Ye.BACKGROUND_SYNC_CLOSE),L(this,void 0,void 0,(function(){var t,n=this;return P(this,(function(r){return $()?[2,new Promise((function(t){var r={key:We(),resolver:function(e){return t(e)},priority:e};switch(e){case Ye.USER_CALL:case Ye.FILL:case Ye.BACKGROUND_SYNC_OPEN:for(var i=it[n._resolversKey],s=-1,a=0;ai[a].priority&&(s=a);if(s>=0){it[n._resolversKey].splice(s,0,r);break}case Ye.BACKGROUND_SYNC_CLOSE:it[n._resolversKey].push(r)}n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){var i=We(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e};switch(e){case Ye.USER_CALL:case Ye.FILL:case Ye.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 Ye.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($()){if((t=rt[this._holdersKey].indexOf(e))>=0)return rt[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),n.length>0?window.localStorage.setItem(this._holdersKey,JSON.stringify(n)):window.localStorage.removeItem(this._holdersKey),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($()){if(rt[this._holdersKey].length0?window.localStorage.setItem(this._resolversKey,JSON.stringify(r)):window.localStorage.removeItem(this._resolversKey),window.localStorage.setItem(this._holdersKey,JSON.stringify(w(w([],t,!0),[e],!1))),this._localAcquiredKeys.push(e);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(w([],t,!0)),newValue:JSON.stringify(w(w([],t,!0),[e],!1))});return dispatchEvent(s),(0,n.resolver)(e),!0}}return!1},e.prototype._getLocalHoldersData=function(){var e=window.localStorage[this._holdersKey];return void 0!==e?JSON.parse(e):[]},e.prototype._getLocalResolversData=function(){var e=window.localStorage[this._resolversKey];return void 0!==e?JSON.parse(e):[]},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Xe||(Xe={}));var ot,lt=function(){},ut=function(){function e(e,t,n,r){void 0===n&&(n=2),void 0===r&&(r=10),this._worker=null,this._state=Xe.IDLE,this._retryCount=0,this._retryLimit=3,this._isPaused=!1,this.priority=Ye.BACKGROUND_SYNC_CLOSE,this.onProgress=lt,this.onStop=lt,this.onError=lt,this.onEnd=lt,this._key=e,this._worker=t,this._semaphore=new at({key:e,concurrentCallLimit:n,backOffDelay:r})}return Object.defineProperty(e.prototype,"isIdle",{get:function(){return this._state===Xe.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isRunning",{get:function(){return this._state===Xe.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDone",{get:function(){return this._state===Xe.END},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPaused",{get:function(){return this._isPaused},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),e.prototype.resume=function(e,t){return void 0===t&&(t=!1),this._isPaused=!1,this.isDone&&t&&(this._state=Xe.IDLE),this.run(e)},e.prototype.run=function(e){return L(this,void 0,void 0,(function(){var t,n,r;return P(this,(function(i){switch(i.label){case 0:return this._isPaused||!this.isIdle?[3,5]:(t=this,[4,this._semaphore.acquire(this.priority)]);case 1:t._key=i.sent(),this._state=Xe.RUNNING,i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this._worker(e)];case 3:return n=i.sent(),this._retryCount=0,this.onProgress(n),n.hasNext?(this._state=Xe.IDLE,this._isPaused?(this._semaphore.release(this._key),this.onStop()):(this.run(n.nextParams),this._semaphore.release(this._key))):(this._state=Xe.END,this._semaphore.release(this._key),this.onEnd(),this._isPaused&&this.onStop()),[3,5];case 4:return r=i.sent(),J.warn("Collection sync run error: ",r),this._state=Xe.IDLE,this._semaphore.release(this._key),this.onError(r),this._retryCount=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 4:return p.sent(),[4,u.set({key:h,value:{token:this._token,range:this._syncRange,completed:this._completed,primaryKeyIndex:this._pkIndex},generation:1})];case 5:return p.sent(),a={source:de.CHANNEL_BACKGROUND,payload:{channels:i}},d.send(a),[3,9];case 6:return p.sent().isInvalidTokenError?[4,u.remove(h)]:[3,8];case 7:p.sent(),p.label=8;case 8:return[3,9];case 9:return[3,11];case 10:J.debug("Group channel collection background sync has finished."),e.hasNext=!1,p.label=11;case 11:return[2,e]}}))}))}))}return e.of=function(t,n){return void 0===n&&(n=mt),ct[t]||(ct[t]=new e({iid:t,limit:n})),ct[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}(),ht={},pt=function(){function e(e){var t=e.iid,n=this;this._token=0,this._sync=null,this._pkIndex=Date.now(),this._iid=t;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=bt.of(this._iid),c=ge.of(this._iid),d="sendbird:".concat(s,"@groupchannel/changelogs");this._sync=new ut(d,(function(e){return L(n,void 0,void 0,(function(){var e,t,n,i,s,h,p,f=this;return P(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:(t=n)&&(this._token=t.token,this._pkIndex=t.primaryKeyIndex),i={},"number"==typeof this._token?i.ts=this._token:i.token=this._token,_.label=4;case 4:return _.trys.push([4,10,,13]),[4,o.getMyGroupChannelChangeLogs(i)];case 5:return s=_.sent(),h={updatedChannels:s.updated.map((function(e){return e.cached_primary_key=f._pkIndex--,r.upsert(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,9];case 6:return _.sent(),[4,u.remove(h.deletedChannelUrls)];case 7:return _.sent(),[4,a.set({key:d,value:{token:this._token,primaryKeyIndex:this._pkIndex},generation:1})];case 8:_.sent(),_.label=9;case 9:return p={source:de.CHANNEL_CHANGELOG,payload:h},c.send(p),[2,e];case 10:return _.sent().isInvalidTokenError?[4,a.remove(d)]:[3,12];case 11:_.sent(),_.label=12;case 12:return[3,13];case 13:return[2]}}))}))}))}return e.of=function(t){return ht[t]||(ht[t]=new e({iid:t})),ht[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}(),ft=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 yt(e[s],t,n)>0?s:s+1}return e.length},gt=function(e,t){return t-e},yt=function(e,t,n){switch(n){case ot.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=gt(e.cachedPrimaryKey,t.cachedPrimaryKey))}return s}r=e.createdAt;return 0===(s=t.createdAt-r)&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ot.CHRONOLOGICAL:return 0===(s=t.createdAt-e.createdAt)&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s;case ot.CHANNEL_NAME_ALPHABETICAL:var s;return 0===(s=e.name.localeCompare(t.name))&&(s=gt(e.cachedPrimaryKey,t.cachedPrimaryKey)),s}},mt=40;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical"}(ot||(ot={}));var Et=function(){function e(e){var t=e.iid,n=e.filter,r=e.order,i=e.limit,s=void 0===i?20:i,a=this;this._channels=[],this._token=null,this._hasMore=!0,this._iid=t,this._filter=n,this._order=r,this._limit=s,this._syncLimit=Math.max(s,mt),this._eventObserver={onevent:function(e){return L(a,void 0,void 0,(function(){return P(this,(function(t){return[2,this._handleEvent(e)]}))}))}},this._eventHandler={onChannelsAdded:Oe,onChannelsUpdated:Oe,onChannelsDeleted:Oe};var o=U.get(this._iid);this._localCacheEnabled=o.container.localCacheEnabled,this._localCacheEnabled&&(this._backgroundSync=dt.of(this._iid,this._syncLimit),this._backgroundSync.resume()),this._changelogSync=pt.of(this._iid),ge.of(this._iid).addObserver(this._eventObserver),this._connectionStateObserver={onConnect:function(){a._localCacheEnabled&&a._backgroundSync.resume(),a._changelogSync.resume()},onDisconnect:function(){return L(a,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return[4,Je.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 Te(n);switch(n){case de.CHANNEL_BACKGROUND:break;case de.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 de.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 de.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 de.EVENT_USER_BANNED:case de.EVENT_USER_UNBANNED:break;case de.EVENT_USER_MUTED:case de.EVENT_USER_UNMUTED:case de.EVENT_TYPING_STATUS_UPDATED:case de.EVENT_OPERATOR_UPDATED:case de.EVENT_CHANNEL_METADATA_UPDATED:case de.EVENT_CHANNEL_METADATA_DELETED:case de.EVENT_CHANNEL_METACOUNTER_UPDATED:case de.EVENT_CHANNEL_METACOUNTER_DELETED:h=r.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case de.EVENT_READ_RECEIPT_UPDATED:case de.EVENT_USER_RECEIVED_INVITATION:case de.EVENT_USER_JOINED:case de.EVENT_CHANNEL_FROZEN:case de.EVENT_CHANNEL_UNFROZEN:case de.EVENT_CHANNEL_HIDDEN:case de.EVENT_CHANNEL_UNHIDDEN:case de.EVENT_CHANNEL_CHANGED:h=r.channel;this._filter.match(h)?this._addChannelsToView([h],{context:s}):this._removeChannelsFromView([h.url],{context:s});break;case de.EVENT_CHANNEL_DELETED:var f=r.channelUrl;this._removeChannelsFromView([f],{context:s})}},e.prototype._getRemoteChannels=function(){return L(this,void 0,void 0,(function(){var e,t,n,r;return P(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(R(R({},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,bt.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 L(this,void 0,void 0,(function(){var e,t,n,r,i;return P(this,(function(s){switch(s.label){case 0:return this._hasMore?[4,Je.ready()]:[3,5];case 1:return s.sent()?[3,3]:(J.debug("Group channel collection loadMore() from the cache."),e=bt.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(),ge.of(this._iid).removeObserver(this._eventObserver)},e.prototype.setGroupChannelCollectionHandler=function(e){this._eventHandler=e},e.GroupChannelOrder=ot,e}(),vt={},bt=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,vt[t]=this}return e.of=function(e){return vt[e]},e.prototype._serialize=function(e){var t=this._createPk();return e.cachedPrimaryKey=t,R(R({},e.serialize()),{lastMessageCreatedAt:e.lastMessage?e.lastMessage.createdAt:-1,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 L(this,void 0,void 0,(function(){var r,i,s,a,o,l,u,c=this;return P(this,(function(d){switch(d.label){case 0:if(!this._localCacheEnabled)return[3,2];switch(r=Ue.LATEST_LAST_MESSAGE,t){case ot.CHANNEL_NAME_ALPHABETICAL:r=Ue.NAME_ALPHABETICAL;break;case ot.CHRONOLOGICAL:r=Ue.CHRONOLOGICAL;break;case ot.LATEST_LAST_MESSAGE:r=Ue.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 ot.LATEST_LAST_MESSAGE:if(n.lastMessageCreatedAt>s)return!1;if(n.lastMessageCreatedAt===s&>(l,n.pk)>=0)return!1;if(n.lastMessageCreatedAt<0){if(n.createdAt>a)return!1;if(n.createdAt===a&>(l,n.pk)>=0)return!1}break;case ot.CHANNEL_NAME_ALPHABETICAL:var r=n.name.localeCompare(o);if(r<0)return!1;if(0===r&>(l,n.pk)>=0)return!1;break;case ot.CHRONOLOGICAL:if(n.createdAt>a)return!1;if(n.createdAt===a&>(l,n.pk)>=0)return!1}return e.match(c._deserialize(n))},index:r},[4,this._collection.query(u).fetch({limit:n.limit})];case 1:return[2,d.sent().map((function(e){return c._deserialize(e)}))];case 2:return[2,[]]}}))}))},e.prototype.getNextContainerToken=function(e,t){switch(e){case ot.LATEST_LAST_MESSAGE:return t.length>0?{lastMessageCreatedAt:(n=t[t.length-1]).lastMessage?n.lastMessage.createdAt:-1,createdAt:n.createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{lastMessageCreatedAt:Number.MAX_SAFE_INTEGER,createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ot.CHRONOLOGICAL:return t.length>0?{createdAt:(n=t[t.length-1]).createdAt,lastFetchedPrimaryKey:n.cachedPrimaryKey}:{createdAt:Number.MAX_SAFE_INTEGER,lastFetchedPrimaryKey:this._lastFetchedPrimaryKey};case ot.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 L(this,void 0,void 0,(function(){var t;return P(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),L(this,void 0,void 0,(function(){return P(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 L(this,void 0,void 0,(function(){var t,n=this;return P(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 L(this,void 0,void 0,(function(){return P(this,(function(t){switch(t.label){case 0:return this._localCacheEnabled?[4,this._collection.removeIf({where:{url:{"/in":e}}})]:[3,3];case 1:return t.sent(),[4,ji.getInstance(this._iid).clearCachedMessages(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return L(this,void 0,void 0,(function(){return P(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}(),Ct=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}(),At=function(e){return Object.keys(e).forEach((function(t){e[t]&&"object"==typeof e[t]&&At(e[t])})),Object.freeze(e)},Nt=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),At(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}(),St={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},It=new WeakMap,Tt=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.mentionedMessageTemplate=null,this.sendingStatus=null,It.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 Nt.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 se.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=ji.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;if(e.hasOwnProperty("msg_id")&&e.msg_id&&(this.messageId=parseInt(e.msg_id)),e.hasOwnProperty("type"))switch(e.type){case"MESG":this.messageType=o.MESSAGE_TYPE_USER;break;case"FILE":this.messageType=o.MESSAGE_TYPE_FILE;break;case"BRDM":case"ADMM":this.messageType=o.MESSAGE_TYPE_ADMIN}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&&It.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:"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=me.parse(arguments,[new me({type:Ct,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=t)return this.parentMessage=e,!0}return!1}},{key:"_setRootMessageId",value:function(e){It.set(this,e)}}],[{key:"MESSAGE_TYPE_BASE",get:function(){return"base"}},{key:"MESSAGE_TYPE_ADMIN",get:function(){return"admin"}},{key:"MESSAGE_TYPE_USER",get:function(){return"user"}},{key:"MESSAGE_TYPE_FILE",get:function(){return"file"}},{key:"SendingStatus",get:function(){return{NONE:"none",PENDING:"pending",FAILED:"failed",CANCELED:"canceled",SUCCEEDED:"succeeded"}}},{key:"ReplyType",get:function(){return{ALL:"all",NONE:"none",ONLY_REPLY_TO_CHANNEL:"only_reply_to_channel"}}},{key:"getMessage",value:function(e,t){var n=this,r=x.get(this._iid),i=r.BaseChannel,s=r.MessageRetrievalParams,a=null,o=me.parse(arguments,[new me({type:s,constraint:function(e){return e._validate()}}),new me({type:"callback"})]),u=C(o,3);return a=u[0],e=u[1],t=u[2],oe(this._iid,(function(t){if(a)t(a,null);else{var r=x.get(n._iid),s=r.GroupChannel,o=r.OpenChannel;switch(e.channelType){case i.CHANNEL_TYPE_GROUP:s.getChannel(e.channelUrl,T.INTERNAL_CALL,(function(r,s){if(ji.getInstance(n._iid).getErrorFirstCallback()){var a=[r,s];s=a[0],r=a[1]}s?t(s,null):U.get(n._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,n){if(e)t(e,null);else{var s=i.buildMessage(n,r);t(null,s)}}))}));break;case i.CHANNEL_TYPE_OPEN:o.getChannel(e.channelUrl,T.INTERNAL_CALL,(function(r,s){if(ji.getInstance(n._iid).getErrorFirstCallback()){var a=[r,s];s=a[0],r=a[1]}s?t(s,null):U.get(n._iid).container.apiClient.getMessage(l({channel:r},e),(function(e,n){if(e)t(e,null);else{var s=i.buildMessage(n,r);t(null,s)}}))}))}}}),t)}}]),e}(),Ot=function(){function e(e){this.nickname="",this.plainProfileUrl="",this.userId="",this.connectionStatus="",this.lastSeenAt=null,this.metaData={},this.isActive=!0,this.friendDiscoveryKey=null,this.friendName=null,this._preferredLanguages=null,this.requireAuth=null,e&&this.__update(e)}return e.objectify=function(e){var t=e.userId,n=void 0===t?null:t,r=e.nickname,i=void 0===r?"":r,s=e.plainProfileUrl,a=void 0===s?"":s,o=e.connectionStatus,l=void 0===o?"":o,u=e.lastSeenAt,c=void 0===u?0:u,d=e.metaData,h=void 0===d?{}:d,p=e.isActive,f=void 0===p||p,_=e.friendDiscoveryKey,g=void 0===_?null:_,y=e.friendName,m=void 0===y?null:y,E=e.preferredLanguages,v=void 0===E?null:E,b=e.requireAuth;return{user_id:n,nickname:i,profile_url:a,is_online:l,last_seen_at:c,metadata:h,is_active:f,friend_discovery_key:g,friend_name:m,preferred_languages:v,require_auth_for_profile_image:void 0!==b&&b}},e.buildFromSerializedData=function(e){var t=x.get(this._iid).User,n=Nt.deserialize(e);return new t(t.objectify(n))},Object.defineProperty(e.prototype,"preferredLanguages",{get:function(){return this._preferredLanguages},enumerable:!1,configurable:!0}),e.prototype.__update=function(t){var n=U.get(this._iid).container.auth;t.hasOwnProperty("guest_id")&&(this.userId=t.guest_id),t.hasOwnProperty("user_id")&&(this.userId=t.user_id),t.hasOwnProperty("name")&&(this.nickname=t.name),t.hasOwnProperty("nickname")&&(this.nickname=t.nickname),t.hasOwnProperty("require_auth_for_profile_image")?this.requireAuth=t.require_auth_for_profile_image:this.requireAuth=null,(t.hasOwnProperty("image")||t.hasOwnProperty("profile_url"))&&(this.plainProfileUrl=t.image||t.profile_url||"",Object.defineProperty(this,"profileUrl",{value:this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(n.eKey):this.plainProfileUrl,configurable:!0,writable:!1})),t.hasOwnProperty("is_online")?t.is_online===e.NON_AVAILABLE?this.connectionStatus=e.NON_AVAILABLE:this.connectionStatus=t.is_online?e.ONLINE:e.OFFLINE:this.connectionStatus=e.NON_AVAILABLE,t.hasOwnProperty("last_seen_at")?this.lastSeenAt=parseInt(t.last_seen_at):this.lastSeenAt=0,t.hasOwnProperty("metadata")?this.metaData=t.metadata:this.metaData={},t.hasOwnProperty("is_active")?this.isActive=void 0===t.is_active||t.is_active:this.isActive=!0,t.hasOwnProperty("friend_discovery_key")?this.friendDiscoveryKey=t.friend_discovery_key:this.friendDiscoveryKey=null,t.hasOwnProperty("friend_name")?this.friendName=t.friend_name:this.friendName=null,t.hasOwnProperty("preferred_languages")?this._preferredLanguages=t.preferred_languages||null:this._preferredLanguages=null},e.prototype._updateMetaData=function(e,t){var n=this;void 0===t&&(t=!1);var r=x.get(this._iid).GroupChannel;Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]})),Object.keys(r.cachedChannels).forEach((function(e){if(r.cachedChannels.hasOwnProperty(e)){var t=r.cachedChannels[e];if(t.memberMap.hasOwnProperty(n.userId))t.memberMap[n.userId].metaData=n.metaData}}))},e.prototype.serialize=function(){return Nt.serialize(this,(function(e){e.hasOwnProperty("_preferredLanguages")&&(e.preferredLanguages=e._preferredLanguages,delete e._preferredLanguages)}))},e.prototype.getOriginalProfileUrl=function(){var e="";if(((e=(e=this.plainProfileUrl.indexOf("://")>-1?this.plainProfileUrl.split("/")[2]:this.plainProfileUrl.split("/")[0]).split("?")[0]).indexOf("sendbird.com")>-1||e.indexOf("sendbirdtest.com")>-1||e.indexOf("intoz.com")>-1||e.indexOf("file-local")>-1)&&this.plainProfileUrl.indexOf(e+"/profile_images/")>-1){var 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=me.parse(arguments,[new me({type:"object",constraint:function(e){return Object.keys(e).length>0&&!Array.isArray(e)}}),new me({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=me.parse(arguments,[new me({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 me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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}(),Ut={TIMESTAMP:"timestamp",MESSAGE_ID:"messageId"},Mt=new WeakMap,kt=new WeakMap,Rt=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,Mt.set(this,{}),kt.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 Ot(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):this._refreshMetaData(e.metadata,-1)),e.hasOwnProperty("cached_primary_key")&&(this.cachedPrimaryKey=e.cached_primary_key)}},{key:"_addOrUpdateCachedMetaData",value:function(e,t){var n=this,r=Mt.get(this);Object.keys(e).forEach((function(i){var s=r[i],a=e[i];s?t>s.updatedAt&&(s.value=a,s.updatedAt=t,s.isRemoved=!1):r[i]={value:a,updatedAt:t,isRemoved:!1},bt.of(n._iid).upsert([n]).then((function(){})).catch((function(e){J.error(e)}))}))}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var n=this,r=Mt.get(this);e.forEach((function(e){var i=r[e];i?t>i.updatedAt&&(i.isRemoved=!0,i.updatedAt=t):r[e]={value:null,updatedAt:t,isRemoved:!0},bt.of(n._iid).upsert([n]).then((function(){})).catch((function(e){J.error(e)}))}))}},{key:"_refreshMetaData",value:function(e,t){var n={};Object.keys(e).forEach((function(r){n[r]={value:e[r],updatedAt:t,isRemoved:!1}})),Mt.set(this,n)}},{key:"_clearCachedMetaData",value:function(){Mt.set(this,{})}},{key:"cachedPrimaryKey",get:function(){return kt.get(this)},set:function(e){kt.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 Nt.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),t.metadata=e.getCachedMetaData(),e.cachedPrimaryKey&&(t.cachedPrimaryKey=e.cachedPrimaryKey)}))}},{key:"getMessageChangeLogsByTimestamp",value:function(e,t,n,r){var i=this,s=null,a=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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=ji.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=me.parse(g,[new me({type:"number"}),new me({type:"boolean"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(g,[new me({type:"number"}),new me({type:"boolean"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(g,[new me({type:"number"}),new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({type:"string"}),new me({type:"string"}),new me({type:"array",optional:!0}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"number"}),new me({type:"string",constraint:function(e){return Object.values(Ut).includes(e)}}),new me({type:a,constraint:function(e){return e._validate()}}),new me({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(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getPreviousAndNextMessagesByTimestamp",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.TIMESTAMP,r,i)}},{key:"getPreviousMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prev"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["next"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getPreviousAndNextMessagesByID",value:function(e){var t=this._parseMessageListParams.apply(this,["prevnext"].concat(A(me.toArray(arguments)))),n=C(t,2),r=n[0],i=n[1];return this._getMessageList(e,Ut.MESSAGE_ID,r,i)}},{key:"getMessagesByTimestamp",value:function(e,t,n){return this._getMessageList(e,Ut.TIMESTAMP,t,n)}},{key:"getMessagesByMessageId",value:function(e,t,n){return this._getMessageList(e,Ut.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.mentionedUsers,d=e.mentionedMessageTemplate,h=e.pushNotificationDeliveryOption,p=e.rootMessageId,f=e.parentMessageId,_=e.translationTargetLanguages,g=e.appleCriticalAlertOptions,y=e.pollId,m=e.silent,E=void 0!==m&&m,v=e.isReplyToChannel,b=e.messageParams,C=e.oldMessage,A=void 0===C?null:C,N=e.isManualResend,S=void 0!==N&&N,I=e.callback,T=x.get(this._iid),O=T.Command,M=T.UserMessage,k=ji.getInstance(this._iid),R=Ge.of(this._iid),L=bt.of(this._iid),P=ge.of(this._iid),w=U.get(this._iid).container.localCacheEnabled;n||(n=O.generateRequestId());var D={};Array.isArray(_)&&_.forEach((function(e){return D[e]=""}));var F=M.objectify({messageId:0,reqId:n,user:k.currentUser||{},channel:this,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedUsers:c,mentionedMessageTemplate:d,rootMessageId:p,parentMessageId:f,translations:D,silent:E,appleCriticalAlertOptions:g,isReplyToChannel:v,messageParams:b,createdAt:(new Date).getTime()}),G=new M(F);if(G.requestState=k.MessageRequestState.PENDING,G.sendingStatus=k.MessageSendingStatus.PENDING,G.requestedMentionUserIds=u,G._messageParams=b,!k.currentUser){var j=new H("Connection should be made first.",H.CONNECTION_REQUIRED),B=new M(F);return B.requestState=k.MessageRequestState.FAILED,B.sendingStatus=k.MessageSendingStatus.FAILED,B.requestedMentionUserIds=u,B.errorCode=j.code,I(j,B),G}return(!t.isGroupChannel()||A&&A._isAutoResendRegistered?Promise.resolve():R.upsert([G],fe.UNSENT).then((function(){P.send({source:S?de.LOCAL_MESSAGE_RESEND_STARTED:de.LOCAL_MESSAGE_PENDING_CREATED,payload:{channel:t,message:G}})}))).then((function(){var e=O.bMessage({channelUrl:t.url,message:r,data:i,customType:s,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedMessageTemplate:d,requestId:n,rootMessageId:p,parentMessageId:f,silent:E,translationTargetLanguages:_,pushNotificationDeliveryOption:h,appleCriticalAlertOptions:g,pollId:y,isReplyToChannel:v});(G.reqId=e.requestId,t.isGroupChannel()&&k.getConnectionState()!==k.ConnectionState.OPEN&&k.currentUser&&!k.connecting&&!k.reconnecting&&"string"==typeof s&&0===s.indexOf("SB_VIDEOCHAT"))?U.get(k._iid).container.apiClient.sendUserMessage({channelUrl:t.url,isOpenChannel:t.isOpenChannel(),message:r,data:i,customType:s,translationTargetLanguages:_,metaArrays:a,mentionType:o,mentionedUserIds:u,mentionedMessageTemplate:d,pushNotificationDeliveryOption:h,rootMessageId:p,parentMessageId:f,appleCriticalAlertOptions:g,pollId:y,isReplyToChannel:v},(function(e,r){var i=null;if(e){if(G._isAutoResendRegistered&&se.isAutoResendableError(e.code))return;(i=new M(F)).requestState=k.MessageRequestState.FAILED,i.requestedMentionUserIds=u,A&&(i._isAutoResendRegistered=A._isAutoResendRegistered),e.code===H.REQUEST_CANCELED?(i.sendingStatus=k.MessageSendingStatus.CANCELED,R.removeUnsentMessages({channelUrl:t.url,sendingStatus:k.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){P.send({source:de.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(new H(e.message,e.code),i)}))):(i.errorCode=e.code,i.sendingStatus=k.MessageSendingStatus.FAILED,w&&se.isAutoResendableError(e.code)&&(i.sendingStatus=k.MessageSendingStatus.PENDING,i.errorCode=0,i._isAutoResendRegistered=!0),R.upsert([i],fe.UNSENT).then((function(){nt._completeCurrentAndProcessNextAutoResend(k,i),P.send({source:de.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){var t=i._clone();t.sendingStatus=k.MessageSendingStatus.FAILED,t.errorCode=e.code,t._isAutoResendRegistered=!1,I&&I(new H(e.message,e.code),t)})))}else{for(var s in(i=new M(r)).reqId=n,i.requestState=k.MessageRequestState.SUCCEEDED,i.sendingStatus=k.MessageSendingStatus.SUCCEEDED,A&&(i._isAutoResendRegistered=A._isAutoResendRegistered),t.lastMessage=i,k.channelHandlers){k.channelHandlers[s].onChannelChanged(t)}L.upsert([t]).then((function(){P.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return R.removeUnsentMessages({channelUrl:t.url,sendingStatus:k.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return R.upsert([i],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(k,i),P.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:t,message:i}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(null,i)}))}})):k.sendCommand(e,(function(r,i){if(k.getErrorFirstCallback()){var s=[r,i];i=s[0],r=s[1]}if(i){if(G._isAutoResendRegistered&&se.isAutoResendableError(i.code))return;var a=new M(F);a.reqId=e.requestId,a.requestState=k.MessageRequestState.FAILED,i.code===H.REQUEST_CANCELED?(a.sendingStatus=k.MessageSendingStatus.CANCELED,t.isGroupChannel()&&R.removeUnsentMessages({channelUrl:t.url,sendingStatus:k.MessageSendingStatus.PENDING,reqIds:[n]}).then((function(){P.send({source:de.LOCAL_MESSAGE_CANCELED,payload:{channel:t,message:a}})})).catch((function(e){return J.error(e)})).finally((function(){I&&I(new H(i.message,i.code),a)}))):(a.sendingStatus=k.MessageSendingStatus.FAILED,a.errorCode=i.code,a.requestedMentionUserIds=u,t.isGroupChannel()?(w&&se.isAutoResendableError(i.code)&&(a.sendingStatus=k.MessageSendingStatus.PENDING,a.errorCode=0,a._isAutoResendRegistered=!0),R.upsert([a],fe.UNSENT).then((function(){return nt._completeCurrentAndProcessNextAutoResend(k,a),P.send({source:de.LOCAL_MESSAGE_FAILED,payload:{channel:t,message:a}})})).catch((function(e){J.error(e)})).finally((function(){var e=a._clone();e.sendingStatus=k.MessageSendingStatus.FAILED,e.errorCode=i.code,e._isAutoResendRegistered=!1,I&&I(new H(i.message,i.code),e)}))):I&&I(new H(i.message,i.code),a))}else{var o=new M(l(l({},r.getJsonElement()),{},{messageParams:b}));o.reqId=n,o.requestState=k.MessageRequestState.SUCCEEDED,o.sendingStatus=k.MessageSendingStatus.SUCCEEDED,A&&(o._isAutoResendRegistered=A._isAutoResendRegistered);var c=k.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),se.deepEqual(c.metaData,o._sender.metaData)||(c.metaData=o._sender.metaData)),t.isGroupChannel()){t.lastMessage=o,Object.keys(k.channelHandlers).forEach((function(e){k.channelHandlers[e].onChannelChanged(t)}));var d=ge.of(t._iid);bt.of(t._iid).upsert([t]).then((function(){d.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).then((function(){return R.removeUnsentMessages({channelUrl:t.url,sendingStatus:k.MessageSendingStatus.PENDING,reqIds:[n]})})).then((function(){return R.upsert([o],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(k,o),d.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:t,message:o}})})).catch((function(e){J.error(e)})).finally((function(){I&&I(null,o)}))}else I&&I(null,o)}}))})),G}},{key:"sendUserMessage",value:function(){var e=me.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=me.error}else n=me.error;else n=me.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,mentionedUsers:r.mentionedUsers,mentionedMessageTemplate:r.mentionedMessageTemplate,rootMessageId:r.rootMessageId,parentMessageId:r.parentMessageId,translationTargetLanguages:r._translationTargetLanguages,messageParams:r,callback:function(e,n){o?t(e,n):t(n,e)}})):(o?t(me.error,null):t(null,me.error),null)}},{key:"_autoResendUserMessage",value:function(e){var t=this,n=ji.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=ji.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=me.parse(arguments,[new me({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 me({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=me.parse(d,[new me({type:"number"}),new me({type:c}),new me({type:"callback"})]),_=C(f,4);h=_[0],e=_[1],p=_[2],i=_[3];break;case 5:p=new c;var g=me.parse(d,[new me({type:"number"}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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,mentionedMessageTemplate:p.mentionedMessageTemplate})),r=ji.getInstance(s._iid);r.sendCommand(n,(function(e,n){if(r.getErrorFirstCallback()){var i=[e,n];n=i[0],e=i[1]}var a=null;if(!n&&(a=new u(l(l({},e.getJsonElement()),{},{messageParams:p})),s.isGroupChannel())){var o=!1;s.lastMessage?(s.lastMessage.createdAt=0}}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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=se.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=me.error;return se.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,n=ji.getInstance(this._iid),r=x.get(this._iid),i=r.Command,s=r.FileMessage,a=l(l({},e),{},{messageId:0,reqId:null!==(t=e.reqId)&&void 0!==t?t:i.generateRequestId(),user:n.currentUser||{},channel:this,plainUrl:"string"==typeof e.file?e.file:"",thumbnails:e.thumbnailSizes.map((function(e){return{url:"",plainUrl:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}})),sendingStatus:n.MessageSendingStatus.PENDING,createdAt:(new Date).getTime()}),o=s.objectify(a);return new s(o)}catch(e){return null}}},{key:"sendFileMessage",value:function(){var e=this,t=me.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=ji.getInstance(this._iid);if(o&&o.currentUser||(n.error=new H("Connection should be made first.",H.CONNECTION_REQUIRED)),this.isGroupChannel()){var l=Ge.of(this._iid),u=ge.of(this._iid);l.upsert([s],fe.UNSENT).then((function(){u.send({source:de.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(me.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=me.parse(arguments,[new me({type:s,constraint:function(e){return 0===e.messageId&&e.isResendable()&&e.reqId&&e.channelUrl===r.url&&Array.isArray(e.thumbnails)}}),new me({type:"file",optionalIf:function(e){var t,n,r=!!e[0].plainUrl,i=se.isFile(null===(t=e[0])||void 0===t||null===(n=t.messageParams)||void 0===n?void 0:n.file);return r||i},defaultValue:null}),new me({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,s=new a;s._reqId=e.reqId,e.plainUrl?s.fileUrl=e.plainUrl:t?s.file=t:se.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)&&(s.file=e.messageParams.file),s.fileName=e.name,s.fileSize=e.size,s.mimeType=e.type,s.data=e.data,s.customType=e.customType,s.mentionType=e.mentionType,s.mentionedUserIds=e.requestedMentionUserIds,s.metaArrays=e.metaArrays,s.thumbnailSizes=e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),s.appleCriticalAlertOptions=e.appleCriticalAlertOptions,r.sendFileMessage(s,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=me.parse(c,[new me({type:"number"}),new me({type:u}),new me({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 _=me.parse(c,[new me({type:"number"}),new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({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=ji.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=!1;i.lastMessage?(i.lastMessage.createdAt0}}),new me({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=ji.getInstance(this._iid),s=x.get(this._iid),a=s.ReactionEvent,o=null,u=me.parse(arguments,[new me({type:Tt}),new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return!Array.isArray(e)&&null!==e&&e.hasOwnProperty("messageId")}}),new me({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=Ge.of(n._iid),a=ge.of(n._iid);s.remove([e.messageId],fe.SUCCEEDED).then((function(){a.send({source:de.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=me.parse(arguments,[new me({type:e}),new me({type:s}),new me({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(me.error,null):r(null,me.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);f.forEach((function(e){return""}));var _=a.PushNotificationDeliveryOption.DEFAULT;return t._sendUserMessage(l(l({},n),{},{reqId:null,pushNotificationDeliveryOption:_,translationTargetLanguages:f,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=me.parse(arguments,[new me({type:e}),new me({type:o}),new me({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(me.error,null):r(null,me.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=ji.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,M=y.thumbnails,k=y.requireAuth,R=y.messageSurvivalSeconds,L=y.silent,P=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:M,requireAuth:k,messageSurvivalSeconds:R,silent:L,createdAt:(new Date).getTime(),appleCriticalAlertOptions:P}),q=new o(V);if(q.requestState=g.MessageRequestState.PENDING,q.sendingStatus=g.MessageSendingStatus.PENDING,!g.currentUser){var K=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=K.code,f?r(K,z):r(z,K),q}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:M,requireAuth:k,pushNotificationDeliveryOption:B,silent:L,appleCriticalAlertOptions:P});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=ge.of(i._iid);bt.of(i._iid).upsert([t]).then((function(){c.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}})})).catch((function(e){J.error(e)})),Ge.of(i._iid).upsert([l]).then((function(){c.send({source:de.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:M,requireAuth:k,pushNotificationDeliveryOption:B,appleCriticalAlertOptions:P},(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)}})),q}},{key:"addOperators",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({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 me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({type:"string"}),new me({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=Mt.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return Object.keys(e).map((function(t){return e[t]})).every((function(e){return"string"==typeof e}))}}),new me({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,r){if(r&&r.ts){var i=r.metadata;n._addOrUpdateCachedMetaData(i,r.ts),t(e,i)}else t(e,r)}))}),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(n,r){if(r&&r.ts){var i=r.metadata;t._refreshMetaData(i,r.ts),e(n,i)}else e(n,r)}))}),e)}},{key:"createMetaData",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&!Array.isArray(e)&&Object.keys(e).length>0}}),new me({type:"boolean",optional:!0,defaultValue:!1}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=ji.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(me.error,null)}),r)}},{key:"createMessageMetaArrayKeys",value:function(e,t,n){var r=x.get(this._iid),i=r.MessageMetaArray,s=null,a=me.parse(arguments,[new me({type:Tt}),new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e&&""!==e}))}}),new me({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 me({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=me.parse(arguments,[new me({type:Tt}),new me({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 me({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=me.parse(arguments,[new me({type:s.ReportCategory}),new me({type:"string"}),new me({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=ji.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=me.parse(arguments,[new me({type:Ot}),new me({type:a.ReportCategory}),new me({type:"string"}),new me({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=ji.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=me.parse(arguments,[new me({type:Tt}),new me({type:a.ReportCategory}),new me({type:"string"}),new me({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=ji.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}(),Lt=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):Rt.CHANNEL_TYPE_GROUP,this.channel=t.hasOwnProperty("channel")?t.channel:null)}return h(e,[{key:"isGroupChannel",value:function(){return this.channelType===Rt.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===Rt.CHANNEL_TYPE_OPEN}}]),e}();Lt.CATEGORY_NONE=0,Lt.CATEGORY_CHANNEL_ENTER=10102,Lt.CATEGORY_CHANNEL_EXIT=10103,Lt.CATEGORY_USER_CHANNEL_MUTE=10201,Lt.CATEGORY_USER_CHANNEL_UNMUTE=10200,Lt.CATEGORY_USER_CHANNEL_BAN=10601,Lt.CATEGORY_USER_CHANNEL_UNBAN=10600,Lt.CATEGORY_CHANNEL_FREEZE=10701,Lt.CATEGORY_CHANNEL_UNFREEZE=10700,Lt.CATEGORY_TYPING_START=10900,Lt.CATEGORY_TYPING_END=10901,Lt.CATEGORY_CHANNEL_JOIN=1e4,Lt.CATEGORY_CHANNEL_LEAVE=10001,Lt.CATEGORY_CHANNEL_OPERATOR_UPDATE=10002,Lt.CATEGORY_CHANNEL_INVITE=10020,Lt.CATEGORY_CHANNEL_DECLINE_INVITE=10022,Lt.CATEGORY_CHANNEL_PROP_CHANGED=11e3,Lt.CATEGORY_CHANNEL_DELETED=12e3,Lt.CATEGORY_CHANNEL_META_DATA_CHANGED=11100,Lt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED=11200,Lt.CATEGORY_CHANNEL_HIDE=13e3,Lt.CATEGORY_CHANNEL_UNHIDE=13001;var Pt=h((function e(t){c(this,e),t&&(this.category=t.hasOwnProperty("cat")?parseInt(t.cat):0)}));Pt.CATEGORY_USER_BLOCK=20001,Pt.CATEGORY_USER_UNBLOCK=2e4,Pt.CATEGORY_FRIEND_DISCOVERED=20900;var wt=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,M=A.sessionManager,k=A.ackStateMap,R=new r(e),L=R.getJsonElement();if(L.hasOwnProperty("unread_cnt")&&"object"===u(L.unread_cnt)){var P=!1,w=L.unread_cnt.ts;"number"==typeof w&&w>O.ts&&(O.all!==L.unread_cnt.all&&(P=!0),O.all=L.unread_cnt.all>=0?L.unread_cnt.all:0,L.unread_cnt.custom_types&&Object.keys(L.unread_cnt.custom_types).forEach((function(e){O.custom_types[e]!==L.unread_cnt.custom_types[e]&&(P=!0),O.custom_types[e]=L.unread_cnt.custom_types[e]})),P=P&&O.ts>0,O.ts=w),P&&Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onTotalUnreadMessageCountUpdated(O.all,O.custom_types)}))}var D=R.requestId;if(D){var F=k[D];if(F){clearTimeout(F.timer);var G=F.handler;G&&("EROR"===R.command?G(new H(L.message,L.code),null):G(null,R)),k.hasOwnProperty(D)&&delete k[D]}}else{N&&"LOGI"!==R.command&&N.refreshTimer();var x,j=bt.of(this.sb._iid),B=Ge.of(this.sb._iid),V=ge.of(this.sb._iid);switch(R.command){case"LOGI":if(this.sb.loginTimer)if(clearTimeout(this.sb.loginTimer),this.sb.loginTimer=null,this.sb.onLoginTimerCancel=null,L.hasOwnProperty("error"))this.sb.isSessionOpened=!1,this.sb.loginHandler(new H(L.message,L.code),null);else{if(this.sb.isSessionOpened=!0,L.hasOwnProperty("key")&&(S.sessionKey=L.key),L.hasOwnProperty("ekey")&&(S.eKey=L.ekey),L.hasOwnProperty("user_id")&&(this.sb.currentUser=new i(L)),"number"==typeof L.ping_interval&&L.ping_interval>0&&C.set("pingInterval",1e3*L.ping_interval),"number"==typeof L.pong_timeout&&L.pong_timeout>0&&C.set("pongTimeout",1e3*L.pong_timeout),"number"==typeof L.login_ts){var q=1e3*L.login_ts;C.set("connectedAt",q);var K=C.container,z=K.firstConnectedAt,Y=K.localCacheEnabled,Q=K.store;if(!z){var W=q;if(Y){var X=(x=this.sb.currentUser.userId,"sendbird:".concat(x,"@firstConnectedAt"));Q.get(X).then((function(e){e&&(W=e.ts)})).catch((function(e){t.handleCacheError(e)})).finally((function(){C.set("firstConnectedAt",W)}))}else C.set("firstConnectedAt",W)}}if(L.hasOwnProperty("reconnect")&&"object"===u(L.reconnect)){var Z=L.reconnect,$=C.container.wsAdapter;Z.hasOwnProperty("interval")&&"number"==typeof Z.interval&&($.reconnectParams.interval=Z.interval),Z.hasOwnProperty("max_interval")&&"number"==typeof Z.max_interval&&($.reconnectParams.maxInterval=Z.max_interval),Z.hasOwnProperty("mul")&&"number"==typeof Z.mul&&($.reconnectParams.multiplier=Z.mul),Z.hasOwnProperty("retry_cnt")&&"number"==typeof Z.retry_cnt&&($.reconnectParams.retryCount=Z.retry_cnt)}"number"==typeof L.max_unread_cnt_on_super_group?C.set("maxUnreadCountOfSuperGroupChannel",L.max_unread_cnt_on_super_group):C.set("maxUnreadCountOfSuperGroupChannel",T.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL),L.profile_image_encryption&&C.set("profileImageEncryption",!0),N&&N.start(),L.hasOwnProperty("file_upload_size_limit")&&L.hasOwnProperty("premium_feature_list")&&L.hasOwnProperty("emoji_hash")&&C.set("appInfo",new Ie(L)),L.hasOwnProperty("concurrent_call_limit")&&L.hasOwnProperty("back_off_delay")&&(C.set("concurrentCallLimit",L.concurrent_call_limit),C.set("backOffDelay",L.back_off_delay)),this.sb.loginHandler(null,this.sb.currentUser)}break;case"EXPR":var ee=new H("The session would be expired.",L.reason||H.SESSION_KEY_EXPIRED);M.refreshSessionIfExpiredError(ee).then((function(){})).catch((function(){}));break;case"MESG":case"FILE":case"BRDM":case"ADMM":var te=null;if("MESG"===R.command?te=new h(L):"FILE"===R.command?te=new p(L):"BRDM"!==R.command&&"ADMM"!==R.command||(te=new f(L)),te){var ne=this.sb.currentUser?this.sb.currentUser.userId:null,re=te.silent,ie=!!L.force_update_last_message,ae=te._sender&&te._sender.userId===ne;if(te.isGroupChannel()){var oe=c.cachedChannels.hasOwnProperty(te.channelUrl);c.getChannel(te.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:te.channelUrl,messageId:te.messageId});t.sb.sendCommand(s)}if(e.isHidden=!1,e.hiddenState=c.HiddenState.UNHIDDEN,c.cachedChannels[e.url]=e,te._sender&&e.memberMap.hasOwnProperty(te._sender.userId)){var a=e.memberMap[te._sender.userId];a.nickname!==te._sender.nickname&&(a.nickname=te._sender.nickname),a.plainProfileUrl!==te._sender.plainProfileUrl&&(a.plainProfileUrl=te._sender.plainProfileUrl),se.deepEqual(a.metaData,te._sender.metaData)||(a.metaData=te._sender.metaData),a.isBlockedByMe!==te._sender.isBlockedByMe&&(a.isBlockedByMe=te._sender.isBlockedByMe)}var o=t.sb.currentUser;o&&ae&&(o.nickname!==te._sender.nickname&&(o.nickname=te._sender.nickname),o.plainProfileUrl!==te._sender.plainProfileUrl&&(o.plainProfileUrl=te._sender.plainProfileUrl),se.deepEqual(o.metaData,te._sender.metaData)||(o.metaData=te._sender.metaData));var l=!1;if(te.mentionType===_.MentionType.CHANNEL)ae||(l=!0);else if(te.mentionType===_.MentionType.USERS)for(var u=0;u=le.createAt,a=t.sb.currentUser;a&&he&&(a.nickname!==le._sender.nickname&&(a.nickname=le._sender.nickname),a.plainProfileUrl!==le._sender.plainProfileUrl&&(a.plainProfileUrl=le._sender.plainProfileUrl),se.deepEqual(a.metaData,le._sender.metaData)||(a.metaData=le._sender.metaData));var o=!1,l=!1;if(!he&&!s&&L&&L.hasOwnProperty("old_values")){var u=L.old_values.mention_type||le.mentionType,c=L.old_values.mentioned_user_ids||le.mentionedUsers.map((function(e){return e.userId}));if(u===_.MentionType.USERS&&le.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)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.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:de.EVENT_READ_RECEIPT_UPDATED,payload:{channel:e,user:me.reader}})))}));break;case"MRCT":var ve=String(L.channel_type),be=String(L.channel_url),Ce=g.createFromJson(L);switch(ve){case o.CHANNEL_TYPE_GROUP:c.getChannel(be,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(R.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,Ce)})),B.get("".concat(Ce.messageId)).then((function(n){n&&(n.applyReactionEvent(Ce),B.upsert([n]).then((function(){V.send({source:de.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:Ce}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(be,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(R.command,"`")):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onReactionUpdated(e,Ce)})),V.send({source:de.EVENT_REACTION_UPDATED,payload:{channel:e,reactionEvent:Ce}}))}))}break;case"DLVR":var Ae=String(L.channel_url),Ne=L.hasOwnProperty("updated")?L.updated:null,Se=c.cachedChannels.hasOwnProperty(Ae);c.getChannel(Ae,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(Ne).forEach((function(n){t.sb.currentUser&&n===t.sb.currentUser.userId&&(i=!0),Se&&e.updateDeliveryReceipt(n,parseInt(Ne[n]))})),c.cachedChannels[e.url]=e,i&&1===Object.keys(Ne).length||(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onDeliveryReceiptUpdated(e)})),V.send({source:de.EVENT_DELIVERY_RECEIPT_UPDATED,payload:{channel:e}}))}}));break;case"MTHD":var Te=String(L.channel_url),Oe=String(L.channel_type),Ue=m.createFromJson(L);switch(Oe){case o.CHANNEL_TYPE_GROUP:c.getChannel(Te,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,Ue)})),B.get("".concat(Ue.targetMessageId)).then((function(n){n&&(n.applyThreadInfoUpdateEvent(Ue),B.upsert([n]).then((function(){V.send({source:de.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:Ue}})})).catch((function(e){t.handleCacheError(e)})))})).catch((function(e){t.handleCacheError(e)})))}));break;case o.CHANNEL_TYPE_OPEN:d.getChannel(Te,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,Ue)})),V.send({source:de.EVENT_THREAD_INFO_UPDATED,payload:{channel:e,threadInfoUpdateEvent:Ue}}))}))}break;case"MCNT":if(L.hasOwnProperty("group_channels")&&Array.isArray(L.group_channels)){var Me,ke=[],Re=I(L.group_channels);try{for(Re.s();!(Me=Re.n()).done;){var Le=Me.value;if(Le){var Pe=c.cachedChannels[Le.channel_url];if(Pe&&Pe.isBroadcast)Pe.setLatestMemberCount(Le.member_count,Le.joined_member_count,Le.ts)&&ke.push(Pe)}}}catch(e){Re.e(e)}finally{Re.f()}ke.length>0&&(Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelMemberCountChanged(ke)})),j.upsert(ke).then((function(){var e,t=I(ke);try{for(t.s();!(e=t.n()).done;){var n=e.value;V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:n}})}}catch(e){t.e(e)}finally{t.f()}})).catch((function(e){t.handleCacheError(e)})))}if(L.hasOwnProperty("open_channels")&&Array.isArray(L.open_channels)){var we,De=[],He=I(L.open_channels);try{for(He.s();!(we=He.n()).done;){var Fe=we.value;if(Fe){var xe=d.cachedChannels[Fe.channel_url];if(xe)xe.setLatestParticipantCount(Fe.participant_count,Fe.ts)&&De.push(xe)}}}catch(e){He.e(e)}finally{He.f()}if(De.length>0){Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelParticipantCountChanged(De)}));var je,Be=I(De);try{for(Be.s();!(je=Be.n()).done;){var Ve=je.value;V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:Ve}})}}catch(e){Be.e(e)}finally{Be.f()}}}break;case"PEDI":var qe=E.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollUpdated(qe)}));break;case"VOTE":var Ke=v.createFromJson(L);Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onPollVoted(Ke)}));break;case"SYEV":var ze=new Lt(L),Ye=L.ts;switch(ze.category){case Lt.CATEGORY_CHANNEL_JOIN:case Lt.CATEGORY_CHANNEL_LEAVE:c.getChannel(ze.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(R.command,"`"),ze.category);else{var a=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,o=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null,l=!1;if(ze.category===Lt.CATEGORY_CHANNEL_JOIN){(ze.data.hasOwnProperty("users")?ze.data.users:[ze.data]).forEach((function(n){e.isSuper||e.isBroadcast?l=e.setLatestMemberCount(a,o,L.ts):(n.state=s.JOINED,e.addMember(new s(n),Ye),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])})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_JOINED,payload:{channel:e,user:r}})})).catch((function(e){t.handleCacheError(e)}))}))}else{var u=new i(ze.data);if(t.sb.currentUser&&u.userId===t.sb.currentUser.userId?(e.isPublic||c.removeCachedChannel(ze.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,L.ts);else C.container.appInfo.enabledChannelMemberShipHistory?(e.memberMap[u.userId].state=c.MemberStateFilter.LEFT,e.memberCount=ze.data.member_count):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])})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_LEFT,payload:{channel:e,user:u}})})).catch((function(e){t.handleCacheError(e)}))}}}));break;case Lt.CATEGORY_CHANNEL_OPERATOR_UPDATE:ze.isGroupChannel()?c.getChannel(ze.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(R.command,"`"),ze.category);else{for(var s=ze.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_OPERATOR_UPDATED,payload:{channel:e,operators:s}})})).catch((function(e){t.handleCacheError(e)}))}})):ze.isOpenChannel()&&d.getChannel(ze.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(R.command,"`"),ze.category):(e.operators=ze.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)})))}));break;case Lt.CATEGORY_CHANNEL_INVITE:c.getChannel(ze.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(R.command,"`"),ze.category);else{var a=null;ze.data&&ze.data.inviter&&Object.keys(ze.data.inviter).length>0&&(a=new i(ze.data.inviter));for(var o=[],l=0;l0&&(s=new i(ze.data.inviter));var a=new i(ze.data.invitee);if(t.sb.currentUser&&a.userId===t.sb.currentUser.userId&&(e.invitedAt=0,e.myMemberState="none",e.isPublic||c.removeCachedChannel(ze.channelUrl)),e.isSuper||e.isBroadcast){var o=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,l=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null;e.setLatestMemberCount(o,l,L.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_DECLINED_INVITATION,payload:{channel:e,inviter:s,invitee:a}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_TYPING_START:case Lt.CATEGORY_TYPING_END:c.getChannel(ze.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(R.command,"`"),ze.category);else{var s=new i(ze.data);ze.category===Lt.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_TYPING_STATUS_UPDATED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_CHANNEL_ENTER:case Lt.CATEGORY_CHANNEL_EXIT:d.getChannel(ze.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(R.command,"`"),ze.category);else{var s=ze.data.hasOwnProperty("participant_count")?ze.data.participant_count:null,a=e.setLatestParticipantCount(s,L.ts),o=new i(ze.data);ze.category===Lt.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:de.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:de.EVENT_CHANNEL_EXIT,payload:{channel:e,user:o}}))}}));break;case Lt.CATEGORY_USER_CHANNEL_MUTE:case Lt.CATEGORY_USER_CHANNEL_UNMUTE:var Qe=ze.category===Lt.CATEGORY_USER_CHANNEL_MUTE,We=l({},ze.data);Qe&&(We.restriction_type=a.RestrictionType.MUTED);var Je=Qe?new a(We):new i(ze.data),Xe=Qe?"muted":"unmuted";ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category):Qe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,Je)})),V.send({source:de.EVENT_USER_MUTED,payload:{channel:e,user:Je}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,Je)})),V.send({source:de.EVENT_USER_UNMUTED,payload:{channel:e,user:Je}}))})):c.getChannel(ze.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(R.command,"`"),ze.category):(t.sb.currentUser&&Je.userId===t.sb.currentUser.userId&&(e.myMutedState=Xe),Array.isArray(e.members)&&e.members.filter((function(e){return e&&e.userId===Je.userId})).forEach((function(e){e.isMuted=Qe,e.restrictionInfo=new b(We)})),Qe?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserMuted(e,Je)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_MUTED,payload:{channel:e,user:Je}})})).catch((function(e){t.handleCacheError(e)}))):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnmuted(e,Je)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_USER_UNMUTED,payload:{channel:e,user:Je}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Lt.CATEGORY_USER_CHANNEL_BAN:case Lt.CATEGORY_USER_CHANNEL_UNBAN:var Ze=ze.category===Lt.CATEGORY_USER_CHANNEL_BAN,$e=l({},ze.data);Ze&&($e.restriction_type=a.RestrictionType.BANNED);var et=Ze?new a($e):new i(ze.data);ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category);else if(Ze){if(t.sb.currentUser&&et.userId===t.sb.currentUser.userId)delete d.enteredChannels[ze.channelUrl],t.cls.FileMessageQueue.delete(ze.channelUrl);Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,et)})),V.send({source:de.EVENT_USER_BANNED,payload:{channel:e,user:et}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,et)})),V.send({source:de.EVENT_USER_UNBANNED,payload:{channel:e,user:et}})})):c.getChannel(ze.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(R.command,"`"),ze.category);else if(Ze){if(t.sb.currentUser&&et.userId===t.sb.currentUser.userId&&(e.isPublic||c.removeCachedChannel(ze.channelUrl),e.myMemberState="none",e.invitedAt=0,e.joinedAt=0,e._setGroupChannelUnreadCount(0,0)),e.isSuper||e.isBroadcast){var i=ze.data.hasOwnProperty("member_count")?ze.data.member_count:null,s=ze.data.hasOwnProperty("joined_member_count")?ze.data.joined_member_count:null;e.setLatestMemberCount(i,s,L.ts)}else e.removeMember(et),e.updateJoinedMemberCount();Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserBanned(e,et)})),V.send({source:de.EVENT_USER_BANNED,payload:{channel:e,user:et}})}else Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onUserUnbanned(e,et)})),V.send({source:de.EVENT_USER_UNBANNED,payload:{channel:e,user:et}})}));break;case Lt.CATEGORY_CHANNEL_FREEZE:case Lt.CATEGORY_CHANNEL_UNFREEZE:ze.isOpenChannel()?d.getChannel(ze.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(R.command,"`"),ze.category):(e.isFrozen=ze.data.freeze,d.cachedChannels[e.url]=e,ze.category===Lt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),V.send({source:de.EVENT_CHANNEL_FROZEN,payload:{channel:e}})):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelUnfrozen(e)})),V.send({source:de.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})))})):c.getChannel(ze.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(R.command,"`"),ze.category):(e.isFrozen=ze.data.freeze,c.cachedChannels[e.url]=e,ze.category===Lt.CATEGORY_CHANNEL_FREEZE?(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelFrozen(e)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_UNFROZEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))))}));break;case Lt.CATEGORY_CHANNEL_DELETED:ze.isGroupChannel()?c.removeCachedChannel(ze.channelUrl):d.removeCachedChannel(ze.channelUrl);var tt=ze.channelUrl,nt=ze.isGroupChannel()?"group":"open";Object.keys(this.sb.channelHandlers).forEach((function(e){t.sb.channelHandlers[e].onChannelDeleted(tt,nt)})),j.remove([tt]).then((function(){V.send({source:de.EVENT_CHANNEL_DELETED,payload:{channelUrl:tt,channelType:nt}})})).catch((function(e){t.handleCacheError(e)}));break;case Lt.CATEGORY_CHANNEL_PROP_CHANGED:ze.isOpenChannel()?d.getChannelWithoutCache(ze.channelUrl,(function(e,n){if(t.sb.getErrorFirstCallback()){var r=[e,n];n=r[0],e=r[1]}n?J.debug("Discard command:","`".concat(R.command,"`"),ze.category):(Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelChanged(e)})),V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:e}}))})):c.getChannelWithoutCache(ze.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(R.command,"`"),ze.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_CHANGED,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)}))}}));break;case Lt.CATEGORY_CHANNEL_META_DATA_CHANGED:case Lt.CATEGORY_CHANNEL_META_COUNTERS_CHANGED:var rt=ze.data.hasOwnProperty("created"),it=ze.data.hasOwnProperty("updated"),st=ze.data.hasOwnProperty("deleted");(ze.isOpenChannel()?d.getChannel(ze.channelUrl,T.INTERNAL_CALL):c.getChannel(ze.channelUrl,T.INTERNAL_CALL)).then((function(e){var n=ze.data.created,r=ze.data.updated,i=ze.data.deleted;Object.keys(t.sb.channelHandlers).forEach((function(s){var a=t.sb.channelHandlers[s];if(ze.category===Lt.CATEGORY_CHANNEL_META_DATA_CHANGED){var o=L.ts;rt&&e._addOrUpdateCachedMetaData(n,o),it&&e._addOrUpdateCachedMetaData(r,o),st&&e._markAsDeletedCachedMetaData(i,o),rt&&a.onMetaDataCreated(e,n),it&&a.onMetaDataUpdated(e,r),st&&a.onMetaDataDeleted(e,i),(rt||it)&&V.send({source:de.EVENT_CHANNEL_METADATA_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),st&&V.send({source:de.EVENT_CHANNEL_METADATA_DELETED,payload:{channel:e,metaData:l({},i)}})}else rt&&a.onMetaCountersCreated(e,n),it&&a.onMetaCountersUpdated(e,r),st&&a.onMetaCountersDeleted(e,i),(rt||it)&&V.send({source:de.EVENT_CHANNEL_METACOUNTER_UPDATED,payload:{channel:e,metaData:l(l({},n),r)}}),st&&V.send({source:de.EVENT_CHANNEL_METACOUNTER_DELETED,payload:{channel:e,metaData:l({},i)}})}))})).catch((function(e){return J.debug("Discard command:","`".concat(R.command,"`"),ze.category)}));break;case Lt.CATEGORY_CHANNEL_HIDE:case Lt.CATEGORY_CHANNEL_UNHIDE:c.getChannel(ze.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(R.command,"`"),ze.category):ze.category===Lt.CATEGORY_CHANNEL_HIDE?(e.isHidden=!0,ze.data&&(ze.data.hasOwnProperty("allow_auto_unhide")&&(e.hiddenState=ze.data.allow_auto_unhide?c.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:c.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),ze.data.hasOwnProperty("hide_previous_messages")&&ze.data.hide_previous_messages&&e._setGroupChannelUnreadCount(0,0)),L.hasOwnProperty("ts_message_offset")&&(e._messageOffsetTimestamp=L.ts_message_offset),c.cachedChannels[e.url]=e,Object.keys(t.sb.channelHandlers).forEach((function(n){t.sb.channelHandlers[n].onChannelHidden(e)})),j.upsert([e]).then((function(){V.send({source:de.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)})),j.upsert([e]).then((function(){V.send({source:de.EVENT_CHANNEL_UNHIDDEN,payload:{channel:e}})})).catch((function(e){t.handleCacheError(e)})))}))}break;case"USEV":var at=new Lt(L);switch(at.category){case Pt.CATEGORY_USER_BLOCK:case Pt.CATEGORY_USER_UNBLOCK:var ot=at.data.blocker.user_id,lt=at.data.blockee.user_id;Object.keys(c.cachedChannels).forEach((function(e){var n=c.cachedChannels[e];try{t.sb.currentUser&&(t.sb.currentUser.userId===ot?n.memberMap[lt].isBlockedByMe=at.category===Pt.CATEGORY_USER_BLOCK:t.sb.currentUser.userId===lt&&(n.memberMap[ot].isBlockingMe=at.category===Pt.CATEGORY_USER_BLOCK))}catch(e){}}));break;case Pt.CATEGORY_FRIEND_DISCOVERED:var ut=at.data.friend_discoveries.map((function(e){return new i(e)}));Object.keys(this.sb.userEventHandlers).forEach((function(e){t.sb.userEventHandlers[e].onFriendsDiscovered(ut)}))}break;case"LEAV":case"JOIN":case"PONG":case"MTIO":case"TPST":case"TPEN":break;default:J.debug("Discard command:","`".concat(R.command,"`"))}}}},{key:"handleCacheError",value:function(e){J.error(e)}}]),e}(),Dt=200,Ht={},Ft={},Gt=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(r.state=n.State.SENDING,navigator&&"boolean"==typeof navigator.onLine)if(navigator.onLine){for(0===this.latestTimestampToSendMessage&&(this.latestTimestampToSendMessage=(new Date).getTime()-Dt);(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.error.code===H.REQUEST_FAILED&&(t.error=new H("Failed to upload a file.",H.NETWORK_ERROR)),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)):Je.ready().then((function(e){e?n._uploadFile(t,(function(e){t.error&&t.error.code===H.REQUEST_FAILED&&(t.error=new H("Failed to upload a file.",H.NETWORK_ERROR)),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=ji.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=ji.getInstance(this._iid),s=bt.of(this._iid),a=Ge.of(this._iid),o=ge.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:de.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],fe.SUCCEEDED)})).then((function(){nt._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:de.EVENT_MESSAGE_SENT,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||r?f(null,d):f(d,null)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))}if(h){if(d&&d._isAutoResendRegistered&&se.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:de.LOCAL_MESSAGE_CANCELED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||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:de.LOCAL_MESSAGE_FAILED,payload:{channel:e.channel,message:d}})})).catch((function(e){return J.error(e)})).finally((function(){f&&(f.isPromisifyCallback||r?f(p,d):f(d,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")})):(n&&se.isAutoResendableError(h.code)&&(d.sendingStatus=i.MessageSendingStatus.PENDING,d.errorCode=0,d._isAutoResendRegistered=!0),a.upsert([d],fe.UNSENT).then((function(){nt._completeCurrentAndProcessNextAutoResend(i,d),o.send({source:de.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&&(f.isPromisifyCallback||r?f(p,t):f(t,p)),e.messageQueue.shift(),e._handleMessageQueueUpdated("remove")}))))}f&&(f.isPromisifyCallback||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(){Ft[this._iid]={}}},{key:"queueMap",get:function(){return Ft[this._iid]||(Ft[this._iid]={}),Ft[this._iid]}},{key:"uploadRequest",get:function(){return Ht[this._iid]||(Ht[this._iid]={}),Ht[this._iid]}}]),e}();Gt.Job=function(){return h((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||Gt.State.PENDING,this.error=o,this.response=u}))}();var xt,jt={},Bt=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,f=e.disableLogger,_=void 0!==f&&f;return jt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=d,this.transactionApplyDelay=p,this.disableLogger=_,jt[t]=this),jt[t]}return e.get=function(e){return jt[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_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",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"}(xt||(xt={}));var Vt,qt=function(e){function t(n){var r=n.code,i=void 0===r?xt.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return k(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:xt.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:xt.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:xt.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:xt.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:xt.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:xt.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:xt.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,"storeEncryptionInvalid",{get:function(){return new t({code:xt.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:xt.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:xt.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:xt.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:xt.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:xt.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:xt.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:xt.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:xt.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:xt.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:xt.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:xt.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:xt.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:xt.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:xt.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:xt.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:xt.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"}(Vt||(Vt={}));var Kt,zt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw qt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return zt(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]=zt(e[r],t);return t.delete(e),n}return e},Yt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw qt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Qt=function(e,t){for(var n=0,r=0;r>>0)%t},Wt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Jt=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!Jt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Jt(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(!(Yt(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Yt(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Yt(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Yt(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)},Xt=function(){},Zt=function(){return Promise.resolve()},$t=function(e){return e},en=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Kt||(Kt={}));var tn,nn,rn,sn=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?$t:a,l=e.backward,u=void 0===l?Zt:l,c=e.forward,d=void 0===c?Zt:c,h=e.complete,p=void 0===h?Xt: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 L(this,void 0,void 0,(function(){var e,t,n;return P(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 L(this,void 0,void 0,(function(){var e,t,n;return P(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}(),an=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*Yt(this._indexer.origin[u].columnValues[i],this.condition[s][l])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*Yt(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===rn.PERSISTENT&&(r.state=nn.PERSISTENT),t!==rn.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)_n.includes(this._items[t].state)&&_n.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===nn.VOLATILE})),r=n.length-this._limit;if(r>0){for(var i=[],s=0,a=this._items;s0?r--:i.push(o)}this._items=i}}}},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!==nn.VOLATILE}))},e}(),mn=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(un(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(un(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=[]),L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var n,r,i,s,a,o,l,u,c;return P(this,(function(d){switch(d.label){case 0:n=yn.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 R(R({},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=yn.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=En.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 L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return n=Bt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,yn.get(this.dbname).find(this._store,r)];case 1:return s=o.sent(),(a=s?En.createFromCacheItem(s):new En({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 L(this,void 0,void 0,(function(){var t;return P(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 L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a;return P(this,(function(o){switch(o.label){case 0:return e=dn(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=yn.get(this.dbname),i=0,s=n;i")),this._transaction=s,this._store=a,this._transaction.on(tn.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(tn.ERROR,this.indexerKey,(function(){return o.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 L(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,o,l,u,c,d;return P(this,(function(h){switch(h.label){case 0:return[4,(e=yn.get(this.dbname)).find(this._store,this.indexerKey,rn.PERSISTENT)];case 1:return(t=h.sent())?[3,7]:(n=dn(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),i=0,s=r,h.label=3;case 3:return i-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Sn.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))},e.prototype._sendSync=function(){var e;this.isHost&&this._send(Sn.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return L(this,void 0,void 0,(function(){var e=this;return P(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=Nn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Sn.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Sn.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return L(this,void 0,void 0,(function(){var e;return P(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Sn.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),kn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Vt.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=w([[r]],s.filter((function(e){return bn.createKey(e)!==o.keyName})),!0),this._keyHash=i,this._store=a,this._mutex=new Mn(function(e,t){return"".concat(un(e,t),".lock")}(t,n)),this._blobContainer=new fn({dbname:t,collectionName:n,store:a}),this._transaction=new mn({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return L(this,void 0,void 0,(function(){var r;return P(this,(function(i){switch(i.label){case 0:return r=cn(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 L(this,void 0,void 0,(function(){var t,n,r,i,s,a,o,l,u,c,d,h,p=this;return P(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=Bt.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 vn({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 bn.createKey(e)})),a=n?n.indexes.map((function(e){return bn.createKey(e)})):[],o=0,l=a;o0&&!r.some((function(t){switch(t){case qn.CHANNEL_NAME:return e.name.toLowerCase().includes(n.toLowerCase());case qn.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 Vn.AND:if(o.some((function(e){return!u.includes(e)})))return!1;break;case Vn.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.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var h=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!==h})))return!1}if(this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.memberStateFilter)switch(this.memberStateFilter){case Kn.JOINED:if("joined"!==e.myMemberState)return!1;break;case Kn.INVITED:if("invited"!==e.myMemberState)return!1;break;case Kn.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Kn.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Wn.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Wn.HIDDEN:if(!e.isHidden)return!1;break;case Wn.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Wn.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Qn.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Yn.PUBLIC:if(!e.isPublic||"none"===e.myMemberState)return!1;break;case Yn.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case zn.SUPER:if(!e.isSuper)return!1;break;case zn.NON_SUPER:if(e.isSuper)return!1}return!0},e.QueryType=Vn,e.SearchField=qn,e.MemberStateFilter=Kn,e.SuperChannelFilter=zn,e.PublicChannelFilter=Yn,e.UnreadChannelFilter=Qn,e.HiddenChannelFilter=Wn,e}(),$n=function(){function e(e){var t=e.iid;this._iid=t,this._filter=new Zn,this._filter.iid=this._iid,this._order=ot.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 Et({iid:this._iid,filter:this._filter,order:this._order,limit:this._limit})},e}(),er=function(){function e(e){var t=e.iid,n=e.channel;this._iid=t,this._channel=n,this._startingPoint=Date.now(),this._filter=new Re,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 nt({iid:this._iid,channel:this._channel,startingPoint:this._startingPoint,filter:this._filter,limit:this._limit})},e}(),tr={},nr={},rr=new WeakMap,ir=new WeakMap,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=Rt.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},rr.set(y(r),{}),ir.set(y(r),{start:0,end:0}),sr.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 er({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 me({type:"callback"})]),i=C(r,3);return n=i[0],e=i[1],t=i[2],n?oe(this._iid,(function(e){return e(me.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string",optional:!0,defaultValue:""}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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>=sr.get(this)&&(sr.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=me.parse(arguments,[new me({type:"boolean",optional:!0,defaultValue:!1}),new me({type:"boolean",optional:!0,defaultValue:!0}),new me({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=ji.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=bt.of(t._iid),o=ge.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:de.EVENT_CHANNEL_CHANGED,payload:{channel:t}}),o.send({source:de.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 Tt&&!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=ji.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof Tt&&!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=ji.getInstance(this._iid);if(n.currentUser&&!this.isSuper&&!this.isBroadcast&&e instanceof Tt&&!e.isAdminMessage()){for(var r=[],i=0;i0&&void 0!==arguments[0]&&arguments[0],n=ji.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=ir.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=ji.getInstance(this._iid),t=(new Date).getTime(),n=e.Options.typingIndicatorThrottle;("number"!=typeof n||n<1e3||n>9e3)&&(n=1e3);var r=ir.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=rr.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=rr.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=rr.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=rr.get(this);t?n[e.userId]={user:e,ts:(new Date).getTime()}:delete n[e.userId]}},{key:"isTyping",value:function(){var e=rr.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=me.parse(arguments,[new me({type:s,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new me({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=ji.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=me.parse(arguments,[new me({type:i.PushTriggerOption}),new me({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=me.parse(arguments,[new me({type:i.CountPreference}),new me({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",LEFT:"left"}}},{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{ALL:"all",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 tr[this._iid]||(tr[this._iid]={}),tr[this._iid]}},{key:"createGroupChannelCollection",value:function(){return new $n({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=Nt.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,metadata:d.metadata,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(){tr[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(e,t){var n=null,r=null,i=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.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(me.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(me.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}return oe(this._iid,(function(e){return e(me.error,null)}),n)}},{key:"createChannelWithUserIds",value:function(){var e=me.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(me.error,null)}),t)}return t?r.createChannel(s,t):r.createChannel(s)}},{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 nr[this._iid]||0},set:function(e){nr[this._iid]=e}},{key:"getChannelCount",value:function(e,t){return ji.getInstance(this._iid).getGroupChannelCount(e,t)}},{key:"getUnreadItemCount",value:function(e,t){return ji.getInstance(this._iid).getUnreadItemCount(e,t)}},{key:"getTotalUnreadMessageCount",value:function(){var e=me.toArray(arguments),t="function"==typeof e[e.length-1]?e.pop():null,n=ji.getInstance(this._iid);return n.getTotalUnreadMessageCount.apply(n,A(e).concat([t]))}},{key:"getTotalUnreadChannelCount",value:function(e){return ji.getInstance(this._iid).getTotalUnreadChannelCount(e)}}]),n}(Rt),or=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 k(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=Nt.deserialize(e);return new t(t.objectify(R({},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||ar.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}),Object.defineProperty(t,"LEFT",{get:function(){return"left"},enumerable:!1,configurable:!0}),t}(Ot),lr=function(e){function t(t){var n=e.call(this,t)||this;return n.role="",n.isBlockedByMe=!1,t&&n._update(t),n}return k(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=Nt.deserialize(e);return new t(t.objectify(R({},n)))},t.prototype.parse=function(e){this._update(e)},t.prototype._update=function(e){this.role=e.role||ar.Role.NONE,e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)},t}(Ot),ur=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}(Ot),cr=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}(),dr=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}(),hr=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}(),pr={},fr={},_r=new WeakMap,gr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).channelType=Rt.CHANNEL_TYPE_OPEN,r.participantCount=0,_r.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=ji.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,ge.of(t._iid).send({source:de.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=ji.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),ge.of(t._iid).send({source:de.EVENT_CHANNEL_EXIT,payload:{channel:t}}),e(null,null))}))}),e)}},{key:"updateChannel",value:function(){var e=this,t=me.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(me.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})),n?this.updateChannel(a,n):this.updateChannel(a)}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]),n?this.updateChannel(o,n):this.updateChannel(o)}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],n?this.updateChannel(l,n):this.updateChannel(l)}return oe(this._iid,(function(e){return e(me.error,null)}),n)}},{key:"updateChannelWithOperatorUserIds",value:function(){var e=me.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return t?this.updateChannel(params,t):this.updateChannel(params);default:return oe(this._iid,(function(e){return e(me.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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({type:"string",optional:!0,defaultValue:""}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"number",optional:!0,defaultValue:-1,constraint:function(e){return e>=-1}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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>=_r.get(this)&&(_r.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 pr[this._iid]||(pr[this._iid]={}),pr[this._iid]}},{key:"enteredChannels",get:function(){return fr[this._iid]||(fr[this._iid]={}),fr[this._iid]}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid),n=t.User,r=t.OpenChannel,i=Nt.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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",optional:!0,nullable:!0,defaultValue:null}),new me({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=me.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(me.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(me.error,null)}),n)}return n?i.createChannel(a,n):i.createChannel(a)}},{key:"createChannelWithOperatorUserIds",value:function(){var e=me.toArray(arguments),t=void 0;switch("function"==typeof e[e.length-1]&&(t=e.pop()),e.length){case 4:case 5:return t?this.createChannel.apply(this,A(e).concat([t])):this.createChannel.apply(this,A(e));default:return oe(this._iid,(function(e){return e(me.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(){pr[this._iid]={},x.get(this._iid).FileMessageQueue.clear()}},{key:"clearEnteredChannels",value:function(){fr[this._iid]={}}},{key:"createOpenChannelListQuery",value:function(){return new(0,x.get(this._iid).OpenChannelListQuery)}}]),n}(Rt),yr="default",mr=function(){function e(e){this.name=yr,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?yr:t,r=e.volume;return{name:n,volume:void 0===r?1:r}},e.prototype.serialize=function(){return Nt.serialize(this)},e}(),Er=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}(),vr=new WeakMap,br=function(){function e(t){c(this,e),this._mentionType=e.MentionType.USERS,this._mentionedUserIds=[],this._cachedMentionedUsers=[],this._cachedMentionedUserIds=[],this._metaArrays=[],vr.set(this,null),this._parentMessageId=null,this._reqId=null,this.data=null,this.customType=null,this.pushNotificationDeliveryOption=null,this.appleCriticalAlertOptions=null,this.isReplyToChannel=!1,this.mentionedMessageTemplate=null,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)){if(0===e.length)return this._cachedMentionedUserIds=[],void(this._mentionedUserIds=[]);for(var t=ji.getInstance(this._iid),n=0;n-1&&this._mentionedUserIds.every((function(e){return"string"==typeof e}))&&("string"==typeof this.mentionedMessageTemplate||null===this.mentionedMessageTemplate)&&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 mr)&&"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.mentionedMessageTemplate,o=void 0===a?null:a,l=t.cachedMentionedUsers,u=void 0===l?[]:l,c=t.cachedMentionedUserIds,d=void 0===c?[]:c,h=t.metaArrays,p=void 0===h?[]:h,f=t.parentMessageId,_=void 0===f?null:f,g=t.pushNotificationDeliveryOption,y=void 0===g?null:g,m=t.appleCriticalAlertOptions,E=void 0===m?null:m,v=t.isReplyToChannel;return{mention_type:r,mentioned_user_ids:s,mentioned_message_template:o,cached_mentioned_users:u,cached_mentioned_user_ids:d,meta_arrays:p,parent_message_id:_,push_notification_delivery_option:y,apple_critical_alert_options:E,is_reply_to_channel:void 0!==v&&v}}},{key:"MentionType",get:function(){return{USERS:"users",CHANNEL:"channel"}}},{key:"PushNotificationDeliveryOption",get:function(){return{DEFAULT:"default",SUPPRESS:"suppress"}}}]),e}(),Cr=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&&"number"==typeof r?new this(t,n,r):null},e.objectify=function(e){return{key:e.key,user_ids:e.userIds,updated_at:e.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}(),Nr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.MESSAGE_TYPE_USER,r.message=null,r._sender=null,r.translations={},r.requestState=null,r.requestedMentionUserIds=[],r.errorCode=0,r.messageSurvivalSeconds=-1,r.plugins=[],r.poll=null,r._messageParams=null,e&&r._update(e),r}return h(n,[{key:"applyPollUpdateEvent",value:function(e){var t=x.get(this._iid),n=t.Poll,r=t.PollUpdateEvent,i=null,s=me.parse(arguments,[new me({type:r,constraint:function(e){return Object.values(n.Status).includes(e.status)}})]),a=C(s,2);if(i=a[0],e=a[1],!i&&this.poll&&this.poll.id===e.poll.id){if(e.status===n.Status.REMOVED)return this.poll=new n(n.objectify(this.poll)),this.poll.details.status=e.status,!0;if(this.poll.details.updatedAt0?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 Cr(e.message_params))}},{key:"sender",get:function(){var e=ji.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(this._sender&&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),se.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=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&se.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:"_isSentByMe",value:function(){var e=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.SUCCEEDED&&0===this.updatedAt&&this._sender&&this._sender.userId===e.currentUser.userId}}],[{key:"objectify",value:function(e){var t=ji.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.Reaction,_=n.AppleCriticalAlertOptions,g=n.Poll,y=n.UserMessageParams,m=e.messageId,E=e.messageType,v=void 0===E?Tt.MESSAGE_TYPE_BASE:E,b=e.reqId,C=void 0===b?"":b,A=e.user,N=e.channel,S=void 0===N?null:N,I=e.channelUrl,T=void 0===I?"":I,O=e.channelType,U=void 0===O?r.CHANNEL_TYPE_OPEN:O,M=e.message,k=e.data,R=void 0===k?"":k,L=e.customType,P=void 0===L?"":L,w=e.mentionType,D=void 0===w?i.MentionType.USERS:w,H=e.mentionedUsers,F=void 0===H?[]:H,G=e.mentionedUserIds,j=void 0===G?[]:G,B=e.mentionedMessageTemplate,V=void 0===B?null:B,q=e.requestedMentionUserIds,K=void 0===q?[]:q,z=e.reactions,Y=void 0===z?[]:z,Q=e.metaArrays,W=void 0===Q?[]:Q,J=e.rootMessageId,X=void 0===J?0:J,Z=e.parentMessageId,$=void 0===Z?0:Z,ee=e.parentMessageText,te=void 0===ee?"":ee,ne=e.threadInfo,re=void 0===ne?null:ne,ie=e.isReplyToChannel,se=void 0!==ie&&ie,ae=e.parentMessage,oe=void 0===ae?null:ae,le=e.translations,ue=void 0===le?{}:le,ce=e.sendingStatus,de=e.errorCode,he=void 0===de?0:de,pe=e.silent,fe=void 0!==pe&&pe,_e=e.isGlobalBlocked,ge=void 0!==_e&&_e,ye=e.messageSurvivalSeconds,me=void 0===ye?-1:ye,Ee=e.ogMetaData,ve=void 0===Ee?null:Ee,be=e.isOperatorMessage,Ce=void 0!==be&&be,Ae=e.plugins,Ne=void 0===Ae?[]:Ae,Se=e.appleCriticalAlertOptions,Ie=e.poll,Te=void 0===Ie?null:Ie,Oe=e.createdAt,Ue=e.updatedAt,Me=void 0===Ue?0:Ue,ke=e.messageParams,Re=void 0===ke?null:ke,Le=e.isAutoResendRegistered,Pe=void 0!==Le&&Le,we={};switch(we.req_id=C,we.msg_id=m,v){case Tt.MESSAGE_TYPE_USER:we.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:we.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:we.type="ADMM"}if(we.user=s.objectify(l({},A)),we.channel_url=S?S.url:T,we.channel_type=S?S.channelType:U,we.message=M,we.data=R,we.custom_type=P,we.translations=ue,we.is_global_block=!!ge,we.ts=Oe,we.updated_at=Me,we.mention_type=D,we.mentioned_users=F.map((function(e){return a.objectify(e)})),we.mentioned_user_ids=j,we.mentioned_message_template=V,we.requested_mention_user_ids=K,we.reactions=Y.map((function(e){return f.objectify(e)})),we.metaarray={},W.forEach((function(e){var t=e.key;we.metaarray[t]=e.value})),we.metaarray_key_order=W.map((function(e){return e.key})),we.root_message_id=X,we.parent_message_id=$,we.parent_message_text=te,re&&(we.thread_info=d.objectify(re)),we.is_reply_to_channel=se,oe)switch(oe.messageType){case Tt.MESSAGE_TYPE_USER:we.parent_message_info=o._objectifySerializedData(oe);break;case Tt.MESSAGE_TYPE_FILE:we.parent_message_info=u._objectifySerializedData(oe);break;case Tt.MESSAGE_TYPE_ADMIN:we.parent_message_info=c._objectifySerializedData(oe)}return we.sending_status=m>0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ce&&(we.sending_status=ce),we.silent=!!fe,we.error_code=he,we.message_survival_seconds=me,ve&&(we.og_tag=h.objectify(ve)),we.is_op_msg=!!Ce,we.plugins=Ne.map((function(e){return p.objectify(e)})),Te&&(we.poll=g.objectify(Te)),Se&&(we.apple_critical_alert_options=_.objectify(Se)),Re&&(we.message_params=y.objectify(Re)),we.is_auto_resend_registered=Pe,we}},{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,M){return this.objectify({messageId:t,reqId:e,user:n,channel:r,message:i,data:s,customType:a,mentionType:p,mentionedUsers:f,mentionedUserIds:E,mentionedMessageTemplate:v,requestedMentionUserIds:C,reactions:h,metaArrays:d,rootMessageId:_,parentMessageId:g,parentMessageText:y,threadInfo:m,translations:o,sendingStatus:b,errorCode:A,isGlobalBlocked:l,messageSurvivalSeconds:N,ogMetaData:S,isOperatorMessage:I,plugins:T,appleCriticalAlertOptions:O,poll:U,createdAt:u,updatedAt:c,messageParams:M})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).UserMessage,n=Nt.deserialize(e);return new t(this._objectifySerializedData(n))}},{key:"_objectifySerializedData",value:function(e){return x.get(this._iid).UserMessage.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,messageParams:e.messageParams?new Cr(Cr.objectify(e.messageParams)):null}))}}]),n}(Tt),Sr=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){se.isFile(e)&&(this._fileUrl=null,this._file=e,te.isFile(e)?this._fileType=D.FILE:te.isBlob(e)?this._fileType=D.BLOB:te.isFileLikeObject(e)?this._fileType=D.BLOB_LIKE_OBJECT:"string"==typeof e&&(this._fileType=D.URL))}},{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({},br._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}(br),Ir=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.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=ji.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 Sr(e.message_params))}},{key:"sender",get:function(){var e=ji.getInstance(this._iid),t=x.get(this._iid).GroupChannel;if(this._sender&&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),se.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=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.FAILED&&se.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&&te.isBlob(t)&&(e._messageParams.file=t.slice())}return e}},{key:"_isSentByMe",value:function(){var e=ji.getInstance(this._iid);return this.sendingStatus===e.MessageSendingStatus.SUCCEEDED&&0===this.updatedAt&&this._sender&&this._sender.userId===e.currentUser.userId}}],[{key:"objectify",value:function(e){var t=ji.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.Reaction,f=n.FileMessageParams,_=n.AppleCriticalAlertOptions,g=e.messageId,y=e.messageType,m=void 0===y?Tt.MESSAGE_TYPE_BASE:y,E=e.reqId,v=void 0===E?"":E,b=e.user,C=void 0===b?{}:b,A=e.channel,N=e.plainUrl,S=e.name,I=void 0===S?null:S,T=e.type,O=e.size,U=void 0===O?0:O,M=e.data,k=void 0===M?"":M,R=e.customType,L=void 0===R?"":R,P=e.mentionType,w=void 0===P?i.MentionType.USERS:P,D=e.mentionedUsers,H=void 0===D?[]:D,F=e.mentionedUserIds,G=void 0===F?[]:F,j=e.requestedMentionUserIds,B=void 0===j?[]:j,V=e.reactions,q=void 0===V?[]:V,K=e.metaArrays,z=void 0===K?[]:K,Y=e.rootMessageId,Q=void 0===Y?0:Y,W=e.parentMessageId,J=void 0===W?0:W,X=e.parentMessageText,Z=void 0===X?"":X,$=e.threadInfo,ee=void 0===$?null:$,te=e.isReplyToChannel,ne=void 0!==te&&te,re=e.parentMessage,ie=void 0===re?null:re,se=e.thumbnails,ae=void 0===se?[]:se,oe=e.requireAuth,le=void 0!==oe&&oe,ue=e.sendingStatus,ce=e.errorCode,de=void 0===ce?0:ce,he=e.silent,pe=void 0!==he&&he,fe=e.isGlobalBlocked,_e=void 0!==fe&&fe,ge=e.messageSurvivalSeconds,ye=void 0===ge?-1:ge,me=e.ogMetaData,Ee=void 0===me?null:me,ve=e.isOperatorMessage,be=void 0!==ve&&ve,Ce=e.appleCriticalAlertOptions,Ae=e.createdAt,Ne=e.updatedAt,Se=void 0===Ne?0:Ne,Ie=e.messageParams,Te=void 0===Ie?null:Ie,Oe=e.isAutoResendRegistered,Ue=void 0!==Oe&&Oe,Me={};switch(Me.req_id=v,Me.msg_id=g,m){case Tt.MESSAGE_TYPE_USER:Me.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:Me.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:Me.type="ADMM"}Me.user=s.objectify(l({},C)),Me.channel_url=A.url,Me.channel_type=A.channelType===r.CHANNEL_TYPE_OPEN?r.CHANNEL_TYPE_OPEN:r.CHANNEL_TYPE_GROUP,Me.url=N,Me.name=I,Me.type=T,Me.size=U,Me.custom=k,Me.custom_type=L,Me.thumbnails=ae,Me.require_auth=le,Me.is_global_block=!!_e,Me.ts=Ae,Me.updated_at=Se,Me.mention_type=w,Me.mentioned_users=H.map((function(e){return a.objectify(e)})),Me.mentioned_user_ids=G,Me.requested_mention_user_ids=B,Me.reactions=q.map((function(e){return p.objectify(e)})),Me.metaarray={};for(var ke=0;ke0?t.MessageSendingStatus.SUCCEEDED:t.MessageSendingStatus.FAILED,ue&&(Me.sending_status=ue),Me.silent=!!pe,Me.error_code=de,Me.message_survival_seconds=ye,Ee&&(Me.og_tag=h.objectify(Ee)),Me.is_op_msg=!!be,Ce&&(Me.apple_critical_alert_options=_.objectify(Ce)),Te&&(Me.message_params=f.objectify(Te)),Me.is_auto_resend_registered=Ue,Me}},{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,M,k){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:M,createdAt:d,updatedAt:f,messageParams:k})}},{key:"buildFromSerializedData",value:function(e){var t=x.get(this._iid).FileMessage,n=Nt.deserialize(e);return new t(this._objectifySerializedData(n))}},{key:"_objectifySerializedData",value:function(e){return x.get(this._iid).FileMessage.objectify(l(l({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,messageParams:e.messageParams?new Sr(Sr.objectify(e.messageParams)):null}))}}]),n}(Tt),Tr=function(e){f(n,e);var t=E(n);function n(e){var r;return c(this,n),(r=t.call(this,e)).messageType=Tt.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=t.Reaction,d=e.messageId,h=e.messageType,p=void 0===h?Tt.MESSAGE_TYPE_BASE:h,f=e.channel,_=e.message,g=e.data,y=void 0===g?"":g,m=e.customType,E=void 0===m?"":m,v=e.mentionType,b=void 0===v?r.MentionType.USERS:v,C=e.mentionedUsers,A=void 0===C?[]:C,N=e.mentionedMessageTemplate,S=void 0===N?null:N,I=e.reactions,T=void 0===I?[]:I,O=e.metaArrays,U=void 0===O?[]:O,M=e.rootMessageId,k=void 0===M?0:M,R=e.parentMessageId,L=void 0===R?0:R,P=e.parentMessageText,w=void 0===P?"":P,D=e.threadInfo,H=void 0===D?null:D,F=e.isReplyToChannel,G=void 0!==F&&F,j=e.parentMessage,B=void 0===j?null:j,V=e.translations,q=void 0===V?{}:V,K=e.silent,z=void 0!==K&&K,Y=e.ogMetaData,Q=void 0===Y?null:Y,W=e.createdAt,J=e.updatedAt,X=void 0===J?0:J,Z={msg_id:d,channel_url:f.url,channel_type:f.channelType===n.CHANNEL_TYPE_OPEN?n.CHANNEL_TYPE_OPEN:n.CHANNEL_TYPE_GROUP,message:_,data:y,custom_type:E,silent:z,ts:W,updated_at:X};switch(p){case Tt.MESSAGE_TYPE_USER:Z.type="MESG";break;case Tt.MESSAGE_TYPE_FILE:Z.type="FILE";break;case Tt.MESSAGE_TYPE_ADMIN:Z.type="ADMM"}Z.translations=q,Z.mention_type=b,Z.mentioned_users=A.map((function(e){return o.objectify(e)})),Z.mentioned_message_template=S,Z.reactions=T.map((function(e){return c.objectify(e)})),Z.metaarray={};for(var $=0;$0&&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(me.error,null)}),e)}}]),e}(),Lr=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(me.error,null)}),e)}}]),e}(),Pr=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(me.error,null)}),e)}}]),e}(),wr=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(me.error,null)}),e)}}]),e}(),Dr=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.nicknameStartsWithFilter="",this.nicknameExactMatchFilter="",this.channelNameContainsFilter="",this.memberStateFilter=ar.MemberStateFilter.ALL,this.customTypesFilter=[],this.channelUrlsFilter=[],this.superChannelFilter=ar.SuperChannelFilter.ALL,this.publicChannelFilter=ar.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=ar.UnreadChannelFilter.ALL,this.metadataOrderKeyFilter=null,this.metadataKey=null,this.metadataValues=[],this.metadataValueStartsWith=null,this.hiddenChannelFilter=ar.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 Nt.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.nicknameStartsWithFilter||"string"!=typeof t.nicknameExactMatchFilter||"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(me.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=Nt.deserialize(e),r=t.createMyGroupChannelListQuery();return Object.keys(n).forEach((function(e){r.hasOwnProperty(e)&&(r[e]=n[e])})),r}}]),e}(),Hr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this.mutedMemberFilter=e.MutedMemberFilter.ALL,this.memberStateFilter=ar.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;if("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))if(t.isLoading)e(new H("Query in progress.",H.QUERY_IN_PROGRESS),null);else if(t.hasNext){t.isLoading=!0;var a=U.get(t._iid);t.memberStateFilter===r.MemberStateFilter.LEFT&&(t.memberStateFilter=r.MemberStateFilter.ALL),a.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)}))}else e(null,[]);else e(me.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}(),Fr=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(me.error,null)}),e)}}]),e}(),Gr=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(me.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}(),xr=new WeakMap,jr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",xr.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=xr.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(me.error,null)}),e)}}]),e}(),Br=new WeakMap,Vr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasNext=!0,this.limit=20,this._token="",t&&Br.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:Br.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(me.error,null)}),e)}}]),e}(),qr=new WeakMap,Kr=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},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,qr.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 qr.get(this).keyword}},{key:"limit",get:function(){return qr.get(this).limit}},{key:"reverse",get:function(){return qr.get(this).reverse}},{key:"exactMatch",get:function(){return qr.get(this).exactMatch}},{key:"channelUrl",get:function(){return qr.get(this).channelUrl}},{key:"channelCustomType",get:function(){return qr.get(this).channelCustomType}},{key:"messageTimestampFrom",get:function(){return qr.get(this).messageTimestampFrom}},{key:"messageTimestampTo",get:function(){return qr.get(this).messageTimestampTo}},{key:"order",get:function(){return qr.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=qr.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(me.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,qr.get(t).nextToken=a.end_cursor),t.isLoading=!1,e(n,o)}))):e(null,[])}),e)}}]),e}(),zr=new WeakMap,Yr=new WeakMap,Qr=function(){function e(t){c(this,e),this.isLoading=!1,this.hasMore=!0,this.limit=20,Yr.set(this,Number.MAX_SAFE_INTEGER),zr.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=me.parse(arguments,[new me({type:"number",optional:!0,defaultValue:this.limit}),new me({type:"boolean",optional:!0,defaultValue:this.reverse}),new me({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 me({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=me.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=zr.get(i);U.get(i._iid).container.apiClient.getMessageList({channel:s,token:Yr.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(me.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,Xr=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.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),Xr.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!Jr.get(this)}},{key:"hasNext",get:function(){return!!Xr.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),Xr.set(t,!!a),e(null,s)}}))):e(null,[]):e(me.error,null)}),e)}}]),e}(),$r=new WeakMap,ei=new WeakMap,ti=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,$r.set(this,!1),ei.set(this,!0)}return h(e,[{key:"isLoading",get:function(){return!!$r.get(this)}},{key:"hasNext",get:function(){return!!ei.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?($r.set(t,!0),U.get(t._iid).container.apiClient.getPollOptionVoterList(l({},t),(function(n,r){if(n)$r.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,$r.set(t,!1),ei.set(t,!!a),e(null,s)}}))):e(null,[]):e(me.error,null)}),e)}}]),e}(),ni=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)&&(se.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}(),ri=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||se.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}(),ii=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}(Cr),si=h((function e(){c(this,e),this.channelCustomTypesFilter=[],this.superChannelFilter=ar.SuperChannelFilter.ALL})),ai=function(e){f(n,e);var t=E(n);function n(){return c(this,n),t.call(this)}return h(n)}(si),oi=function(e){f(n,e);var t=E(n);function n(){return c(this,n),t.call(this)}return h(n)}(si),li=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}(),ui=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=ji.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}(),ci=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}(),di=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}(),hi=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}(),pi=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}(),fi=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}(),_i=function(){this.onReconnectStarted=function(){},this.onReconnectSucceeded=function(){},this.onReconnectFailed=function(){}},gi=function(){this.onFriendsDiscovered=function(){},this.onTotalUnreadMessageCountUpdated=function(){}},yi=h((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){}})),mi=h((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}})),Ei=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}(),vi=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}(),bi=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}(),Ci=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}(),Ai=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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"array",constraint:function(e){return e.every((function(e){return"number"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:i,constraint:function(e){return e._validate()}}),new me({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}(),Ni=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}(),Si=new WeakMap,Ii=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,Si.set(this,null),this._update(t)}return h(e,[{key:"lastVotedAt",get:function(){return Si.get(this)}},{key:"update",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({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(me.error,null)}),e)}}]),e}(),Ui=new WeakMap,Mi=function(){function e(t){c(this,e),this.isLoading=!1,Ui.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(me.parse(i,[new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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(me.parse(i,[new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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(me.parse(s,[new me({type:"number"}),new me({type:"number"}),new me({type:"number"}),new me({type:"boolean"}),new me({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=Ui.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}(),ki=0,Ri=1,Li=2,Pi=function(){function e(t){var n=this;c(this,e),this.state=ki,this._value=null,this._reason=null;var r=function(e){n.state===ki&&(n.state=Li,n._reason=e)};if("function"!=typeof t)throw"Promise resolver ".concat(t," is not a function");try{t((function(e){n.state===ki&&(n.state=Ri,n._value=e)}),r)}catch(e){r(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 ki:setTimeout((function(){return r.then(t,n)}),2);break;case Ri:t&&"function"==typeof t&&(i=t(this._value));break;case Li: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 ki:setTimeout((function(){return n.catch(t)}),2);break;case Ri:break;case Li:r=t(this._reason)}return r instanceof e?r:this}},{key:"finally",value:function(t){var n=this,r=this;switch(this.state){case ki:setTimeout((function(){return n.finally(t)}),2);break;case Ri:case Li: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),wi();var r=!1;if((n.newInstance||!Hi||Hi&&n.appId!==Hi.getApplicationId()&&Hi.getConnectionState()===Hi.ConnectionState.CLOSED)&&(r=!0,Hi=this),r){try{if(!n.hasOwnProperty("appId"))return J.warn("Must be set appId."),Hi=null,null}catch(e){return J.warn("Must be set appId."),Hi=null,null}var i=Xn.create();Object.defineProperty(this,"_iid",{get:function(){return i}}),Fi[i]=this,this.customApiHost=null,this.customWsHost=null,this.connecting=!1,this.reconnecting=!1,this.isReconnectingOnError=!1,this.connectionCallbacks=[],this.ConnectionManager=new Ee(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:Rt.MessageTypeFilter},this.GroupChannelFilter=Zn,this.MessageFilter=Re,this.GroupChannelCollection={GroupChannelOrder:ot},this.MessageCollection={MessageCollectionInitPolicy:Fe},this.CollectionEventSource=de,this._currentUserId=null;var s={User:Ot,Member:or,RestrictedUser:ur,GroupChannel:ar,OpenChannel:gr,UserMessage:Nr,FileMessage:Ir,AdminMessage:Tr,GroupChannelListQuery:Dr,MemberListQuery:Hr,GroupChannelParams:ni,OpenChannelParams:ri,BaseMessageParams:br,UserMessageParams:Cr,FileMessageParams:Sr,ScheduledUserMessageParams:ii,GroupChannelTotalUnreadMessageCountParams:ai,GroupChannelTotalUnreadChannelCountParams:oi,MessageRetrievalParams:li,MessageListParams:ui,ThreadedMessageListParams:ci,MessageChangeLogsParams:di,GroupChannelChangeLogsParams:hi,PollParams:pi,PollRetrievalParams:fi,MessageMetaArray:Er,UserEventHandler:gi,SessionHandler:ve,ChannelHandler:yi,ConnectionHandler:_i,AppleCriticalAlertOptions:mr,Poll:Ai,PollOption:Ii},a={SessionManager:be,BaseChannel:Rt,BaseMessage:Tt,UserListQuery:Oi,ApplicationUserListQuery:Rr,BannedUserListQuery:Lr,BlockedUserListQuery:Pr,FriendListQuery:wr,MutedUserListQuery:Fr,OpenChannelListQuery:Gr,OperatorListQuery:jr,ParticipantListQuery:Vr,MessageListQuery:Mi,PreviousMessageListQuery:Qr,MessageSearchQuery:Kr,PublicGroupChannelListQuery:Wr,PollListQuery:Zr,PollVoterListQuery:ti,ScheduledUserMessage:Or,ThreadInfo:Ei,ThreadInfoUpdateEvent:Ur,OGMetaData:vi,OGImage:bi,Plugin:Ci,Command:Ne,Sender:lr,ReadStatus:mi,Reaction:Ar,ReactionEvent:Ct,Emoji:hr,EmojiCategory:dr,EmojiContainer:cr,PollDetails:Ni,PollUpdateEvent:Mr,PollVoteEvent:kr,RestrictionInfo:Ti,FileMessageQueue:Gt},o=new x(this._iid,l(l({},s),a));this.BaseMessage={ReplyType:Tt.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 ye(this),commandHandler:new wt(this),onlineDetector:new Ce(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 Hn({encryption:u}),preference:null,auth:new F,appInfo:null,pingInterval:15e3,pongTimeout:5e3,connectedAt:0,extensions:{},supportedExtensionKeys:["sb_uikit","sb_syncmanager","device-os-platform"],getUserAgentWithExtensions:function(e){var t=$()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(T.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},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<=Di&&(this._websocketResponseTimeout=e)},includePollDetails:!1};var d=pe.of(i);d.addObserver({onConnect:function(){t.isCacheEnabled&&!t.getIsProcessingAutoResend()&&(0===t.getAutoResendQueue().length?nt._processAutoResendRegisteredPendingMessages(t).then((function(){nt._processNextAutoResend(t)})):nt._processNextAutoResend(t))},onDisconnect:function(){}})}return Hi}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 Gi}},{key:"setDebugMode",value:function(e){Gi=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:"setOnlineListener",value:function(e){U.get(this._iid).container.onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){U.get(this._iid).container.onlineDetector.setOfflineListener(e)}},{key:"getMemoryStoreForDebugging",value:function(){var e=U.get(this._iid);return e.container.debugCache&&e.container.store instanceof wn?e.container.store:null}},{key:"useMemoryAsDatabaseForDebugging",value:function(){var e=U.get(this._iid);e.container.debugCache=!0,e.container.store=new wn}},{key:"useAsyncStorageAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Fn({AsyncStorage:e,encryption:t.container.encryption})}},{key:"useMMKVAsDatabase",value:function(e){var t=U.get(this._iid);t.container.store=new Gn({MMKV: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){if(0===e)i.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[Ue.NAME_ALPHABETICAL,Ue.CHRONOLOGICAL,Ue.LATEST_LAST_MESSAGE]},{collectionName:"SucceededMessage",keyName:"messageId",index:[Me.LATEST,Me.CHILD_MESSAGE_FIRST]},{collectionName:"UnsentMessage",keyName:"reqId",index:[Me.LATEST_UNSENT,Me.CHILD_MESSAGE_FIRST]}]).then((function(){return t()})).catch((function(e){throw e}));else t()})),i.on("error",(function(e){e?e.code===xt.STORE_NOT_AVAILABLE||e.code===xt.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING?t(null):(J.error("Database initialize failed with an error: ",e),t(e)):t(null)})),i.on("success",(function(){r.container.currentUserId=e,new bt({iid:n._iid,collection:i.collection("GroupChannel")}),new Ge({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 bt({iid:n._iid,collection:null}),new Ge({iid:n._iid,collections:{succeeded:null,unsent:null}}),t(null)}),t)}},{key:"clearCachedData",value:function(){var e=U.get(this._iid),t=e.container,n=t.localCacheEnabled,r=t.nestdb;return new Promise((function(t,i){n&&r?(r.close(),r.reset().then((function(){J.debug("Database clear succeeded."),e.container.nestdb=null,t()})).catch((function(e){J.error("Database clear failed with an error: ",e),i(e)}))):t()}))}},{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;u&&u.start();var d=null,h=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||3===e.length}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new me({type:"string",nullable:!0,ignoreIf:function(e){return 1===e.length||2===e.length}}),new me({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],(n||r)&&J.debug("Please note that apiHost and wsHost are for internal use only."),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).then((function(){if(c)return nt._processNonAutoResendRegisteredPendingMessages(s)})):h.lock((function(n){s.initializeDatabase(e).then((function(){n(),l.connect(e,t)})).then((function(){if(c)return nt._processNonAutoResendRegisteredPendingMessages(s)})).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.clearCachedData().finally((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 as the app goes background.",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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"string",nullable:!0}),new me({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){if(i)n(i,null);else{var s=U.get(r._iid);s.container.apiClient.updateCurrentUserInfo({nickname:e,profileUrl:t},(function(i,a){var o=null;i||(r.currentUser&&(e&&(r.currentUser.nickname=e),t&&(r.currentUser.plainProfileUrl=t,Object.defineProperty(r.currentUser,"profileUrl",{value:r.currentUser.requireAuth?"".concat(r.currentUser.plainProfileUrl,"?auth=").concat(s.container.auth.eKey):r.currentUser.plainProfileUrl,configurable:!0,writable:!1}))),o=r.currentUser),n(i,o)}))}}),n)}},{key:"updateCurrentUserInfoWithProfileImage",value:function(e,t,n){var r=this,i=null,s=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"file",nullable:!0}),new me({type:"callback"})]),a=C(s,4);return i=a[0],e=a[1],t=a[2],n=a[3],oe(this._iid,(function(n){if(i)n(i,null);else{var s=U.get(r._iid);s.container.apiClient.updateCurrentUserInfo({nickname:e,profileImage:t},(function(t,i){var a=null;t||(r.currentUser&&(e&&(r.currentUser.nickname=e),i.profile_url&&(r.currentUser.plainProfileUrl=i.profile_url,Object.defineProperty(r.currentUser,"profileUrl",{value:r.currentUser.requireAuth?"".concat(r.currentUser.plainProfileUrl,"?auth=").concat(s.container.auth.eKey):r.currentUser.plainProfileUrl,configurable:!0,writable:!1}))),a=r.currentUser),n(t,a)}))}}),n)}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e.length>0}}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:"array",optional:!0,nullable:!0,defaultValue:null}),new me({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"string",nullable:!0}),new me({type:c,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:"array",optional:!0,nullable:!0,defaultValue:null}),new me({type:"boolean",nullable:!0,optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({type:c,constraint:function(e){return e._validate()}}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=23}}),new me({type:"number",constraint:function(e){return 0<=e&&e<=59}}),new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({type:"number",constraint:function(e){return e>0}}),new me({type:"number",constraint:function(e){return e>0}}),new me({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=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new me({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 Ot(n)),t(e,r)}))}),t)}},{key:"unblockUser",value:function(e,t){var n=null,r=me.parse(arguments,[new me({type:"object",constraint:function(e){return e&&e.hasOwnProperty("userId")}}),new me({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=me.parse(arguments,[new me({type:"string",constraint:function(e){return e&&(!n.currentUser||e!==n.currentUser.userId)}}),new me({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(me.error,null)}),t)}},{key:"getGroupChannelCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=null,a=me.parse(arguments,[new me({type:i.MemberStateFilter,optional:!0,defaultValue:i.MemberStateFilter.ALL}),new me({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,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadChannelCountParams,a=null,o=me.parse(arguments,[new me({type:"object",optional:!0,defaultValue:null,constraint:function(e){return e instanceof s}}),new me({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=null,s=i.SuperChannelFilter.ALL;e&&(r=e.channelCustomTypesFilter,s=e.superChannelFilter),U.get(n._iid).container.apiClient.getTotalUnreadChannelCount({customTypesFilter:r,superChannelFilter:s},(function(e,n){var r=null;e||(r=parseInt(n.unread_count)),t(e,r)}))}}),t)}},{key:"getTotalUnreadMessageCount",value:function(e,t){var n=this,r=x.get(this._iid),i=r.GroupChannel,s=r.GroupChannelTotalUnreadMessageCountParams,a=null,o=me.parse(arguments,[new me({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 me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.length>0&&e.every((function(e){return Object.keys(ar.UnreadItemKey).map((function(e){return ar.UnreadItemKey[e]})).indexOf(e)>-1}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({type:"string",constraint:function(e){return["gcm","apns","apns_voip"].indexOf(e)>-1}}),new me({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(me.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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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){ar.cachedChannels[e]&&(n.currentUser&&ar.cachedChannels[e].updateReadReceipt(n.currentUser.userId,i),ar.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).then((function(e){return e.markAsDelivered()})).catch((function(e){return J.debug(e)}))}},{key:"getFriendChangeLogsByToken",value:function(e,t){var n=this,r=null,i=me.parse(arguments,[new me({type:"string",optional:!0,defaultValue:null}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return e.hasOwnProperty("friendDiscoveryKey")}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({type:"array",constraint:function(e){return e.every((function(e){return"string"==typeof e}))}}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"number",constraint:function(e){return e>=0}}),new me({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=me.parse(arguments,[new me({type:"string"}),new me({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=me.parse(arguments,[new me({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=me.parse(arguments,[new me({type:"boolean"}),new me({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=this,n=Ge.of(this._iid);if(n){var r=U.get(this._iid).container.store;return Promise.all(e.map((function(e){return new Promise((function(i,s){n.clearByChannelUrl(e).then((function(){var n=Be(t._currentUserId,e);return r.remove(n)})).then((function(){var n=Ke(t._currentUserId,e);return r.remove(n)})).then((function(){i()})).catch((function(e){s(e)}))}))})))}return 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 Ie(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?Fi[e]:Hi}},{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,"`."))}}},{key:"getAppVersion",value:function(){return xi}},{key:"setAppVersion",value:function(e){"string"==typeof e&&$()&&(xi=e)}}]),e}();return ji})); \ No newline at end of file diff --git a/bower.json b/bower.json index 2721ba2..0c066e9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.1.26", + "version": "3.1.27", "authors": [ "Sendbird " ], diff --git a/package.json b/package.json index f9e2d9d..6a2d097 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.1.26", + "version": "3.1.27", "description": "Sendbird JavaScript SDK", "main": "SendBird.min.js", "dependencies": {