diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b3775..92e0bbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog +## v4.3.1 (Feb 15, 2023) +### **Improvements** +- Fixed a bug where `poll.votedOptionIds` is not updated upon calling `poll.applyPollUpdateEvent(pollUpdateEvent)` +- Fixed a bug where auto-resending file message fails occasionally +- `MessageCollectionEventHandler.onMessagesDeleted` + - Added a new parameter `messages: BaseMessage[]` + - Deprecated `messageIds: number[]` + - `onMessagesDeleted` callback now returns either unsent or sent messages through a new parameter `messages: BaseMessage[]`, which you can use to remove pending messages +- Fixed a bug where `MessageRequestHandler.onPending` is called when pending message is marked for auto-resend +- Fixed a bug where `MessageCollection.hasNext` remains true after `MessageCollection.initialize()` is called with `startingPoint` as now +- Fixed a bug where SDK calls `MessageCollectionEventHandler` when handler has not been set +- Fixed a bug where `MessageCollectionEventHandler.onMessagesUpdated` is called on update of `GroupChannel`s `getUnreadMemberCount` and `getUndeliveredMemberCount` +- Deprecated `EVENT_MESSAGE_READ` and `EVENT_MESSAGE_DELIVERED` in `MessageEventSource` +- Exported `BaseMessageCreateParams` and `BaseMessageUpdateParams` +- Improved stability + ## v4.3.0 (Feb 01, 2023) ### **Features** #### **Participant class in Open Channel** diff --git a/__bundle-2a729281.js b/__bundle-2a729281.js deleted file mode 100644 index d877ea7..0000000 --- a/__bundle-2a729281.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&g.indexOf(e)>=0},T=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=v("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},b=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=u([],a(e),!1).sort(),r=u([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){v("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){v("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),A={encrypt:function(e){return e},decrypt:function(e){return e}},C=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:u([],a(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,a,u,c,l,d;return s(this,(function(s){switch(s.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=s.sent())&&void 0!==t?t:[],s.label=2;case 2:s.trys.push([2,7,8,9]),r=o(n),i=r.next(),s.label=3;case 3:return i.done?[3,6]:(a=i.value,[4,this._store.get(a)]);case 4:(u=s.sent())&&this._preference.set(a,u),s.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),l={error:c},[3,9];case 8:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(u([],a(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,o=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new C({store:i}),this.encryption=null!=n?n:A,this.localCacheEnabled=o},w=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),R=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)}))},D=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=R()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){for(var e in this._container)this._container[e].delete(this.key)},e}(),M=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new D({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new D({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var s=[];try{for(var a=o(i.keys()),u=a.next();!u.done;u=a.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return i.delete(e)}))}},e}(),k=function(){function e(){this._dispatcher=new M}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),L=function(){},P=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(h||(h={}));var U,q=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=R(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=P(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=P(this.params);if(Object.keys(t).some((function(e){return T(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(T(s)){var o=s;n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(L),x=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(L),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(L),G=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),Q=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(L);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(U||(U={}));var j,K=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return P({stat_type:e.type,ts:e.createdAt,data:P(e.data)})},e}(),V=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&o.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"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(d.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,s=r.appVersion,o=n(n({},e.headers),{SendBird:"JS,".concat(d.OS_VERSION,",").concat(d.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(o["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(o["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(o["App-Id"]=i,o["Access-Token"]=this._auth.authToken),o},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Q(new K({type:U.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,a,u,c,l,d,p,_,g,y,v;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,r=![h.GET,h.DELETE].includes(n),i=this._sdkState.api,o="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,u=this._createHeader(e,a instanceof FormData?a:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),d=Date.now(),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(p=s.sent()).json()];case 3:if(_=s.sent(),p.ok||p.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),[2,new x(this._iid,_)];throw _?(g=new f(_),!e.requireAuth&&g.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,d,g),g):(g=f.requestFailed,this._statLogApiResult(e,d,g),g);case 4:throw y=s.sent(),this._statLogApiResult(e,d,y),y instanceof f?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?f.requestCanceled:(v=f.networkError,this._logger.debug("fail api request",v),v);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),z=function(e){function n(t,n,r,i){void 0===i&&(i="");var s=e.call(this)||this;return s._iid=t,s.code=n,s.payload=r,s.requestId=r?r.req_id:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(L),B=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(j||(j={}));var H,W=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===j.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return j.CONNECTING;case 1:return j.OPEN}return j.CLOSED},enumerable:!1,configurable:!0}),n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&v("string",e)){var n=z.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",f.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==j.CLOSED?(e._ws.onopen=B,e._ws.onmessage=B,e._ws.onerror=B,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw f.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(M),Y=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,o=void 0===s?null:s,a=this;return(a=e.call(this)||this).code=r,a.payload=o,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:R(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(L),X=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(L),J=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Z=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new V(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new W(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new X(e.payload.unread_cnt)),e.requestId){if(o._ackStateMap.has(e.requestId)){var t=o._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new f({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(f.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){if(t=new J,e.ackRequired){n=null,r=function(r,s){void 0===r&&(r=null),void 0===s&&(s=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(s)))};try{n=setTimeout((function(){return r(f.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof q?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Y?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw f.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(H||(H={}));var $=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(L),ee=function(){function e(e,t){var n=t.auth,r=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=H.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Z(e,{auth:n,sdkState:r,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof $){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case H.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=s.sent(),n.resolve(i),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case H.INITIALIZED:case H.DISCONNECTED:case H.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n;return s(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(f.connectionClosed):t.reject(f.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===H.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===H.CONNECTING||this._currentConnectionStateType===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return e instanceof Y?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new J,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),f.connectionRequired;case 3:return[3,7];case 4:return e instanceof q?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new J,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=f.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(f.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),te="/".concat("v3","/users"),ne="/".concat("v3","/storage/file"),re="/".concat("v3","/group_channels"),ie="/".concat("v3","/sdk/group_channels"),se="/".concat("v3","/open_channels"),oe="/".concat("v3","/sdk/open_channels"),ae="/".concat("v3","/search"),ue="/".concat("v3","/report"),ce="/".concat("v3","/emojis"),le="/".concat("v3","/emoji_categories"),de="/".concat("v3","/polls"),he="/".concat("v3","/scheduled_messages"),pe="/".concat("v3","/sdk/statistics"),fe=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,o=e.call(this)||this;return o.path="".concat(te,"/").concat(n,"/session_key"),o.method=h.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),_e=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,s=t.requestId,o=void 0===s?null:s;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:o},ackRequired:!0})||this}return t(n,e),n}(Y),ge=function(e){function n(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return t(n,e),n}(x),ye=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new f(r.error):null,i}return t(n,e),n}(z),ve=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),me=function(e){return i(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Ee=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Se=function(e,t,n){return void 0===n&&(n=new Ee),i(void 0,void 0,void 0,(function(){var r,i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:r=0,i=null,o=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},s.label=1;case 1:if(!(-1===t||r0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Xe({userProfile:this}))},e}(),Ze=function(e){function r(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new Je(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new f(r):null,s}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){if(this.error)throw this.error;var t=ft.of(e);if(!t)throw f.lostInstance;t.sessionManager.auth.sessionKey=this.key,Pe(e,this.ekey),this.userProfile.apply()},r}(z),$e=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),et=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,o=n.sessionManager,a=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,d=void 0===l?new De:l,h=e.call(this)||this;return h._currentState=null,h._loginTimer=null,h._unresolvedLogi=null,h._stateUpdatedAt=0,h._connectingAt=0,h._connectionRequestQueue=[],h._iid=t,h.sdkState=r,h.cacheContext=i,h.connectionHandlers=s,h._sessionManager=o,h._websocketClient=a,h._dispatcher=u,h._logger=c,h._currentState=d,h.sdkState.websocket.pingerDisabled||(h._pinger=new ke({pingDelegate:{send:function(e){return h._websocketClient.send(e)},error:function(e){return h._websocketClient.error(e)}},sdkState:h.sdkState,logger:c})),h._websocketClient.on("open",(function(){h._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)h._loginTimer&&(clearTimeout(h._loginTimer),h._loginTimer=null),h._dispatcher.dispatch(e.as(Ze))})).on("ping-refresh",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return h._rejectConnectionRequest(f.networkError)})),h._dispatcher.on((function(e){e instanceof Ze&&(h._unresolvedLogi=e,h._tryResolveConnectionRequest())})),h}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new $({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e,t=this._unresolvedLogi;if(this._websocketClient.isOpen&&t)if(this._unresolvedLogi=null,t.error)this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new G),this._rejectConnectionRequest(t.error);else{t.applyTo(this._iid);var n=t.userProfile;this._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}},n.prototype._rejectConnectionRequest=function(e){var t;null===(t=this._pinger)||void 0===t||t.stop(),this._connectionRequestQueue.length>0&&(this._connectionRequestQueue.forEach((function(t){return t.reject(e)})),this._connectionRequestQueue=[],this._statLogConnection(e))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,o=this.cacheContext.localCacheEnabled,a=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",l="JS/c".concat(d.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(d.OS_VERSION),"&sv=").concat(encodeURIComponent(d.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(a.hasSession?"&key=".concat(encodeURIComponent(a.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(l,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new $e(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new K({type:U.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){return t=this._url(e),n=new J,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(Ze.asError(f.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._sessionManager.auth.authToken=e,this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ze.asError(f.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),[4,this.disconnect()];case 1:return e.sent(),[2]}}))}))},n}(M),tt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,o=t.websocketClient,a=t.dispatcher,u=t.logger,c=t.disableWebSocketCloseEventHandling,l=void 0!==c&&c;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._logger=u,this._disableWebSocketCloseEventHandling=l,this._context=new et(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:o,dispatcher:a,logger:u}),this._sdkState=n,this._sessionManager=s,this._websocketClient=o}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"===e._sdkState.appState&&(e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect()))})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===H.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===H.CONNECTING||e.type===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),nt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=h.POST,i.path="".concat(pe),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return t(n,e),n}(q);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(We||(We={}));var rt,it=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,o=e.maxLimit,a=void 0===o?1e3:o,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=We.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=R(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=a,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===We.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new nt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,me(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof Q){var t=e.statLog;r.put(t)}else e instanceof $e&&(r.enabledstate=e.enabled?We.ENABLED:We.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.enabledstate===We.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(rt||(rt={}));var st,ot,at,ut,ct,lt,dt,ht=function(){function e(){this.level=rt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&v("number",c)&&(this.key=i,this.userIds=s,this.updatedAt=c);var l={};try{for(var d=o(this.userIds),h=d.next();!h.done;h=d.next()){l[h.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?P({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case vt.ADD:t<0&&this.userIds.push(e.userId);break;case vt.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),At=function(){function e(e){this.key=e.key,this.value=S("string",e.value)?u([],a(e.value),!1):[]}return e.payloadify=function(e){var t;return e?P({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Ct=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,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=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?P({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null},e}(),Ot=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,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 Ct(e["og:image"]))}return e.payloadify=function(e){return e?P({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ct.payloadify(e.defaultImage):null}):null},e}(),wt=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?P({name:e.name,volume:e.volume}):null},e}();!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(Et||(Et={})),function(e){e.OPERATOR="operator",e.NONE="none"}(St||(St={})),function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(It||(It={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Tt||(Tt={}));var Rt,Dt=function(e){switch(e){case st.BASE:return"";case st.USER:return"MESG";case st.FILE:return"FILE";case st.ADMIN:return"ADMM"}},Mt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g,y=this;(y=e.call(this,t)||this).channelUrl=null,y.channelType=Et.BASE,y.messageId=0,y.parentMessageId=null,y.parentMessage=null,y.silent=!1,y.isOperatorMessage=!1,y.messageType=st.BASE,y.data=null,y.customType=null,y.mentionType=null,y.mentionedUsers=[],y.mentionedUserIds=[],y.mentionedMessageTemplate=null,y.threadInfo=null,y.reactions=[],y.metaArrays=[],y.ogMetaData=null,y.appleCriticalAlertOptions=null,y.createdAt=0,y.updatedAt=0,y.scheduledInfo=null,y.extendedMessage={},y._scheduledStatus=null,y.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,y.channelUrl=n.channel_url,y.channelType=m(Et,n.channel_type)?n.channel_type:Et.GROUP,n.channel&&(n.channel.channel_url&&(y.channelUrl=n.channel.channel_url),n.channel.channel_type&&(y.channelType=n.channel.channel_type)),y.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,y.data=null!==(o=n.data)&&void 0!==o?o:"",y.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",y.mentionType=m(ut,n.mention_type)?n.mention_type:null;var v=n.mentioned_users;y.mentionedUsers=v?v.map((function(e){return new Ye(y._iid,e)})):null;var E=n.mentioned_user_ids;y.mentionedUserIds=null!=E?E:null,y.mentionedUsers&&!y.mentionedUserIds&&(y.mentionedUserIds=y.mentionedUsers.map((function(e){return e.userId}))),y.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",y.threadInfo=n.thread_info?new mt(y._iid,n.thread_info):null,y.reactions=n.reactions?n.reactions.map((function(e){return new Nt(e)})):[];for(var S=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(S).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1},r}(qe),kt=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(St,n.role)?n.role:St.NONE,n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),r}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(Ye),Lt=function(e){function r(t,n){var r,i,s,o,a=this;if((a=e.call(this,t,n)||this).sender=null,a.reqId="",a.replyToChannel=!1,a.sendingStatus=null,a.errorCode=0,a.sender=n.user?new kt(a._iid,n.user):n.sender_id,a.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",a.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&m(dt,n.request_state)&&(a.sendingStatus=n.request_state),!a.sendingStatus)if(a.messageId>0)a.sendingStatus=dt.SUCCEEDED;else if(a.scheduledInfo)switch(a._scheduledStatus=n.scheduled_status,n.scheduled_status){case Tt.SENT:case Tt.IN_QUEUE:a.sendingStatus=dt.SUCCEEDED;break;case Tt.PENDING:a.sendingStatus=dt.SCHEDULED;break;case Tt.FAILED:case Tt.REMOVED:a.sendingStatus=dt.FAILED;break;case Tt.CANCELED:a.sendingStatus=dt.CANCELED}else a.sendingStatus=dt.PENDING;return a.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,a}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{user:kt.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===dt.FAILED&&((e=this.errorCode)>0&&_.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(Mt),Pt=function(){function e(e){var t,n;this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return e?P({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),Ut={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:ot.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return v("number",e.prevResultSize)&&v("number",e.nextResultSize)&&v("boolean",e.isInclusive)&&v("boolean",e.reverse)&&v("string",e.messageTypeFilter)&&m(ot,e.messageTypeFilter)&&S("string",e.customTypesFilter,!0)&&S("string",e.senderUserIdsFilter,!0)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeReactions)&&v("boolean",e.includeParentMessageInfo)},xt=function(e){function r(t,r){var i,s,o,a,u=this;if((u=e.call(this,t,r)||this).message=null,u.translations={},u.message=null!==(i=r.message)&&void 0!==i?i:"",u.messageType=st.ADMIN,u.translations=null!==(s=r.translations)&&void 0!==s?s:{},r.parent_message_info){var c=r.parent_message_info,l=n(n({},c),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:c.file,url:null===(o=c.file)||void 0===o?void 0:o.url,require_auth:null===(a=c.file)||void 0===a?void 0:a.require_auth});u.parentMessage=Yt(t,l)}return u}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:Wt(t.parentMessage)})):null},r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r}(Mt),Ft=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&v("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?P({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Rt||(Rt={}));var Gt,Qt="removed",jt=function(e){switch(e){case Rt.OPEN:return Rt.OPEN;case Rt.CLOSED:return Rt.CLOSED}},Kt=function(e){return!e||e.text&&v("string",e.text)},Vt=function(e){return S("string",e)&&e.every((function(e){return""!==e.trim()}))},zt=function(e){function r(t,n){var r,i,s,o,a,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(o=n.vote_count)&&void 0!==o?o:0,l.createdBy=null!==(a=n.created_by)&&void 0!==a?a:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},r}(qe),Bt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;return(g=e.call(this,t)||this).id=0,g.title=null,g.createdAt=0,g.updatedAt=0,g.closeAt=-1,g.status=Rt.CLOSED,g.messageId=0,g.data=null,g.voterCount=-1,g.options=[],g.createdBy=null,g.allowUserSuggestion=!1,g.allowMultipleVotes=!1,g.votedPollOptionIds=[],g.id=null!==(r=n.id)&&void 0!==r?r:0,g.title=null!==(i=n.title)&&void 0!==i?i:null,g.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,g.updatedAt=null!==(o=n.updated_at)&&void 0!==o?o:0,g.closeAt=null!==(a=n.close_at)&&void 0!==a?a:-1,g.status=null!==(u=jt(n.status))&&void 0!==u?u:Rt.CLOSED,g.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,g.data=null!==(l=n.data)&&void 0!==l?l:null,g.voterCount=null!==(d=n.voter_count)&&void 0!==d?d:-1,g.options=n.options?n.options.map((function(e){return new zt(g._iid,e)})):[],g.createdBy=null!==(h=n.created_by)&&void 0!==h?h:null,g.allowUserSuggestion=null!==(p=n.allow_user_suggestion)&&void 0!==p&&p,g.allowMultipleVotes=null!==(f=n.allow_multiple_votes)&&void 0!==f&&f,g.votedPollOptionIds=null!==(_=n.voted_option_ids)&&void 0!==_?_:[],g}return t(r,e),r.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,o,a,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(i=jt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(o=e.voter_count)&&void 0!==o?o:this.voterCount,this.options=e.options?e.options.map((function(e){return new zt(c._iid,e)})):this.options,this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes},r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return zt.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r}(qe),Ht=function(e){function r(t,r){var i,s,a,u,c,l,d,h=this;if((h=e.call(this,t,r)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=r.message,h.messageType=st.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=o(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var _=f.value;h.translations[_]=""}}catch(e){i={error:e}}finally{try{f&&!f.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}if(h.messageSurvivalSeconds=null!==(c=r.message_survival_seconds)&&void 0!==c?c:-1,h.plugins=r.plugins?r.plugins.map((function(e){return new Ft(e)})):[],h._poll=r.poll?new Bt(h._iid,r.poll):null,r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{created_at:g.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:g.file,url:null===(l=g.file)||void 0===l?void 0:l.url,require_auth:null===(d=g.file)||void 0===d?void 0:d.require_auth});h.parentMessage=Yt(t,P(y))}return h}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return Ft.payloadify(e)})),poll:Bt.payloadify(t._poll),parent_message_info:Wt(t.parentMessage)})):null},r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(r.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),r}(Lt),Wt=function(e){if(e)switch(e.messageType){case st.USER:return Ht.payloadify(e);case st.FILE:return Xt.payloadify(e);case st.ADMIN:return xt.payloadify(e)}return null},Yt=function(e,t){switch(t.type){case"MESG":return new Ht(e,t);case"FILE":return new Xt(e,t);case"ADMM":case"BRDM":return new xt(e,t)}return null},Xt=function(e){function r(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,v,m=this;(m=e.call(this,t,r)||this).messageParams=null,m.plainUrl="",m.requireAuth=!1,m.name=null,m.size=0,m.type=null,m.thumbnails=[],m.messageSurvivalSeconds=-1,m.messageType=st.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;if(m.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],m.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",m.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,m.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",m.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"",m.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,m.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Pt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(m.requireAuth?"?auth=".concat(Pe(m._iid)):"")}))})):[],m.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,r.parent_message_info){var S=r.parent_message_info,I=n(n({},S),{message_id:m.parentMessageId,channel_url:m.channelUrl,channel_type:m.channelType,file:S.file,url:null===(y=S.file)||void 0===y?void 0:y.url,require_auth:null===(v=S.file)||void 0===v?void 0:v.require_auth});m.parentMessage=Yt(t,I)}return m}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:Wt(t.parentMessage)})):null},Object.defineProperty(r.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Pe(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r}(Lt),Jt=function(e){switch(e){case Et.GROUP:return re;case Et.OPEN:return se;default:return null}},Zt=function(e){switch(e){case Et.GROUP:return"".concat(ue,"/group_channels");case Et.OPEN:return"".concat(ue,"/open_channels");default:return null}},$t=function(e,t,n){var r,i;switch(e){case ut.CHANNEL:return!0;case ut.USERS:if(t)try{for(var s=o(t),a=s.next();!a.done;a=s.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return!1},en=function(e,t,n){var r=$t(e.mentionType,e.mentionedUserIds,n),i=$t(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0},tn=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ut.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),e.call(this,{code:"FILE",ackRequired:!0,payload:P({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==lt.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})||this}return t(n,e),n}(Y),nn=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ut.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=h.POST,r.path="".concat(Jt(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=P({message_type:st.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:i,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return Pt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:wt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),r}return t(n,e),n}(q),rn=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new Xt(t,r);var u=ft.of(t).sdkState;return a.isMentioned=$t(a.message.mentionType,null!==(i=a.message.mentionedUserIds)&&void 0!==i?i:null===(s=a.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),a.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,a}return t(n,e),n}(z),sn=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new Xt(t,n);var o=ft.of(t).sdkState;return s.isMentioned=$t(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),o.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Gt||(Gt={}));var on,an=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext,a=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof $&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===H.CONNECTED||this._connectionState===H.CONNECTING||this._connectionState===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var r,i;return s(this,(function(s){switch(s.label){case 0:return this._shouldSendThroughWebSocket?(r=new tn(n(n({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(rn).message];case 2:return r=new nn(n(n({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(sn).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,u,l,d,h,p,_,g;return s(this,(function(s){switch(s.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,s.label=1;case 1:s.trys.push([1,15,16,17]),i=o(t.messageQueue),a=i.next(),s.label=2;case 2:if(a.done)return[3,14];switch(u=a.value,u.state){case Gt.PENDING:case Gt.UPLOADING:return[3,3];case Gt.UPLOADED:return[3,4];case Gt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(u),[3,13];case 4:if(!r)return[3,10];s.label=5;case 5:return s.trys.push([5,8,,9]),u.state=Gt.SENDING,[4,this._sendFileMessage(e,u)];case 6:return l=s.sent(),u.deferred.resolve(l),[4,me(100)];case 7:return s.sent(),[3,9];case 8:return d=s.sent(),u.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(u),s.label=11;case 11:return[3,13];case 12:return u.deferred.reject(u.error.code===c.REQUEST_CANCELED?f.fileUploadCanceled:u.error),[3,13];case 13:return a=i.next(),[3,2];case 14:return[3,17];case 15:return h=s.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(_)throw _.error}return[7];case 17:return p=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,p?[4,this._resolveMessageQueue(e)]:[3,19];case 18:s.sent(),s.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,s.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,a,u,l,d,h,p,_,g,y;return s(this,(function(s){switch(s.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Gt.PENDING})))?T(n.params.file)?t.uploadQueue.length<6?(n.state=Gt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!s.sent())return[3,8];s.label=2;case 2:return s.trys.push([2,4,5,7]),r=new gt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),o=i.as(yt),a=o.url,u=o.fileSize,l=void 0===u?n.params.fileSize:u,d=o.thumbnailSizes,h=void 0===d?n.params.thumbnailSizes:d,p=o.requireAuth,_=void 0!==p&&p,n.params.fileUrl=a,n.params.fileSize=l,n.params.thumbnailSizes=h,n.params.requireAuth=_,n.requireAuth=_,n.state=Gt.UPLOADED,[3,7];case 4:return(g=s.sent()).code===c.REQUEST_FAILED?n.error=new f({code:c.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=g,n.state=Gt.FAILED,[3,7];case 5:return(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return s.sent(),[7];case 7:return[3,10];case 8:return n.state=Gt.FAILED,n.error=f.connectionRequired,(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Gt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:s.sent(),s.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var r,o,a;return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=new J,T(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(o=n.mimeType)&&void 0!==o?o:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Gt.PENDING,deferred:i,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,i.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:u([],a(i.messageQueue),!1);try{for(var c=o(s),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Gt.PENDING:d.state=Gt.FAILED,d.error=f.requestCanceled,this._resolveMessageQueue(e);break;case Gt.UPLOADING:this._requestQueue.cancel(d.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),un={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:ot.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ct.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},cn=function(e){return v("number",e.prevResultSize)&&v("number",e.nextResultSize)&&v("boolean",e.isInclusive)&&v("boolean",e.reverse)&&v("string",e.messageTypeFilter)&&m(ot,e.messageTypeFilter)&&S("string",e.customTypesFilter,!0)&&S("string",e.senderUserIdsFilter,!0)&&m(ct,e.replyType)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeReactions)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)&&v("boolean",e.showSubchannelMessagesOnly)},ln={replyType:ct.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},dn=function(e){return m(ct,e.replyType)&&v("boolean",e.includeReactions)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)};!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(on||(on={}));var hn,pn=function(e){return e.startsWith("EVENT_")||e===on.SYNC_MESSAGE_FILL||e===on.SYNC_MESSAGE_CHANGELOGS||e===on.SYNC_POLL_CHANGELOGS},fn=function(e){function n(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return t(n,e),n}(L),_n=function(e){function n(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return t(n,e),n}(L),gn=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(L),yn=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(L),vn=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(L),mn=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=null,i.source=null,i.event=n,i.source=r,i}return t(n,e),n}(L),En=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,o=t.includeReactions,a=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=h.GET,c.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:!0},c}return t(n,e),n}(q),Sn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Yt(t,n({},r)):null,i}return t(r,e),r}(x),In=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,o=t.token,a=void 0===o?null:o,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,d=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,v=t.includeReactions,m=t.parentMessageId,E=t.includeThreadInfo,S=t.includeParentMessageInfo,I=t.showSubchannelMessagesOnly,T=e.call(this)||this;return T.method=h.GET,T.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=P({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:d,message_ts:s,message_id:a,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:v,parent_message_id:m,include_thread_info:E,include_parent_message_info:S,show_subchannel_message_only:I,include_poll_details:!0}),T}return t(n,e),n}(q),Tn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return Yt(t,e)})),r}return t(n,e),n}(x),bn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,o=t.replyType,a=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,d=e.call(this)||this;return d.method=h.GET,d.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),d.params={change_ts:i,token:s,with_sorted_meta_array:a,include_reactions:u,include_thread_info:c,include_reply_type:o,include_parent_message_info:l,include_poll_details:!0},d}return t(n,e),n}(q),Nn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Yt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(x),An=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=h.GET,i.path="".concat(re,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),Cn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Yt(t,n({},r)):null,i}return t(r,e),r}(x),On={},wn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=o,this.fileMessageQueue=new an(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),On[e]=this}return e.of=function(e){return On[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=Be(e);switch(t.messageType){case st.USER:return new Ht(this._iid,Ht.payloadify(t));case st.FILE:return new Xt(this._iid,Xt.payloadify(t));case st.ADMIN:return new xt(this._iid,xt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return P({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return P({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=Be(e);return new kt(this._iid,kt.payloadify(t))},e.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new En(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Sn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new An(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Cn).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n({channelType:t,channelUrl:e,token:String(r)},un),o)),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Tn).messages,this._dispatcher.dispatch(new fn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n({channelType:t,channelUrl:e,timestamp:r},un),o)),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Tn).messages,this._dispatcher.dispatch(new fn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,r,o){return void 0===o&&(o=on.REQUEST_THREADED_MESSAGE),i(this,void 0,void 0,(function(){var i,a,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},Ut),r),{replyType:ct.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return a=s.sent(),u=a.as(Tn).messages,(c=u.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new fn({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE_CHANGELOGS),i(this,void 0,void 0,(function(){var i,u,c,l,d,h,p,f;return s(this,(function(s){switch(s.label){case 0:return i=new bn(P(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},ln),o))),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Nn),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,p=c.nextToken,f=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new fn({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new _n({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),Rn=function(){function e(){this._onPending=B,this._onFailed=B,this._onSucceeded=B}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case dt.PENDING:this._onPending(t);break;case dt.FAILED:case dt.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case dt.SCHEDULED:case dt.SUCCEEDED:this._onSucceeded(t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),Dn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.parent_message_id,o=n.channel_url,a=n.channel_type;return i&&v("object",i)&&v("number",s)&&v("string",o)&&v("string",a)&&(r.threadInfo=new mt(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(qe),Mn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},kn=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return v("number",this.limit)&&this.limit>0},e}(),Ln=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,o=t.exactMatch,a=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,d=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=h.GET,_.path="".concat(ae,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:o,channel_url:a,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:d,target_fields:p,after:f},_}return t(n,e),n}(q),Pn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Yt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(hn||(hn={}));var Un=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=hn.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(o=n.channelCustomType)&&void 0!==o?o:"",h.messageTimestampFrom=null!==(a=n.messageTimestampFrom)&&void 0!==a?a:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:hn.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&v("string",this.keyword)&&this.keyword.length>0&&v("boolean",this.reverse)&&v("boolean",this.exactMatch)&&v("string",this.channelUrl)&&v("string",this.channelCustomType)&&(v("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(v("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(hn,this.order)&&v("boolean",this.advancedQuery)&&S("string",this.targetFields,!0)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=ft.of(this._iid).requestQueue,t=new Ln(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=s.sent(),i=r.as(Pn),o=i.messages,a=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=a,this._isLoading=!1,this.totalCount=c,[2,o];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(kn),qn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&v("string",this.channelUrl)&&m(Et,this.channelType)},n}(kn),xn=function(e){function n(t,n,r,i){var s,o,a,u,c,l,d,h,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=ot.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ct.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:ot.ALL,_.customTypesFilter=null!==(a=i.customTypesFilter)&&void 0!==a?a:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ct.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,_.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&v("boolean",this.reverse)&&m(ot,this.messageTypeFilter)&&m(ct,this.replyType)&&S("string",this.customTypesFilter,!0)&&S("string",this.senderUserIdsFilter,!0)&&v("boolean",this.includeMetaArray)&&v("boolean",this.includeReactions)&&v("boolean",this.includeParentMessageInfo)&&v("boolean",this.includeThreadInfo)&&v("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,wn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,u([Number.MAX_SAFE_INTEGER],a(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},n}(qn),Fn={channelUrl:null,scheduledMessageId:0},Gn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(r,e),r.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new wn(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},r.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},r.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},r.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){return t=n(n({},Mn),e),He(function(e){return v("string",e.channelUrl)&&v("string",e.channelType)&&m(Et,e.channelType)&&v("number",e.messageId)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)}(t)).throw(f.invalidParameters),[2,this._manager.getMessage(t)]}))}))},r.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){return t=n(n({},Fn),e),He(function(e){return v("string",e.channelUrl)&&v("number",e.scheduledMessageId)}(t)).throw(f.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},r}(_t);export{A as $,h as A,L as B,Et as C,dt as D,M as E,Xt as F,I as G,$ as H,qe as I,H as J,c as K,fn as L,on as M,te as N,le as O,Bt as P,ce as Q,ct as R,f as S,S as T,Ye as U,ft as V,z as W,kn as X,u as Y,a as Z,t as _,de as a,Dn as a$,r as a0,l as a1,Pe as a2,j as a3,Un as a4,Be as a5,Ie as a6,X as a7,Xe as a8,Je as a9,cn as aA,ln as aB,dn as aC,J as aD,Mt as aE,b as aF,It as aG,Te as aH,mn as aI,vn as aJ,gn as aK,_n as aL,ie as aM,re as aN,he as aO,Tt as aP,jt as aQ,ze as aR,Yt as aS,rn as aT,Qt as aU,pn as aV,Se as aW,Wt as aX,yt as aY,gt as aZ,xt as a_,N as aa,R as ab,Gn as ac,rt as ad,Ft as ae,St as af,Ve as ag,ut as ah,At as ai,lt as aj,wt as ak,Zt as al,ue as am,Y as an,$t as ao,en as ap,bt as aq,at as ar,Pt as as,y as at,xn as au,kt as av,me as aw,p as ax,Rn as ay,un as az,q as b,oe as b0,se as b1,hn as b2,Ct as b3,Ot as b4,Nt as b5,vt as b6,mt as b7,x as c,zt as d,P as e,Kt as f,Jt as g,m as h,v as i,i as j,s as k,n as l,yn as m,qn as n,_t as o,Rt as p,T as q,B as r,ot as s,st as t,He as u,Vt as v,Lt as w,Ht as x,wn as y,o as z}; diff --git a/__bundle-7175498d.js b/__bundle-7175498d.js new file mode 100644 index 0000000..4091d54 --- /dev/null +++ b/__bundle-7175498d.js @@ -0,0 +1,15 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&g.indexOf(e)>=0},S=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=v("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},b=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=u([],a(e),!1).sort(),r=u([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){v("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){v("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),N={encrypt:function(e){return e},decrypt:function(e){return e}},C=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:u([],a(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,a,u,c,l,d;return s(this,(function(s){switch(s.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=s.sent())&&void 0!==t?t:[],s.label=2;case 2:s.trys.push([2,7,8,9]),r=o(n),i=r.next(),s.label=3;case 3:return i.done?[3,6]:(a=i.value,[4,this._store.get(a)]);case 4:(u=s.sent())&&this._preference.set(a,u),s.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),l={error:c},[3,9];case 8:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(u([],a(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,o=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new C({store:i}),this.encryption=null!=n?n:N,this.localCacheEnabled=o},w=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),R=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)}))},D=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=R()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){for(var e in this._container)this._container[e].delete(this.key)},e}(),k=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new D({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new D({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var s=[];try{for(var a=o(i.keys()),u=a.next();!u.done;u=a.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}s.forEach((function(e){return i.delete(e)}))}},e}(),M=function(){function e(){this._dispatcher=new k}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),L=function(){},P=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(h||(h={}));var U,q=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=R(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=P(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=P(this.params);if(Object.keys(t).some((function(e){return S(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(S(s)){var o=s;n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(L),x=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(L),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(L),G=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),j=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(L);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(U||(U={}));var Q,K=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return P({stat_type:e.type,ts:e.createdAt,data:P(e.data)})},e}(),V=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&o.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"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(d.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,s=r.appVersion,o=n(n({},e.headers),{SendBird:"JS,".concat(d.OS_VERSION,",").concat(d.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(o["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(o["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(o["App-Id"]=i,o["Access-Token"]=this._auth.authToken),o},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new j(new K({type:U.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,a,u,c,l,d,p,_,g,y,v;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,r=![h.GET,h.DELETE].includes(n),i=this._sdkState.api,o="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,u=this._createHeader(e,a instanceof FormData?a:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),d=Date.now(),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(p=s.sent()).json()];case 3:if(_=s.sent(),p.ok||p.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),[2,new x(this._iid,_)];throw _?(g=new f(_),!e.requireAuth&&g.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,d,g),g):(g=f.requestFailed,this._statLogApiResult(e,d,g),g);case 4:throw y=s.sent(),this._statLogApiResult(e,d,y),y instanceof f?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?f.requestCanceled:(v=f.networkError,this._logger.debug("fail api request",v),v);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=o(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),z=function(e){function n(t,n,r,i){void 0===i&&(i="");var s=e.call(this)||this;return s._iid=t,s.code=n,s.payload=r,s.requestId=r?r.req_id:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(L),B=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Q||(Q={}));var H,W=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Q.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Q.CONNECTING;case 1:return Q.OPEN}return Q.CLOSED},enumerable:!1,configurable:!0}),n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&v("string",e)){var n=z.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",f.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==Q.CLOSED?(e._ws.onopen=B,e._ws.onmessage=B,e._ws.onerror=B,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw f.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(k),Y=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,o=void 0===s?null:s,a=this;return(a=e.call(this)||this).code=r,a.payload=o,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:R(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(L),X=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(L),J=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Z=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new V(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new W(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new X(e.payload.unread_cnt)),e.requestId){if(o._ackStateMap.has(e.requestId)){var t=o._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new f({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(f.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){if(t=new J,e.ackRequired){n=null,r=function(r,s){void 0===r&&(r=null),void 0===s&&(s=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(s)))};try{n=setTimeout((function(){return r(f.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return e instanceof q?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Y?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw f.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(H||(H={}));var $=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(L),ee=function(){function e(e,t){var n=t.auth,r=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=H.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Z(e,{auth:n,sdkState:r,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof $){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case H.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=s.sent(),n.resolve(i),[3,4];case 3:return o=s.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case H.INITIALIZED:case H.DISCONNECTED:case H.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n;return s(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(f.connectionClosed):t.reject(f.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===H.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===H.CONNECTING||this._currentConnectionStateType===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return e instanceof Y?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new J,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),f.connectionRequired;case 3:return[3,7];case 4:return e instanceof q?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new J,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=f.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(f.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),te=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),ne="/".concat("v3","/users"),re="/".concat("v3","/storage/file"),ie="/".concat("v3","/group_channels"),se="/".concat("v3","/sdk/group_channels"),oe="/".concat("v3","/open_channels"),ae="/".concat("v3","/sdk/open_channels"),ue="/".concat("v3","/search"),ce="/".concat("v3","/report"),le="/".concat("v3","/emojis"),de="/".concat("v3","/emoji_categories"),he="/".concat("v3","/polls"),pe="/".concat("v3","/scheduled_messages"),fe="/".concat("v3","/sdk/statistics"),_e=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,o=e.call(this)||this;return o.path="".concat(ne,"/").concat(n,"/session_key"),o.method=h.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),ge=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,s=t.requestId,o=void 0===s?null:s;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:o},ackRequired:!0})||this}return t(n,e),n}(Y),ye=function(e){function n(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return t(n,e),n}(x),ve=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new f(r.error):null,i}return t(n,e),n}(z),me=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),Ee=function(e){return i(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Te=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Ie=function(e,t,n){return void 0===n&&(n=new Te),i(void 0,void 0,void 0,(function(){var r,i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:r=0,i=null,o=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},s.label=1;case 1:if(!(-1===t||r=0&&this._deviceTokens.splice(n,1)},n.prototype.unsetDeviceTokens=function(e){this._deviceTokens=this._deviceTokens.filter((function(t){return t.type!==e}))},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set("sendbird@devicetokens",{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),Ae.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(k),Ce=function(){function e(){this.type=H.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},e}(),Oe=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=H.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(o){switch(o.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return o.sent(),[4,e.changeState(new Me,t)];case 2:return o.sent(),Se((function(){return i(r,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(Ce),we=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=H.DISCONNECTED,r.name="disconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new Re,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new ke({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Re,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Oe,t)];case 1:return n.sent(),[2]}}))}))},n}(Ce),Re=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=H.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o,a,u,l=this;return s(this,(function(d){switch(d.label){case 0:t=Date.now(),n=new J,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),Se((function(){return i(l,void 0,void 0,(function(){return s(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),d.label=1;case 1:return d.trys.push([1,4,,9]),r=e.sdkState.websocket,o=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,Ie((function(t,n){return i(l,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof f&&r.code===c.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),o,a)];case 2:return d.sent(),[4,e.changeState(new De,t)];case 3:return d.sent(),Se((function(){return i(l,void 0,void 0,(function(){return s(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return u=d.sent(),p(u)?[3,7]:u instanceof f?u.code===c.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new we({autoReconnect:!1}),t)]:[3,6];case 5:d.sent(),d.label=6;case 6:return Se((function(){return i(l,void 0,void 0,(function(){return s(this,(function(t){return this._flushCallbacks(u),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw u;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){return n=new J,this._halt(f.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new ke({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new J,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(f.connectionCanceled),[4,e.changeState(new we({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(f.connectionCanceled),[4,e.changeState(new Oe,t)];case 1:return n.sent(),[2]}}))}))},n}(Ce),De=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=H.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new Re,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new we({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Oe,t)];case 1:return n.sent(),[2]}}))}))},n}(Ce),ke=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=H.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o=this;return s(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new J,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,Ie((function(t){return i(o,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof f&&n.code===c.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new De,t)];case 3:return a.sent(),Se((function(){return i(o,void 0,void 0,(function(){return s(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),p(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof f?r.code===c.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new Me,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return Se((function(){return i(o,void 0,void 0,(function(){return s(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new J,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n;return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:f.connectionCanceled),[4,e.changeState(new Oe,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(f.connectionCanceled),[4,e.changeState(new Oe,t)];case 1:return n.sent(),[2]}}))}))},n}(Ce),Me=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=H.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new ke({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(Ce),Le=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Y),Pe=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=t,this.sdkState=n,this._logger=r}return Object.defineProperty(e.prototype,"isWaiting",{get:function(){return!!this._pingTimeoutTimer},enumerable:!1,configurable:!0}),e.prototype.ping=function(){var e,t=this,n=new Le;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e.prototype.refreshTimer=function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)},e.prototype.start=function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()},e.prototype.stop=function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)},e}(),Ue=function(){function e(e){void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?1048576*e.file_upload_size_limit:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=e.application_attributes||[],this.premiumFeatureList=e.premium_feature_list||[],this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history")}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/1048576,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction}},e}(),qe=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),xe=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=h.POST,i.path="".concat(ne,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(q),Fe=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(x),Ge=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,s=e.call(this)||this;return s.method=h.PUT,s.path="".concat(ne,"/").concat(n,"/metadata"),s.params={metadata:r,upsert:i},s}return t(n,e),n}(q),je=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(x),Qe=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=h.DELETE,i.path="".concat(ne,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(q);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(x);var Ke=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=h.DELETE,r.path="".concat(ne,"/").concat(n,"/metadata"),r}return t(n,e),n}(q);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(x);var Ve,ze=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Be=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},He=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Ve||(Ve={}));var We,Ye=function(e){function r(t,n){var r,i,s,o,c,l,d,h,p,f,_,g,y=this;return(y=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",y.nickname=null!==(o=null!==(s=n.nickname)&&void 0!==s?s:n.name)&&void 0!==o?o:"",y.plainProfileUrl=null!==(l=null!==(c=n.profile_url)&&void 0!==c?c:n.image)&&void 0!==l?l:"",y.requireAuth=null!==(d=n.require_auth_for_profile_image)&&void 0!==d&&d,y.metaData=null!==(h=n.metadata)&&void 0!==h?h:{},y.connectionStatus=Ve.NON_AVAILABLE,m(Ve,n.is_online)?y.connectionStatus=n.is_online:v("boolean",n.is_online)&&(y.connectionStatus=n.is_online?Ve.ONLINE:Ve.OFFLINE),y.isActive=null===(p=n.is_active)||void 0===p||p,y.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,y.preferredLanguages=n.preferred_languages?u([],a(n.preferred_languages),!1):null,y.friendDiscoveryKey=null!==(_=n.friend_discovery_key)&&void 0!==_?_:null,y.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,y}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=ft.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return ze(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return v("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return He(this._isValidMetaData(e)).throw(f.invalidParameters),t=ft.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xe({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return o=s.sent(),a=o.as(Fe).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,o,a,u;return s(this,(function(s){switch(s.label){case 0:return He(this._isValidMetaData(e)).throw(f.invalidParameters),n=ft.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new Ge({userId:r.userId,metadata:e,upsert:t}),[4,i.send(o)];case 1:return a=s.sent(),u=a.as(je).metadata,this._applyMetaData(u),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return He(v("string",e)).throw(f.invalidParameters),t=ft.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Qe({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return s.sent(),this._applyMetaData(((o={})[e]=!0,o),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=ft.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ke({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(qe),Xe=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(L),Je=function(){function e(e,t){var n,r,i,s,o,a,u,c,l,d,h,p,f,_;this._iid=e,this.appInfo=new Ue(t),this.user=new Ye(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(o=null===(s=t.reconnect)||void 0===s?void 0:s.interval)&&void 0!==o?o:3e3,this.reconnectMaxInterval=null!==(u=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==u?u:6e4,this.reconnectRetryCount=null!==(l=null===(c=t.reconnect)||void 0===c?void 0:c.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(h=null===(d=t.reconnect)||void 0===d?void 0:d.mul)&&void 0!==h?h:2,this.maxUnreadCountOnSuperGroup=null!==(p=t.max_unread_cnt_on_super_group)&&void 0!==p?p:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(_=t.back_off_delay)&&void 0!==_?_:100}return e.payloadify=function(e){return n(n(n({},Ye.payloadify(e.user)),Ue.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ft.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Xe({userProfile:this}))},e}(),Ze=function(e){function r(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new Je(t,r),s.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new f(r):null,s}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=ft.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw f.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(z),$e=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),et=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,o=n.sessionManager,a=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,d=void 0===l?new Me:l,h=e.call(this)||this;return h._currentState=null,h._loginTimer=null,h._unresolvedLogi=null,h._stateUpdatedAt=0,h._connectingAt=0,h._connectionRequestQueue=[],h._iid=t,h.sdkState=r,h.cacheContext=i,h.connectionHandlers=s,h._sessionManager=o,h._websocketClient=a,h._dispatcher=u,h._logger=c,h._currentState=d,h.sdkState.websocket.pingerDisabled||(h._pinger=new Pe({pingDelegate:{send:function(e){return h._websocketClient.send(e)},error:function(e){return h._websocketClient.error(e)}},sdkState:h.sdkState,logger:c})),h._websocketClient.on("open",(function(){h._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)h.clearLoginTimer(),h._dispatcher.dispatch(e.as(Ze))})).on("ping-refresh",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=h._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return h._rejectConnectionRequest(f.networkError)})),h._dispatcher.on((function(e){e instanceof Ze&&(h._unresolvedLogi=e,h._tryResolveConnectionRequest())})),h}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new $({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new G),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0&&(this._connectionRequestQueue.forEach((function(t){return t.reject(e)})),this._connectionRequestQueue=[],this._statLogConnection(e))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,o=this.cacheContext.localCacheEnabled,a=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",l="JS/c".concat(d.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(d.OS_VERSION),"&sv=").concat(encodeURIComponent(d.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(a.hasSession?"&key=".concat(encodeURIComponent(a.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(l,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new $e(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new j(new K({type:U.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){return t=this._url(e),n=new J,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(Ze.asError(f.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._sessionManager.auth.authToken=e,this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ze.asError(f.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(k),tt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,o=t.websocketClient,a=t.dispatcher,u=t.logger,c=t.disableWebSocketCloseEventHandling,l=void 0!==c&&c;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._logger=u,this._disableWebSocketCloseEventHandling=l,this._context=new et(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:o,dispatcher:a,logger:u}),this._sdkState=n,this._sessionManager=s,this._websocketClient=o}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"===e._sdkState.appState&&(e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect()))})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===H.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===H.CONNECTING||e.type===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),nt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=h.POST,i.path="".concat(fe),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return t(n,e),n}(q);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(We||(We={}));var rt,it=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,o=e.maxLimit,a=void 0===o?1e3:o,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=We.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=R(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=a,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===We.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new nt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,Ee(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof j){var t=e.statLog;r.put(t)}else e instanceof $e&&(r.enabledstate=e.enabled?We.ENABLED:We.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.enabledstate===We.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(rt||(rt={}));var st,ot,at,ut,ct,lt,dt,ht=function(){function e(){this.level=rt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&v("number",c)&&(this.key=i,this.userIds=s,this.updatedAt=c);var l={};try{for(var d=o(this.userIds),h=d.next();!h.done;h=d.next()){l[h.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?P({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case vt.ADD:t<0&&this.userIds.push(e.userId);break;case vt.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),Nt=function(){function e(e){this.key=e.key,this.value=T("string",e.value)?u([],a(e.value),!1):[]}return e.payloadify=function(e){var t;return e?P({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Ct=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,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=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?P({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null},e}(),Ot=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,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 Ct(e["og:image"]))}return e.payloadify=function(e){return e?P({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ct.payloadify(e.defaultImage):null}):null},e}(),wt=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?P({name:e.name,volume:e.volume}):null},e}();!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(Et||(Et={})),function(e){e.OPERATOR="operator",e.NONE="none"}(Tt||(Tt={})),function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(It||(It={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(St||(St={}));var Rt,Dt=function(e){switch(e){case st.BASE:return"";case st.USER:return"MESG";case st.FILE:return"FILE";case st.ADMIN:return"ADMM"}},kt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g,y=this;(y=e.call(this,t)||this).channelUrl=null,y.channelType=Et.BASE,y.messageId=0,y.parentMessageId=null,y.parentMessage=null,y.silent=!1,y.isOperatorMessage=!1,y.messageType=st.BASE,y.data=null,y.customType=null,y.mentionType=null,y.mentionedUsers=[],y.mentionedUserIds=[],y.mentionedMessageTemplate=null,y.threadInfo=null,y.reactions=[],y.metaArrays=[],y.ogMetaData=null,y.appleCriticalAlertOptions=null,y.createdAt=0,y.updatedAt=0,y.scheduledInfo=null,y.extendedMessage={},y._scheduledStatus=null,y.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,y.channelUrl=n.channel_url,y.channelType=m(Et,n.channel_type)?n.channel_type:Et.GROUP,n.channel&&(n.channel.channel_url&&(y.channelUrl=n.channel.channel_url),n.channel.channel_type&&(y.channelType=n.channel.channel_type)),y.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,y.data=null!==(o=n.data)&&void 0!==o?o:"",y.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",y.mentionType=m(ut,n.mention_type)?n.mention_type:null;var v=n.mentioned_users;y.mentionedUsers=v?v.map((function(e){return new Ye(y._iid,e)})):null;var E=n.mentioned_user_ids;y.mentionedUserIds=null!=E?E:null,y.mentionedUsers&&!y.mentionedUserIds&&(y.mentionedUserIds=y.mentionedUsers.map((function(e){return e.userId}))),y.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",y.threadInfo=n.thread_info?new mt(y._iid,n.thread_info):null,y.reactions=n.reactions?n.reactions.map((function(e){return new At(e)})):[];for(var T=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(T).sort((function(e,t){return e.localeCompare(t)})),S=0;S=t)return this.parentMessage=e,!0}return!1},r}(qe),Mt=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(Tt,n.role)?n.role:Tt.NONE,n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),r}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(Ye),Lt=function(e){function r(t,n){var r,i,s,o,a=this;if((a=e.call(this,t,n)||this).sender=null,a.reqId="",a.replyToChannel=!1,a.sendingStatus=null,a.errorCode=0,a.sender=n.user?new Mt(a._iid,n.user):n.sender_id,a.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",a.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&m(dt,n.request_state)&&(a.sendingStatus=n.request_state),!a.sendingStatus)if(a.messageId>0)a.sendingStatus=dt.SUCCEEDED;else if(a.scheduledInfo)switch(a._scheduledStatus=n.scheduled_status,n.scheduled_status){case St.SENT:case St.IN_QUEUE:a.sendingStatus=dt.SUCCEEDED;break;case St.PENDING:a.sendingStatus=dt.SCHEDULED;break;case St.FAILED:case St.REMOVED:a.sendingStatus=dt.FAILED;break;case St.CANCELED:a.sendingStatus=dt.CANCELED}else a.sendingStatus=dt.PENDING;return a.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,a}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{user:Mt.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===dt.FAILED&&((e=this.errorCode)>0&&_.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(kt),Pt=function(){function e(e){var t,n;this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return e?P({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),Ut={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:ot.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},qt=function(e){return v("number",e.prevResultSize)&&v("number",e.nextResultSize)&&v("boolean",e.isInclusive)&&v("boolean",e.reverse)&&v("string",e.messageTypeFilter)&&m(ot,e.messageTypeFilter)&&T("string",e.customTypesFilter,!0)&&T("string",e.senderUserIdsFilter,!0)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeReactions)&&v("boolean",e.includeParentMessageInfo)},xt=function(e){function r(t,r){var i,s,o,a,u=this;if((u=e.call(this,t,r)||this).message=null,u.translations={},u.message=null!==(i=r.message)&&void 0!==i?i:"",u.messageType=st.ADMIN,u.translations=null!==(s=r.translations)&&void 0!==s?s:{},r.parent_message_info){var c=r.parent_message_info,l=n(n({},c),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:c.file,url:null===(o=c.file)||void 0===o?void 0:o.url,require_auth:null===(a=c.file)||void 0===a?void 0:a.require_auth});u.parentMessage=Yt(t,l)}return u}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:Wt(t.parentMessage)})):null},r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r}(kt),Ft=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&v("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?P({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Rt||(Rt={}));var Gt,jt="removed",Qt=function(e){switch(e){case Rt.OPEN:return Rt.OPEN;case Rt.CLOSED:return Rt.CLOSED}},Kt=function(e){return!e||e.text&&v("string",e.text)},Vt=function(e){return T("string",e)&&e.every((function(e){return""!==e.trim()}))},zt=function(e){function r(t,n){var r,i,s,o,a,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(o=n.vote_count)&&void 0!==o?o:0,l.createdBy=null!==(a=n.created_by)&&void 0!==a?a:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},r}(qe),Bt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;return(g=e.call(this,t)||this).id=0,g.title=null,g.createdAt=0,g.updatedAt=0,g.closeAt=-1,g.status=Rt.CLOSED,g.messageId=0,g.data=null,g.voterCount=-1,g.options=[],g.createdBy=null,g.allowUserSuggestion=!1,g.allowMultipleVotes=!1,g.votedPollOptionIds=[],g.id=null!==(r=n.id)&&void 0!==r?r:0,g.title=null!==(i=n.title)&&void 0!==i?i:null,g.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,g.updatedAt=null!==(o=n.updated_at)&&void 0!==o?o:0,g.closeAt=null!==(a=n.close_at)&&void 0!==a?a:-1,g.status=null!==(u=Qt(n.status))&&void 0!==u?u:Rt.CLOSED,g.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,g.data=null!==(l=n.data)&&void 0!==l?l:null,g.voterCount=null!==(d=n.voter_count)&&void 0!==d?d:-1,g.options=n.options?n.options.map((function(e){return new zt(g._iid,e)})):[],g.createdBy=null!==(h=n.created_by)&&void 0!==h?h:null,g.allowUserSuggestion=null!==(p=n.allow_user_suggestion)&&void 0!==p&&p,g.allowMultipleVotes=null!==(f=n.allow_multiple_votes)&&void 0!==f&&f,g.votedPollOptionIds=null!==(_=n.voted_option_ids)&&void 0!==_?_:[],g}return t(r,e),r.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,o,a,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(i=Qt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(o=e.voter_count)&&void 0!==o?o:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new zt(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes},r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return zt.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r}(qe),Ht=function(e){function r(t,r){var i,s,a,u,c,l,d,h=this;if((h=e.call(this,t,r)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=r.message,h.messageType=st.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=o(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var _=f.value;h.translations[_]=""}}catch(e){i={error:e}}finally{try{f&&!f.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}if(h.messageSurvivalSeconds=null!==(c=r.message_survival_seconds)&&void 0!==c?c:-1,h.plugins=r.plugins?r.plugins.map((function(e){return new Ft(e)})):[],h._poll=r.poll?new Bt(h._iid,r.poll):null,r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{created_at:g.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:g.file,url:null===(l=g.file)||void 0===l?void 0:l.url,require_auth:null===(d=g.file)||void 0===d?void 0:d.require_auth});h.parentMessage=Yt(t,P(y))}return h}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return Ft.payloadify(e)})),poll:Bt.payloadify(t._poll),parent_message_info:Wt(t.parentMessage)})):null},r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(r.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),r}(Lt),Wt=function(e){if(e)switch(e.messageType){case st.USER:return Ht.payloadify(e);case st.FILE:return Xt.payloadify(e);case st.ADMIN:return xt.payloadify(e)}return null},Yt=function(e,t){switch(t.type){case"MESG":return new Ht(e,t);case"FILE":return new Xt(e,t);case"ADMM":case"BRDM":return new xt(e,t)}return null},Xt=function(e){function r(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,v,m=this;(m=e.call(this,t,r)||this).messageParams=null,m.plainUrl="",m.requireAuth=!1,m.name=null,m.size=0,m.type=null,m.thumbnails=[],m.messageSurvivalSeconds=-1,m.messageType=st.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;m.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],m.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",m.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,m.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",m.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"";var T=ft.of(m._iid).sessionManager;if(m.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,m.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Pt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(m.requireAuth?"?auth=".concat(T.ekey):"")}))})):[],m.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,r.parent_message_info){var I=r.parent_message_info,S=n(n({},I),{message_id:m.parentMessageId,channel_url:m.channelUrl,channel_type:m.channelType,file:I.file,url:null===(y=I.file)||void 0===y?void 0:y.url,require_auth:null===(v=I.file)||void 0===v?void 0:v.require_auth});m.parentMessage=Yt(t,S)}return m}return t(r,e),r.payloadify=function(t){return t?P(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:Wt(t.parentMessage)})):null},Object.defineProperty(r.prototype,"url",{get:function(){var e=ft.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),r.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=n(n({},Ut),t),He(this.messageId>0&&v("number",e)&&qt(r)).throw(f.invalidParameters),[4,wn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},r}(Lt),Jt=function(e){switch(e){case Et.GROUP:return ie;case Et.OPEN:return oe;default:return null}},Zt=function(e){switch(e){case Et.GROUP:return"".concat(ce,"/group_channels");case Et.OPEN:return"".concat(ce,"/open_channels");default:return null}},$t=function(e,t,n){var r,i;switch(e){case ut.CHANNEL:return!0;case ut.USERS:if(t)try{for(var s=o(t),a=s.next();!a.done;a=s.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}return!1},en=function(e,t,n){var r=$t(e.mentionType,e.mentionedUserIds,n),i=$t(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0},tn=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ut.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),e.call(this,{code:"FILE",ackRequired:!0,payload:P({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==lt.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})||this}return t(n,e),n}(Y),nn=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ut.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=h.POST,r.path="".concat(Jt(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=P({message_type:st.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:i,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return Pt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return Nt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:wt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),r}return t(n,e),n}(q),rn=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new Xt(t,r);var u=ft.of(t).sdkState;return a.isMentioned=$t(a.message.mentionType,null!==(i=a.message.mentionedUserIds)&&void 0!==i?i:null===(s=a.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),a.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,a}return t(n,e),n}(z),sn=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new Xt(t,n);var o=ft.of(t).sdkState;return s.isMentioned=$t(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),o.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Gt||(Gt={}));var on,an=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext,a=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof $&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===H.CONNECTED||this._connectionState===H.CONNECTING||this._connectionState===H.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var r,i;return s(this,(function(s){switch(s.label){case 0:return this._shouldSendThroughWebSocket?(r=new tn(n(n({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return i=s.sent(),[2,i.as(rn).message];case 2:return r=new nn(n(n({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),[2,i.as(sn).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,u,l,d,h,p,_,g;return s(this,(function(s){switch(s.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,s.label=1;case 1:s.trys.push([1,15,16,17]),i=o(t.messageQueue),a=i.next(),s.label=2;case 2:if(a.done)return[3,14];switch(u=a.value,u.state){case Gt.PENDING:case Gt.UPLOADING:return[3,3];case Gt.UPLOADED:return[3,4];case Gt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(u),[3,13];case 4:if(!r)return[3,10];s.label=5;case 5:return s.trys.push([5,8,,9]),u.state=Gt.SENDING,[4,this._sendFileMessage(e,u)];case 6:return l=s.sent(),u.deferred.resolve(l),[4,Ee(100)];case 7:return s.sent(),[3,9];case 8:return d=s.sent(),u.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(u),s.label=11;case 11:return[3,13];case 12:return u.deferred.reject(u.error.code===c.REQUEST_CANCELED?f.fileUploadCanceled:u.error),[3,13];case 13:return a=i.next(),[3,2];case 14:return[3,17];case 15:return h=s.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(_)throw _.error}return[7];case 17:return p=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,p?[4,this._resolveMessageQueue(e)]:[3,19];case 18:s.sent(),s.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,s.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,a,u,l,d,h,p,_,g,y;return s(this,(function(s){switch(s.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Gt.PENDING})))?S(n.params.file)?t.uploadQueue.length<6?(n.state=Gt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!s.sent())return[3,8];s.label=2;case 2:return s.trys.push([2,4,5,7]),r=new gt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),o=i.as(yt),a=o.url,u=o.fileSize,l=void 0===u?n.params.fileSize:u,d=o.thumbnailSizes,h=void 0===d?n.params.thumbnailSizes:d,p=o.requireAuth,_=void 0!==p&&p,n.params.fileUrl=a,n.params.fileSize=l,n.params.thumbnailSizes=h,n.params.requireAuth=_,n.requireAuth=_,n.state=Gt.UPLOADED,[3,7];case 4:return(g=s.sent()).code===c.REQUEST_FAILED?n.error=new f({code:c.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=g,n.state=Gt.FAILED,[3,7];case 5:return(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return s.sent(),[7];case 7:return[3,10];case 8:return n.state=Gt.FAILED,n.error=f.connectionRequired,(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Gt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:s.sent(),s.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var r,o,a;return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=new J,S(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(o=n.mimeType)&&void 0!==o?o:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Gt.PENDING,deferred:i,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,i.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:u([],a(i.messageQueue),!1);try{for(var c=o(s),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Gt.PENDING:d.state=Gt.FAILED,d.error=f.requestCanceled,this._resolveMessageQueue(e);break;case Gt.UPLOADING:this._requestQueue.cancel(d.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),un={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:ot.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ct.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},cn=function(e){return v("number",e.prevResultSize)&&v("number",e.nextResultSize)&&v("boolean",e.isInclusive)&&v("boolean",e.reverse)&&v("string",e.messageTypeFilter)&&m(ot,e.messageTypeFilter)&&T("string",e.customTypesFilter,!0)&&T("string",e.senderUserIdsFilter,!0)&&m(ct,e.replyType)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeReactions)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)&&v("boolean",e.showSubchannelMessagesOnly)},ln={replyType:ct.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},dn=function(e){return m(ct,e.replyType)&&v("boolean",e.includeReactions)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)};!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(on||(on={}));var hn,pn=function(e){return e.startsWith("EVENT_")||e===on.SYNC_MESSAGE_FILL||e===on.SYNC_MESSAGE_CHANGELOGS||e===on.SYNC_POLL_CHANGELOGS},fn=function(e){function n(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return t(n,e),n}(L),_n=function(e){function n(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return t(n,e),n}(L),gn=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(L),yn=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(L),vn=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(L),mn=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=null,i.source=null,i.event=n,i.source=r,i}return t(n,e),n}(L),En=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,o=t.includeReactions,a=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=h.GET,c.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:!0},c}return t(n,e),n}(q),Tn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Yt(t,n({},r)):null,i}return t(r,e),r}(x),In=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,o=t.token,a=void 0===o?null:o,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,d=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,v=t.includeReactions,m=t.parentMessageId,E=t.includeThreadInfo,T=t.includeParentMessageInfo,I=t.showSubchannelMessagesOnly,S=e.call(this)||this;return S.method=h.GET,S.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages"),S.params=P({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:d,message_ts:s,message_id:a,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:v,parent_message_id:m,include_thread_info:E,include_parent_message_info:T,show_subchannel_message_only:I,include_poll_details:!0}),S}return t(n,e),n}(q),Sn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return Yt(t,e)})),r}return t(n,e),n}(x),bn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,o=t.replyType,a=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,d=e.call(this)||this;return d.method=h.GET,d.path="".concat(Jt(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),d.params={change_ts:i,token:s,with_sorted_meta_array:a,include_reactions:u,include_thread_info:c,include_reply_type:o,include_parent_message_info:l,include_poll_details:!0},d}return t(n,e),n}(q),An=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Yt(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(x),Nn=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=h.GET,i.path="".concat(ie,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),Cn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Yt(t,n({},r)):null,i}return t(r,e),r}(x),On={},wn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=o,this.fileMessageQueue=new an(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),On[e]=this}return e.of=function(e){return On[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=Be(e);switch(t.messageType){case st.USER:return new Ht(this._iid,Ht.payloadify(t));case st.FILE:return new Xt(this._iid,Xt.payloadify(t));case st.ADMIN:return new xt(this._iid,xt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return P({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return P({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=Be(e);return new Mt(this._iid,Mt.payloadify(t))},e.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new En(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Tn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new Nn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Cn).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n({channelType:t,channelUrl:e,token:String(r)},un),o)),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Sn).messages,this._dispatcher.dispatch(new fn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n({channelType:t,channelUrl:e,timestamp:r},un),o)),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Sn).messages,this._dispatcher.dispatch(new fn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,r,o){return void 0===o&&(o=on.REQUEST_THREADED_MESSAGE),i(this,void 0,void 0,(function(){var i,a,u,c;return s(this,(function(s){switch(s.label){case 0:return i=new In(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},Ut),r),{replyType:ct.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return a=s.sent(),u=a.as(Sn).messages,(c=u.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new fn({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,r,o,a){return void 0===a&&(a=on.REQUEST_MESSAGE_CHANGELOGS),i(this,void 0,void 0,(function(){var i,u,c,l,d,h,p,f;return s(this,(function(s){switch(s.label){case 0:return i=new bn(P(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},ln),o))),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(An),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,p=c.nextToken,f=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new fn({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new _n({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),Rn=function(){function e(){this._onPending=B,this._onFailed=B,this._onSucceeded=B}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case dt.PENDING:0===t.errorCode&&this._onPending(t);break;case dt.FAILED:case dt.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case dt.SCHEDULED:case dt.SUCCEEDED:this._onSucceeded(t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),Dn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.parent_message_id,o=n.channel_url,a=n.channel_type;return i&&v("object",i)&&v("number",s)&&v("string",o)&&v("string",a)&&(r.threadInfo=new mt(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(qe),kn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Mn=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return v("number",this.limit)&&this.limit>0},e}(),Ln=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,o=t.exactMatch,a=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,d=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=h.GET,_.path="".concat(ue,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:o,channel_url:a,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:d,target_fields:p,after:f},_}return t(n,e),n}(q),Pn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Yt(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(hn||(hn={}));var Un=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=hn.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(o=n.channelCustomType)&&void 0!==o?o:"",h.messageTimestampFrom=null!==(a=n.messageTimestampFrom)&&void 0!==a?a:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:hn.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&v("string",this.keyword)&&this.keyword.length>0&&v("boolean",this.reverse)&&v("boolean",this.exactMatch)&&v("string",this.channelUrl)&&v("string",this.channelCustomType)&&(v("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(v("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(hn,this.order)&&v("boolean",this.advancedQuery)&&T("string",this.targetFields,!0)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,r,i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=ft.of(this._iid).requestQueue,t=new Ln(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=s.sent(),i=r.as(Pn),o=i.messages,a=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=a,this._isLoading=!1,this.totalCount=c,[2,o];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(Mn),qn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&v("string",this.channelUrl)&&m(Et,this.channelType)},n}(Mn),xn=function(e){function n(t,n,r,i){var s,o,a,u,c,l,d,h,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=ot.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ct.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:ot.ALL,_.customTypesFilter=null!==(a=i.customTypesFilter)&&void 0!==a?a:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ct.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,_.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&v("boolean",this.reverse)&&m(ot,this.messageTypeFilter)&&m(ct,this.replyType)&&T("string",this.customTypesFilter,!0)&&T("string",this.senderUserIdsFilter,!0)&&v("boolean",this.includeMetaArray)&&v("boolean",this.includeReactions)&&v("boolean",this.includeParentMessageInfo)&&v("boolean",this.includeThreadInfo)&&v("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,wn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,u([Number.MAX_SAFE_INTEGER],a(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},n}(qn),Fn={channelUrl:null,scheduledMessageId:0},Gn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(r,e),r.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new wn(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},r.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},r.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},r.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){return t=n(n({},kn),e),He(function(e){return v("string",e.channelUrl)&&v("string",e.channelType)&&m(Et,e.channelType)&&v("number",e.messageId)&&v("boolean",e.includeMetaArray)&&v("boolean",e.includeParentMessageInfo)&&v("boolean",e.includeThreadInfo)}(t)).throw(f.invalidParameters),[2,this._manager.getMessage(t)]}))}))},r.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){return t=n(n({},Fn),e),He(function(e){return v("string",e.channelUrl)&&v("number",e.scheduledMessageId)}(t)).throw(f.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},r}(_t);export{N as $,h as A,L as B,Et as C,dt as D,k as E,Xt as F,I as G,$ as H,qe as I,H as J,c as K,fn as L,on as M,ne as N,de as O,Bt as P,le as Q,ct as R,f as S,T,Ye as U,ft as V,z as W,Mn as X,u as Y,a as Z,t as _,he as a,ae as a$,r as a0,l as a1,Q as a2,Un as a3,Be as a4,Se as a5,X as a6,Xe as a7,Je as a8,A as a9,cn as aA,ln as aB,dn as aC,J as aD,kt as aE,b as aF,It as aG,mn as aH,vn as aI,gn as aJ,_n as aK,se as aL,ie as aM,pe as aN,St as aO,Qt as aP,ze as aQ,Yt as aR,rn as aS,jt as aT,pn as aU,Ie as aV,Wt as aW,yt as aX,gt as aY,xt as aZ,Dn as a_,R as aa,Gn as ab,be as ac,rt as ad,Ft as ae,Tt as af,Ve as ag,ut as ah,Nt as ai,lt as aj,wt as ak,Zt as al,ce as am,Y as an,$t as ao,en as ap,bt as aq,at as ar,Pt as as,y as at,xn as au,Mt as av,Ee as aw,p as ax,Rn as ay,un as az,q as b,oe as b0,hn as b1,Ct as b2,Ot as b3,At as b4,vt as b5,mt as b6,x as c,zt as d,P as e,Kt as f,Jt as g,m as h,v as i,i as j,s as k,n as l,yn as m,qn as n,_t as o,Rt as p,S as q,B as r,ot as s,st as t,He as u,Vt as v,Lt as w,o as x,Ht as y,wn as z}; diff --git a/__bundle-c01340eb.js b/__bundle-c01340eb.js new file mode 100644 index 0000000..db3b083 --- /dev/null +++ b/__bundle-c01340eb.js @@ -0,0 +1 @@ +import{_ as e,A as t,a as n,b as r,P as i,c as s,d as o,g as a,e as u,i as c,v as l,f as h,h as d,C as f,j as p,k as v,u as _,S as m,l as y,m as g,M as b,n as w,V as I,U as E,o as k,q as N,r as T,s as S,t as O,w as C,R as A,x,y as P,F as L,z as R,I as D,E as M,B as U,D as q,G as F,H as B,J as K,K as j,L as H,W as z,N as V,O as Q,Q as G,T as W,X as Y,Y as X,Z as J,$ as Z,a0 as $,a1 as ee,a2 as te,a3 as ne,a4 as re,a5 as ie,a6 as se,a7 as oe,a8 as ae,a9 as ue,aa as ce,ab as le,ac as he}from"./__bundle-7175498d.js";import{U as de,s as fe,v as pe,B as ve,a as _e,b as me,i as ye,F as ge,c as be}from"./__bundle-d8d501e8.js";var we,Ie,Ee,ke;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(we||(we={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(Ie||(Ie={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(Ee||(Ee={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(ke||(ke={}));var Ne,Te,Se,Oe=function(r){function i(e){var i=e.title,s=e.optionTexts,o=e.data,a=e.allowUserSuggestion,u=e.allowMultipleVotes,c=e.closeAt,l=r.call(this)||this;return l.method=t.POST,l.path=n,l.params={title:i,options:s,data:o,allow_user_suggestion:a,allow_multiple_votes:u,close_at:c},l}return e(i,r),i}(r),Ce=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Ae=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=r.call(this)||this;return a.method=t.GET,a.path="".concat(n,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return e(i,r),i}(r),xe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Pe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=r.call(this)||this;return u.method=t.GET,u.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a)),u.params={channel_url:i,channel_type:s},u}return e(i,r),i}(r),Le=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pollOption=new o(e,n),r}return e(n,t),n}(s),Re=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,o=e.token,c=n.call(this)||this;return c.method=t.GET,c.path="".concat(a(r),"/").concat(encodeURIComponent(i),"/polls/changelogs"),c.params=u({change_ts:s,token:o}),c}return e(r,n),r}(r),De=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedPolls=n.updated.map((function(t){return function(e,t){return t?new i(e,t):null}(e,t)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),Me={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Ue=function(e){return c("string",e.title)&&l(e.optionTexts)&&h(e.data)&&c("boolean",e.allowUserSuggestion,!0)&&c("boolean",e.allowMultipleVotes,!0)&&c("number",e.closeAt,!0)},qe={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Fe=function(e){return c("string",e.channelUrl)&&d(f,e.channelType)&&c("number",e.pollId)&&c("number",e.pollOptionId)},Be={channelUrl:null,channelType:null,pollId:null},Ke=function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&d(f,e.channelType)&&c("number",e.pollId)},je={},He=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=o,je[e]=this}return e.of=function(e){return je[e]},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return _(Ke(e)).throw(m.invalidParameters),t=new Ae(y({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(xe).poll]}}))}))},e.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return _(Ue(e)).throw(m.invalidParameters),t=e.data,n=new Oe(y(y({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(Ce).poll]}}))}))},e.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return _(Fe(e)).throw(m.invalidParameters),t=new Pe(y({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Le).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=b.SYNC_POLL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,s,o,a,c,l,h;return v(this,(function(d){switch(d.label){case 0:return i=new Re(u({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=d.sent(),o=s.as(De),a=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,a.length>0&&this._dispatcher.dispatch(new g({polls:a,source:r})),[2,{updatedPolls:a,deletedPollIds:c,hasMore:l,token:h}]}}))}))},e}(),ze=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},Ve=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Qe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.token,a=e.limit,u=r.call(this)||this;return u.method=t.GET,u.path=n,u.params={channel_url:i,channel_type:s,token:o,limit:a},u}return e(i,r),i}(r),Ge=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(t){return new i(e,t)})),s.token=n.next,s}return e(n,t),n}(s),We=function(t){function n(e,n){return t.call(this,e,n.channelUrl,n.channelType,n)||this}return e(n,t),n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new Qe(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ge),i=r.polls,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(w),Ye=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=e.token,c=e.limit,l=r.call(this)||this;return l.method=t.GET,l.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a),"/voters"),l.params={channel_url:i,channel_type:s,token:u,limit:c},l}return e(i,r),i}(r),Xe=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(t){return new E(e,t)})),i.token=n.next,i}return e(n,t),n}(s),Je=function(t){function n(e,n){var r=t.call(this,e,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("number",this.pollId)&&c("number",this.pollOptionId)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new Ye(y(y({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Xe),i=r.voters,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(w),Ze=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new He(e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c})},n.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},Me),e),_(Ue(t)).throw(m.invalidParameters),[2,this._manager.create(t)]}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},Be),e),_(Ke(t)).throw(m.invalidParameters),[2,this._manager.get(t)]}))}))},n.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},qe),e),_(Fe(t)).throw(m.invalidParameters),[2,this._manager.getOption(t)]}))}))},n}(k),$e={profileImage:null,profileUrl:null,nickname:null},et=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=T,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=T,this.onSessionRefreshed=T,this.onSessionClosed=T})),tt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=T,this.onReconnectStarted=T,this.onReconnectSucceeded=T,this.onReconnectFailed=T,this.onDisconnected=T})),nt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=T,this.onTotalUnreadMessageCountUpdated=T})),rt=100,it="GroupChannel",st=100,ot=10,at=20;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Ne||(Ne={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Te||(Te={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(Se||(Se={}));var ut,ct=function(e){switch(e){case Ne.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case Ne.CHRONOLOGICAL:return["-createdAt","syncIndex"];case Ne.CHANNEL_NAME_ALPHABETICAL:return["name"]}},lt=function(){function e(){this.messageTypeFilter=S.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=A.NONE}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){switch(this.messageTypeFilter){case S.USER:if(e.messageType!==O.USER)return!1;break;case S.FILE:if(e.messageType!==O.FILE)return!1;break;case S.ADMIN:if(e.messageType!==O.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof C))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case A.NONE:if(e.parentMessageId>0)return!1;break;case A.ONLY_REPLY_TO_CHANNEL:if(e instanceof C&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ut||(ut={}));var ht=function(e){switch(e){case ut.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ut.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},dt="undefined"!=typeof document&&"undefined"!=typeof navigator;dt&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var ft=dt&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");dt&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),dt&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),dt&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var pt,vt,_t=dt&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),mt=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)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(pt||(pt={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(vt||(vt={}));var yt,gt={},bt=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=pt.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],gt[e]&&!t.forceCreate||(this.nodeId=mt(),this.key=e,dt&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case vt.NEWNODE:n._sendSync();break;case vt.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case vt.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:vt.REQUEST_LOCK,ts:e.ts})};try{for(var p=x(d),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case vt.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case vt.REQUEST_LOCK:n._requestLock(i);break;case vt.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case vt.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(vt.REMOVENODE)}))),gt[e]=this),gt[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==pt.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:mt(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return dt&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(vt.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-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(vt.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(vt.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 p(this,void 0,void 0,(function(){var e=this;return v(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=pt.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(vt.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(vt.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(vt.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}(),wt=y(y({},de),{scheduledAt:null}),It=function(e){return pe(e)&&c("number",e.scheduledAt,!0)},Et=y(y({},ve),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),kt=function(e){return me(e)&&c("number",e.scheduledAt)&&(N(e.file)||c("string",e.fileUrl))&&c("string",e.fileName,!0)&&c("string",e.mimeType,!0)&&c("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return c("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Nt={},Tt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._sdkState=r,s._cacheContext=i,Nt[e]=s,s._mutex=new bt("unsendmessagecache.lock"),s}return e(n,t),n.of=function(e){return Nt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw m.invalidParameters;var t,n=y({},e.serialize());return e instanceof P?(e.messageParams&&(n.messageParams=fe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,y(y({},fe(t)),{scheduledAt:t.scheduledAt})))):e instanceof L&&(e.messageParams&&(n.messageParams=_e(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return y(y({},_e(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},n.prototype._deserialize=function(e){return e?(e=y(y({},e),{messageId:parseInt(e.messageId)}),R.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype._deserializeWithMessageCreateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=R.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof P?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof L?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&ye(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=a.sent(),a.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),a.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof P?(s=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(s,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof L?(s=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof s.fileKey&&ye(s.fileType)?(o=s,[4,this.collection.getBlob(s.fileKey)]):[3,7]:[3,8];case 6:o.file=a.sent(),a.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(s,n),a.label=8;case 8:return[2,n]}}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,i=void 0===r?new lt:r,s=e.order,o=void 0===s?ut.CHANNEL_LATEST:s,a=e.sendingStatus,u=void 0===a?null:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return p(this,void 0,void 0,(function(){var e,t,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=ht(o),t={"/where":function(e){return!!(o!==ut.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&i.match(a._deserialize(e))}},n&&(t.channelUrl=n),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new lt),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:ut.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return e instanceof L?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=x(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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]}}))}))},n.prototype.saveBlob=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return e instanceof L?e.messageParams&&(t=e.messageParams).file&&be(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=ge.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&be(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=ge.BLOB,i.label=4;case 4:return[2]}}))}))},n}(D),St=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return p(void 0,void 0,void 0,(function(){return v(this,(function(t){return[2,e.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[ct(Ne.LATEST_LAST_MESSAGE),ct(Ne.CHRONOLOGICAL),ct(Ne.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:"Message",keyName:"messageId",index:[ht(ut.CHANNEL_LATEST),ht(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"UnsentMessage",keyName:"reqId",index:[ht(ut.CHANNEL_LATEST),ht(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},Ot={},Ct=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=t.call(this,e)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,Ot[e]=o,o}return e(n,t),n.of=function(e){return Ot[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return y(y({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=y(y({},e),{messageId:parseInt(e.messageId)}),R.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,o=void 0===s?new lt:s,a=e.order,u=void 0===a?ut.CHANNEL_LATEST:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h,f=e.isPollOnly,_=void 0!==f&&f;return p(this,void 0,void 0,(function(){var e,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=ht(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case ut.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=x(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:ht(ut.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:ht(ut.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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]}}))}))},n.prototype.countBetween=function(e,t,n){return p(this,void 0,void 0,(function(){var r,i=this;return v(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=ht(ut.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return e instanceof L&&e.messageParams&&((t=e.messageParams).file&&be(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(D),At=function(t){function n(){var e=t.call(this)||this;return e._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(e),e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},n}(M),xt=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:t.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Pt=function(t){function n(e){var n=e.message,r=t.call(this)||this;return r.message=n,r}return e(n,t),n}(U),Lt={},Rt=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;Lt[e]=this,this._iid=e,Lt[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof B)switch(e.stateType){case K.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case K.DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return Lt[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=x(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=q.FAILED,r.errorCode=j.ACK_TIMEOUT,this._dispatcher.dispatch(new H({messages:[r],source:b.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=u.sent();try{for(t=x(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&F(r.errorCode)&&(i=(new Date).getTime(),s=r.createdAt+2592e5,i<=s?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(r.reqId)<0&&this._autoResendQueue.push(r):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(s).toLocaleString()),r.sendingStatus=q.FAILED,this._dispatcher.dispatch(new H({messages:[r],source:b.LOCAL_MESSAGE_FAILED}))))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===q.SUCCEEDED||e.sendingStatus===q.FAILED&&!F(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return(e=Tt.of(this._iid))?[4,e.fetch({sendingStatus:q.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new Pt({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(yt||(yt={}));var Dt=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,i=n.blockee;return{blocker:new E(e,r),blockee:new E(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new E(e,t)})):[]}},e}(),Mt=function(t){function n(e,n){var r=n.userId,i=t.call(this)||this;return i._iid=e,i.userId=r,i}return e(n,t),n}(U),Ut=function(t){function n(e,n,r){var i=t.call(this,e,"USEV",r)||this;return i.event=new Dt(r),i}return e(n,t),n}(z),qt=function(n){function r(e){var r=e.userId,i=e.nickname,s=void 0===i?null:i,o=e.profileUrl,a=void 0===o?null:o,c=e.profileImage,l=void 0===c?null:c,h=e.preferredLanguages,d=void 0===h?null:h,f=n.call(this)||this;return f.method=t.PUT,f.path="".concat(V,"/").concat(encodeURIComponent(r)),f.params=u({nickname:s,profile_url:a,profile_file:l,preferred_languages:d}),f}return e(r,n),r}(r),Ft=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new E(e,y({},n)),r}return e(n,t),n}(s),Bt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),s.params={apns_device_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var Kt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),s.params={gcm_reg_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var jt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new E(e,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}e(n,t)}(s);var Ht=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new E(e,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}e(n,t)}(s);var zt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}e(n,t)}(s);var Vt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}e(n,t)}(s);var Qt=function(n){function r(e){var r=e.userId,i=e.type,s=e.token,o=e.ts,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:o,token:s},a}return e(r,n),r}(r),Gt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(s),Wt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),i}return e(r,n),r}(r),Yt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Xt=function(n){function r(e){var r=e.userId,i=e.willAutoAccept,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),s.params={auto_accept:i},s}return e(r,n),r}(r),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Zt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),$t=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),en=function(n){function r(e){var r=e.userId,i=e.doNotDisturbOn,s=e.startHour,o=e.startMin,a=e.endHour,u=e.endMin,c=e.timezone,l=n.call(this)||this;return l.method=t.PUT,l.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),l.params={do_not_disturb:i,start_hour:s,start_min:o,end_hour:a,end_min:u,timezone:c},l}return e(r,n),r}(r),tn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),nn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),sn=function(n){function r(e){var r=e.userId,i=e.snoozeOn,s=e.startTs,o=e.endTs,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:o},a}return e(r,n),r}(r),on=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),an=function(n){function r(e){var r=e.userId,i=e.blockedUserId,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block"),s.params={target_id:i},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new E(e,n),r}e(n,t)}(s);var un=function(n){function r(e){var r=e.userId,i=e.unblockedUserId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var cn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),hn=function(n){function r(e){var r=e.userId,i=e.pushTriggerOption,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),s.params={push_trigger_option:i},s}return e(r,n),r}(r),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),fn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),i}return e(r,n),r}(r),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),vn=function(n){function r(e){var r=e.userId,i=e.templateName,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),s.params={name:i},s}return e(r,n),r}(r),_n=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),mn=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends/changelogs"),s.params={token:i},s}return e(r,n),r}(r),yn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new E(e,t)})),updatedUsers:n.updated.map((function(t){return new E(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(s),gn=function(n){function r(e){var r=e.userId,i=e.discoveries,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},s}return e(r,n),r}(r),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(s),wn=function(n){function r(e){var r=e.userId,i=e.discoveryKeys,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discovery_keys:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var In=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r),En=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r}return e(n,t),n}(s),kn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var Nn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),i.params={},i}return e(r,n),r}(r),Tn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(s),Sn=function(n){function r(e){var r=e.userId,i=e.allowFriendDiscovery,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),s.params={allow_friend_discovery:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var On,Cn=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},An=function(e){var t,n,r;this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(t=e.id)&&void 0!==t?t:0,this.name=null!==(n=e.name)&&void 0!==n?n:"",this.url=null!==(r=e.url)&&void 0!==r?r:"",this.emojis=e.emojis?e.emojis.map((function(e){return new Cn(e)})):[]},xn=function(e){this.emojiHash=null,this.emojiCategories=[],this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new An(e)})):[]},Pn=function(n){function r(){var e=n.call(this)||this;return e.method=t.GET,e.path=Q,e}return e(r,n),r}(r),Ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new xn(n),r}return e(n,t),n}(s),Rn=function(n){function r(e){var r=e.categoryId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(Q,"/").concat(r),i}return e(r,n),r}(r),Dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new An(n),r}return e(n,t),n}(s),Mn=function(n){function r(e){var r=e.key,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(r),i}return e(r,n),r}(r),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new Cn(n),r}return e(n,t),n}(s),qn=function(n){function r(e){var r=e.limit,i=e.token,s=e.userIdsFilter,o=e.metaDataKeyFilter,a=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=V,l.params=u({limit:r,token:i,user_ids:s,metadatakey:o,metadatavalues_in:a,nickname_startswith:c}),l}return e(r,n),r}(r),Fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Bn=function(t){function n(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)&&c("string",this.metaDataKeyFilter,!0)&&W("string",this.metaDataValuesFilter,!0)&&c("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new qn(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Fn),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),Kn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=e.userIdsFilter,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(r,"/block"),a.params=u({limit:i,token:s,user_ids:o}),a}return e(r,n),r}(r),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Hn=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Kn(y(y({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(jn),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),zn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),o.params={limit:i,token:s},o}return e(r,n),r}(r),Vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Qn=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zn(y(y({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Vn),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),Gn={},Wn=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,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,v=void 0!==p&&p;return Gn[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Gn[t]=this),Gn[t]}return e.get=function(e){return Gn[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"}(On||(On={}));var Yn,Xn=function(t){function n(e){var r=e.code,i=void 0===r?On.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:On.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:On.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:On.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:On.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:On.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:On.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:On.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:On.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:On.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:On.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:On.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:On.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:On.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:On.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:On.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:On.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:On.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:On.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:On.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:On.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:On.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:On.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:On.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:On.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Yn||(Yn={}));var Jn,Zn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Xn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return Zn(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]=Zn(e[r],t);return t.delete(e),n}return e},$n=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Xn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},er=function(e,t){for(var n=0,r=0;r>>0)%t},tr=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},nr=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!nr(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!nr(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((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!($n(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!($n(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!($n(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!($n(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))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)},rr=function(){},ir=function(){return Promise.resolve()},sr=function(e){return e},or=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Jn||(Jn={}));var ar,ur,cr,lr=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,o=e.map,a=void 0===o?sr:o,u=e.backward,c=void 0===u?ir:u,l=e.forward,h=void 0===l?ir:l,d=e.complete,f=void 0===d?rr:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(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}(),hr=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}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],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*$n(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*$n(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i-1){var r=this._items[n];return t===cr.PERSISTENT&&(r.state=ur.PERSISTENT),t!==cr.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)gr.includes(this._items[r].state)&&gr.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===ur.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=x(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===ur.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},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!==ur.VOLATILE}))},e}(),Ir=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(pr(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(pr(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,X([],J(e),!1)),[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=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return v(this,(function(h){switch(h.label){case 0:n=wr.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return y(y({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=wr.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=Er.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return n=Wn.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,wr.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?Er.createFromCacheItem(s):new Er({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=_r(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),wr.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),Nr={},Tr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[];var u=function(e,t,n){return"".concat(pr(e,t),"/index.").concat(n)}(t,n,i.join(">"));return Nr[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=o,this._transaction.on(ar.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(ar.ERROR,this.indexerKey,(function(){return a.abort()}))),Nr[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in Nr)delete Nr[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=J(this.indexOf(n),2),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=J(this.indexOf(n),2),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){var t,n,r,i,s=[];try{for(var o=x(this.fields),a=o.next();!a.done;a=o.next()){var u=a.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Xn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=$n(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,f,p,_,m;return v(this,(function(v){switch(v.label){case 0:return[4,(e=wr.get(this.dbname)).find(this._store,this.indexerKey,cr.PERSISTENT)];case 1:return(t=v.sent())?[3,11]:(n=_r(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=v.sent(),v.label=3;case 3:v.trys.push([3,8,9,10]),i=x(r),s=i.next(),v.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,cr.NO_CACHE)]:[3,6];case 5:a=v.sent(),u=Er.createFromCacheItem(a);try{for(_=void 0,c=x(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}v.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=v.sent(),f={error:d},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Zn(this._origin),v.label=12;case 12:return Nr[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return wr.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete Nr[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=Zn(this._origin)},e.prototype.abort=function(){this._table=Zn(this._origin)},e}(),Sr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=Yn.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=X([[r]],J(s.filter((function(e){return Tr.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new bt(function(e,t){return"".concat(pr(e,t),".lock")}(t,n)),this._blobContainer=new yr({dbname:t,collectionName:n,store:o}),this._transaction=new Ir({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return p(this,void 0,void 0,(function(){var r;return v(this,(function(i){switch(i.label){case 0:return r=vr(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}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Yn.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,p,_=this;return v(this,(function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=Wn.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.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:v.sent(),this._blockManager=new kr({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=X([],J(this.indexes),!1),i=[],s=r.map((function(e){return Tr.createKey(e)})),o=n?n.indexes.map((function(e){return Tr.createKey(e)})):[];try{for(a=x(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(Tr.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(p=a.return)&&p.call(a)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,X([],J(r.map((function(e){var t=new Tr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,X([],J(i.map((function(e){return new Tr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=vr(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:v.sent(),v.label=8;case 8:return this._state=Yn.READY,this._mutex.unlock(),[3,10];case 9:throw d=v.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Yn.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=Tr.createKey(e);try{for(var i=x(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===Tr.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return e=vr(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=x(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Xn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f;return v(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=x(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),o=x(this._indexers),a=o.next(),p.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=x(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=x(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=x(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,Zn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Xn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new dr({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Xn.collectionKeyNotGiven;return[4,this._requestInsert(Zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Xn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Xn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=x(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Zn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Xn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Xn.collectionKeyNotGiven;return[4,this._requestUpsert(Zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Xn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Xn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=x(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Zn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Xn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Xn.collectionKeyNotGiven;return[4,this._requestUpdate(Zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Xn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,h,d,f,_,m,y=this;return v(this,(function(g){switch(g.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new hr({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return p(y,void 0,void 0,(function(){var n,i;return v(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,nr(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:g.sent(),g.label=4;case 4:g.trys.push([4,9,10,11]),c=x(u),l=c.next(),g.label=5;case 5:return l.done?[3,8]:(h=l.value,[4,this._requestUpdate(Zn(h))]);case 6:g.sent(),g.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return d=g.sent(),_={error:d},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return g.sent(),this._mutex.unlock(),[2,u];case 13:return f=g.sent(),[4,this._transaction.clear()];case 14:throw g.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Xn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Xn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,_,m=this;return v(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,o=void 0!==s&&s,a=[],[4,new hr({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return p(m,void 0,void 0,(function(){var t,r;return v(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,nr(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=x(a),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return h=y.sent(),f={error:h},[3,11];case 10:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw d=y.sent(),this._mutex.unlock(),d;case 14:return[3,16];case 15:throw this._transaction.clear(),Xn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Xn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Or=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:Z,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),X([],J(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=c.sent(),c.label=2;case 2:c.trys.push([2,7,8,9]),n=x(t),r=n.next(),c.label=3;case 3:return r.done?[3,6]:(i=r.value,[4,this._getRaw(i)]);case 4:(s=c.sent())&&(e+=JSON.stringify(s).length),c.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return o=c.sent(),a={error:o},[3,9];case 8:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(a)throw a.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a=this;return v(this,(function(u){switch(u.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=u.sent()))return[3,7];u.label=2;case 2:return u.trys.push([2,6,,7]),r=n.data,(null==(i=n.metadata)?void 0:i.shards)>1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return p(a,void 0,void 0,(function(){var n,i;return v(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw Xn.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return o=u.sent(),[3,5];case 4:o=[r],u.label=5;case 5:return s=o,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,y({},e.value)]}}))}))},e.prototype.setMany=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._setRaw([].concat.apply([],X([],J(e.map((function(e){return t._shardify(e)}))),!1)))];case 1:return n.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i=this;return v(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l=this;return v(this,(function(h){switch(h.label){case 0:t=[],n=function(e){var n,i,s;return v(this,(function(o){switch(o.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=o.sent())&&(s=i.metadata,t.push.apply(t,X([],J(r._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return l._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,h.label=1;case 1:h.trys.push([1,6,7,8]),i=x(e),s=i.next(),h.label=2;case 2:return s.done?[3,5]:(o=s.value,[5,n(o)]);case 3:h.sent(),h.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return a=h.sent(),u={error:a},[3,8];case 7:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e}(),Cr={},Ar=function(t){function n(e){void 0===e&&(e={});var n,r=this;r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=e.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return e(n,t),Object.defineProperty(n.prototype,"rawData",{get:function(){return Cr[this.dbname]},set:function(e){Cr[this.dbname]=e},enumerable:!1,configurable:!0}),n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){if(Cr[this.dbname])return[2,Object.keys(Cr[this.dbname])];throw Xn.storeNotAvailable}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return Cr[this.dbname]?[4,tr(this.delay)]:[3,2];case 1:return t.sent(),[2,Cr[this.dbname][e]?y({key:e},Cr[this.dbname][e]):null];case 2:throw Xn.storeNotAvailable}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return Cr[this.dbname]?[4,tr(this.delay)]:[3,2];case 1:c.sent();try{for(t=x(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,o=r.metadata,Cr[this.dbname][i]=Object.freeze({data:s,metadata:o})}catch(e){a={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw Xn.storeNotAvailable;case 3:return[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return Cr[this.dbname]?[4,tr(this.delay)]:[3,2];case 1:o.sent();try{for(t=x(e),n=t.next();!n.done;n=t.next())r=n.value,Cr[this.dbname][r]&&delete Cr[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw Xn.storeNotAvailable;case 3:return[2]}}))}))},n.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!0]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,Cr[this.dbname]={},[2]}))}))},n.prototype.set=function(e){return p(this,void 0,void 0,(function(){var n;return v(this,(function(r){if(this.observer[e.key]&&"function"==typeof this.observer[e.key].set&&(n=this.observer[e.key].set()))throw n;return[2,t.prototype.set.call(this,e)]}))}))},n.prototype.setMany=function(e){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a;return v(this,(function(u){try{for(n=x(e),r=n.next();!r.done;r=n.next())if(i=r.value,this.observer[i.key]&&"function"==typeof this.observer[i.key].set&&(s=this.observer[i.key].set()))throw s}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[2,t.prototype.setMany.call(this,e)]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,tr(this.delay)];case 1:return e.sent(),Cr[this.dbname]={},[2]}}))}))},n}(Or),xr=function(t){function n(e){void 0===e&&(e={});var n,r=this;return(r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName="NestDBStore",r._window="undefined"!=typeof window?window:null,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:null,r}return e(n,t),n.prototype._getObjectStore=function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i=this;return v(this,(function(s){switch(s.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,t="undefined"!=typeof document&&"undefined"!=typeof navigator,n=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),r=navigator.userAgent&&navigator.userAgent.includes("Edge/"),[4,new Promise((function(s,o){if(t)if(n){var a=i._indexedDb.open("_testMozilla");a.onerror=function(){return o("Private browsing mode.")},a.onsuccess=function(){return s()}}else r?(e.PointerEvent||e.MSPointerEvent)&&o("Private browsing mode."):s()}))];case 2:return s.sent(),[2,!0];case 3:return s.sent(),[2,!1];case 4:return[2,!1]}}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){var t,n=this;return v(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,new Promise((function(e,t){if(n._window&&dt)if(ft){var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Xn.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}else _t?n._window.indexedDB||!n._window.PointerEvent&&!n._window.MSPointerEvent||t(Xn.storeNotAvailableInPrivateBrowsing):e();else t(Xn.storeNotAvailable)}))];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore("NestDBStore",{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return t._database=r.sent(),[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},n}(Or),Pr=function(t){function n(e){var n=this,r=e.AsyncStorage,i=e.itemSizeLimit,s=void 0===i?6291456:i,o=$(e,["AsyncStorage","itemSizeLimit"]);return(n=t.call(this,y(y({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e,t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:t=[];try{for(n=x(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!!this._asyncStorage]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,[2]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},n}(Or);!function(t){function n(e){var n,r=this;return(r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=e.MMKV,r}e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e,t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){try{for(t=x(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}}return[2]}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){try{for(t=x(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!!this._mmkv]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,[2]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(Or);var Lr,Rr=!0,Dr=function(){function e(){}return e.off=function(){Rr=!1},e.log=function(){for(var e=[],t=0;ta.ts){if(a.all!==t.all&&(u=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(u=!0),a.customTypes[l]=t.customTypes[l];u=u&&a.ts>0,a.ts=c}u&&ie((function(){return p(r,void 0,void 0,(function(){return v(this,(function(e){return[2,h.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof oe&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),ae.payloadify(t.userProfile))}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ue:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,v=t.logLevel,_=t.localCacheEnabled,m=void 0!==_&&_,y=t.localCacheEncryption,g=t.useAsyncStorageStore,b=void 0===g?null:g;if(!Ur||p){var w="su-".concat(ce()),E=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},k=new Ar({encryption:E});l||(k=b?new Pr({AsyncStorage:b,encryption:E}):new xr({encryption:E})),new I(w,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:k,encryption:E,logLevel:v,localCacheEnabled:m,debugMode:l});var N=[new le,new Ze],T=new e(w,u,X(X([],J(o),!1),J(N),!1));return Ur||(Ur=T),T}return Ur},Object.defineProperty(e,"instance",{get:function(){return Ur},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return ee},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return I.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appInfo",{get:function(){return I.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=I.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return I.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return I.of(this._iid).logger.level},set:function(e){I.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return I.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return I.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=I.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=I.of(this._iid).connectionManager;return e.isConnected?te.OPEN:e.isConnecting?te.CONNECTING:te.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=I.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},e.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},e.prototype.getMemoryStoreForDebugging=function(){var e=I.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ar?n.store:null;throw m.debugModeRequired},e.prototype.addExtension=function(e,t){var n=I.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},e.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},e.prototype.initializeCache=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=I.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,9]:[4,i.logout()];case 1:return c.sent(),n.userId=e,o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==Lr.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Mr({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",St(a,r.store)),[4,a.open()]):[3,4];case 2:c.sent(),s.dispatch(new Mt(this._iid,{userId:e})),c.label=3;case 3:return[3,6];case 4:return[4,r.store.init(o)];case 5:c.sent(),c.label=6;case 6:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 7:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 8:(u=c.sent())&&new ae(this._iid,u).apply(),c.label=9;case 9:return[2]}}))}))},e.prototype.clearCachedData=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return(e=I.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()];case 1:return t.sent(),[2]}}))}))},e.prototype.clearCachedMessages=function(e){return p(this,void 0,void 0,(function(){var t,n,r=this;return v(this,(function(i){switch(i.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=Ct.of(this._iid),n=Tt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return p(r,void 0,void 0,(function(){return v(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:_(c("string",e)&&c("string",t,!0)).throw(m.invalidParameters),n=I.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return u.sent(),[3,4];case 3:return u.sent(),a=I.of(this._iid).logger,i.localCacheEnabled=!1,a.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return u.sent(),this._onlineDetector.start(),this._appStateChangeDetector.start(),[4,s.connect(t)];case 6:return u.sent(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},e.prototype.disconnect=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=I.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},e.prototype.setBackgroundState=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},e.prototype.setForegroundState=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},e.prototype.setSessionHandler=function(e){_(e instanceof et).throw(m.invalidParameters),I.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){_(c("string",e)&&t instanceof nt).throw(m.invalidParameters),I.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){I.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){I.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){_(c("string",e)&&t instanceof tt).throw(m.invalidParameters),I.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){I.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){I.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Bn(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Hn(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Qn(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new ne(this._iid,e)},e.prototype.createPollListQuery=function(e){return new We(this._iid,y({},e))},e.prototype.createPollVoterListQuery=function(e){return new Je(this._iid,y({},e))},e.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new E(this._iid,E.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return t=y(y({},$e),e),_(function(e){return N(e.profileImage,!0)&&c("string",e.profileUrl,!0)&&c("string",e.nickname,!0)}(t)).throw(m.invalidParameters),this.currentUser?(n=I.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qt(y({userId:r.userId},t)),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(Ft).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=a.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=a.profileUrl)),[2,a];case 2:throw m.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return _(W("string",e)).throw(m.invalidParameters),this.currentUser?(t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new qt({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ft).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw m.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o=this;return v(this,(function(a){switch(a.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,6];a.label=1;case 1:return a.trys.push([1,4,,5]),t=I.of(this._iid),n=t.sessionManager,r=t.sdkState,i=t.requestQueue,n.hasDeviceToken(Ee.FCM,e)?[2,we.SUCCESS]:(s=new Kt({userId:r.userId,token:e}),[4,i.send(s)]);case 2:return a.sent(),[4,he((function(){return p(o,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return n.setDeviceToken(Ee.FCM,e),[4,n.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return a.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 4:return a.sent(),[2,we.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,we.PENDING];case 7:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a=this;return v(this,(function(u){switch(u.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,6];u.label=1;case 1:return u.trys.push([1,4,,5]),t=I.of(this._iid),n=t.sessionManager,r=t.sdkState,i=t.requestQueue,s=new Ht({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o=u.sent().lastDeletedAt,[4,he((function(){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return n.unsetDeviceToken(Ee.FCM,e),n.setDeviceTokenDeletedAt(o),[4,n.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return u.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 4:return u.sent(),[2,we.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,we.PENDING];case 7:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o=this;return v(this,(function(a){switch(a.label){case 0:return this.currentUser?(e=I.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new Vt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=a.sent().lastDeletedAt,[4,he((function(){return p(o,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(Ee.FCM),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o=this;return v(this,(function(a){switch(a.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,6];a.label=1;case 1:return a.trys.push([1,4,,5]),t=I.of(this._iid),n=t.sessionManager,r=t.sdkState,i=t.requestQueue,n.hasDeviceToken(Ee.APNS,e)?[2,we.SUCCESS]:(s=new Bt({userId:r.userId,token:e}),[4,i.send(s)]);case 2:return a.sent(),[4,he((function(){return p(o,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return n.setDeviceToken(Ee.APNS,e),[4,n.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return a.sent(),this._apnsPushToken="",[2,we.SUCCESS];case 4:return a.sent(),[2,we.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,we.PENDING];case 7:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a=this;return v(this,(function(u){switch(u.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,6];u.label=1;case 1:return u.trys.push([1,4,,5]),t=I.of(this._iid),n=t.sessionManager,r=t.sdkState,i=t.requestQueue,s=new jt({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o=u.sent().lastDeletedAt,[4,he((function(){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return n.unsetDeviceToken(Ee.APNS,e),n.setDeviceTokenDeletedAt(o),[4,n.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return u.sent(),this._apnsPushToken="",[2,we.SUCCESS];case 4:return u.sent(),[2,we.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,we.PENDING];case 7:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o=this;return v(this,(function(a){switch(a.label){case 0:return this.currentUser?(e=I.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new zt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=a.sent().lastDeletedAt,[4,he((function(){return p(o,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(Ee.APNS),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Wt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Yt).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(c("boolean",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,{autoAccept:s.as(Jt).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as($t).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,n,r,i,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=""),p(this,void 0,void 0,(function(){var o,a,u,l,h;return v(this,(function(d){switch(d.label){case 0:return _(c("boolean",e)&&c("number",t)&&c("number",n)&&c("number",r)&&c("number",i)&&c("string",s)).throw(m.invalidParameters),o=I.of(this._iid),a=o.sdkState,u=o.requestQueue,l=new en({userId:a.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s}),[4,u.send(l)];case 1:return h=d.sent(),[2,h.as(tn).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new nn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(rn).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return _(c("boolean",e)&&c("number",t)&&c("number",n)).throw(m.invalidParameters),r=I.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new sn({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(on).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,l,h,f,p,y;return v(this,(function(v){switch(v.label){case 0:return _(c("string",e)&&d(Ee,t)).throw(m.invalidParameters),n=I.of(this._iid),r=n.sdkState,i=n.requestQueue,s=n.sessionManager,o=new Qt({userId:r.userId,type:t,token:e}),[4,i.send(o)];case 1:a=v.sent(),u=a.as(Gt).pushTokens;try{for(l=x(u.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,s.setDeviceToken(u.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(y=l.return)&&y.call(l)}finally{if(p)throw p.error}}return[4,s.saveDeviceToken()];case 2:return v.sent(),[2,u]}}))}))},e.prototype.getPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new cn({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ln).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(d(Ie,e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new hn({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(dn).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new fn({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(pn).name]}}))}))},e.prototype.setPushTemplate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(d(ke,e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vn({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(_n).name]}}))}))},e.prototype.blockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(e instanceof E||c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,blockedUserId:e instanceof E?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(e instanceof E||c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new un({userId:n.userId,unblockedUserId:e instanceof E?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new mn({userId:n.userId,token:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(yn).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Tn).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(c("boolean",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Sn({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new gn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(bn).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new wn({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new In({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(En).users]}}))}))},e.prototype.deleteFriend=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new kn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=I.of(this._iid).requestQueue,t=new Pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Ln).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=I.of(this._iid).requestQueue,n=new Rn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Dn).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=I.of(this._iid).requestQueue,n=new Mn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Un).emoji]}}))}))},e}();export{Pt as A,Hn as B,tt as C,rt as D,Cn as E,Qn as F,Ne as G,ke as H,we as I,Ee as J,et as K,nt as L,Ct as M,it as N,ze as P,wt as S,Tt as U,Mt as a,Ve as b,Ut as c,yt as d,Dt as e,st as f,ct as g,He as h,lt as i,Rt as j,Et as k,kt as l,We as m,Je as n,Ie as o,ot as p,at as q,Te as r,Se as s,Ze as t,qr as u,It as v,Bn as w,An as x,xn as y,Ar as z}; diff --git a/__bundle-43418632.js b/__bundle-c20e72f4.js similarity index 97% rename from __bundle-43418632.js rename to __bundle-c20e72f4.js index 5606c6b..5a57862 100644 --- a/__bundle-43418632.js +++ b/__bundle-c20e72f4.js @@ -1 +1 @@ -import{C as e,_ as n,W as t,U as a,a_ as s,V as N,ao as E,ap as o,aq as r,a$ as i,r as _}from"./__bundle-2a729281.js";var u;!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(u||(u={}));var C=function(){function n(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(n.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),n}(),l=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new C(a),s}return n(t,e),t}(t),d=function(e){function t(n,t,s){var N=e.call(this,n,t,s)||this,E=s.data.operators,o=void 0===E?[]:E;return N.operators=o.map((function(e){return new a(N._iid,e)})),N}return n(t,e),t}(l),A=function(e){function t(n,t,a){var s=e.call(this,n,"MCNT",a)||this;return s.groupChannelMemberCounts=a.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=a.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return n(t,e),t}(t),h=function(e){function t(n,t,a){var o,r,i,_=this;(_=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var u=N.of(n).sdkState;return _.isMentioned=E(_.message.mentionType,null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(r=_.message.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),u.userId),_.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,_}return n(t,e),t}(t),c=function(e){function t(n,t,a){var E,r,i,_,u,C,l=this;(l=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=N.of(n).sdkState;return l.mentionCountChange=o({mentionType:null!==(r=null===(E=a.old_values)||void 0===E?void 0:E.mention_type)&&void 0!==r?r:null,mentionedUserIds:null!==(_=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==_?_:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(C=l.message.mentionedUsers)||void 0===C?void 0:C.map((function(e){return e.userId}))},d.userId),l}return n(t,e),t}(t),H=function(e){function t(n,t,a){var s=e.call(this,n,"MRCT",a)||this;return s.channelUrl=a.channel_url,s.channelType=a.channel_type,s.event=new r(a),s}return n(t,e),t}(t),T=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new i(n,a),s}return n(t,e),t}(t),U=function(){this.onUserMuted=_,this.onUserUnmuted=_,this.onUserBanned=_,this.onUserUnbanned=_,this.onChannelChanged=_,this.onChannelDeleted=_,this.onChannelFrozen=_,this.onChannelUnfrozen=_,this.onOperatorUpdated=_,this.onChannelMemberCountChanged=_,this.onMetaDataCreated=_,this.onMetaDataUpdated=_,this.onMetaDataDeleted=_,this.onMetaCounterCreated=_,this.onMetaCounterUpdated=_,this.onMetaCounterDeleted=_,this.onMessageReceived=_,this.onMessageUpdated=_,this.onMessageDeleted=_,this.onMentionReceived=_,this.onReactionUpdated=_,this.onThreadInfoUpdated=_};export{h as A,U as B,l as C,A as M,d as O,H as R,T,c as U,u as a}; +import{C as e,_ as n,W as t,U as a,aZ as s,V as N,ao as E,ap as o,aq as r,a_ as i,r as _}from"./__bundle-7175498d.js";var u;!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(u||(u={}));var C=function(){function n(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(n.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),n}(),l=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new C(a),s}return n(t,e),t}(t),d=function(e){function t(n,t,s){var N=e.call(this,n,t,s)||this,E=s.data.operators,o=void 0===E?[]:E;return N.operators=o.map((function(e){return new a(N._iid,e)})),N}return n(t,e),t}(l),A=function(e){function t(n,t,a){var s=e.call(this,n,"MCNT",a)||this;return s.groupChannelMemberCounts=a.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=a.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return n(t,e),t}(t),h=function(e){function t(n,t,a){var o,r,i,_=this;(_=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var u=N.of(n).sdkState;return _.isMentioned=E(_.message.mentionType,null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(r=_.message.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),u.userId),_.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,_}return n(t,e),t}(t),c=function(e){function t(n,t,a){var E,r,i,_,u,C,l=this;(l=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=N.of(n).sdkState;return l.mentionCountChange=o({mentionType:null!==(r=null===(E=a.old_values)||void 0===E?void 0:E.mention_type)&&void 0!==r?r:null,mentionedUserIds:null!==(_=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==_?_:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(C=l.message.mentionedUsers)||void 0===C?void 0:C.map((function(e){return e.userId}))},d.userId),l}return n(t,e),t}(t),H=function(e){function t(n,t,a){var s=e.call(this,n,"MRCT",a)||this;return s.channelUrl=a.channel_url,s.channelType=a.channel_type,s.event=new r(a),s}return n(t,e),t}(t),T=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new i(n,a),s}return n(t,e),t}(t),U=function(){this.onUserMuted=_,this.onUserUnmuted=_,this.onUserBanned=_,this.onUserUnbanned=_,this.onChannelChanged=_,this.onChannelDeleted=_,this.onChannelFrozen=_,this.onChannelUnfrozen=_,this.onOperatorUpdated=_,this.onChannelMemberCountChanged=_,this.onMetaDataCreated=_,this.onMetaDataUpdated=_,this.onMetaDataDeleted=_,this.onMetaCounterCreated=_,this.onMetaCounterUpdated=_,this.onMetaCounterDeleted=_,this.onMessageReceived=_,this.onMessageUpdated=_,this.onMessageDeleted=_,this.onMentionReceived=_,this.onReactionUpdated=_,this.onThreadInfoUpdated=_};export{h as A,U as B,l as C,A as M,d as O,H as R,T,c as U,u as a}; diff --git a/__bundle-a9c3db53.js b/__bundle-d8d501e8.js similarity index 99% rename from __bundle-a9c3db53.js rename to __bundle-d8d501e8.js index 26eefa9..0621a6a 100644 --- a/__bundle-a9c3db53.js +++ b/__bundle-d8d501e8.js @@ -1 +1 @@ -import{ah as e,i as t,h as n,T as r,U as i,ai as a,aj as s,ak as o,l as u,e as c,q as l,_ as d,A as h,g as p,b as f,c as m,j as v,k as y,n as g,S as _,V as T,W as U,al as I,am as w,C as M,an as E,x as S,ao as b,ap as C,F as P,aq as A,ar as D,as as R,ab as q,at as k,au as O,av as N,D as L,z as F,t as Q,K as z,u as x,aw as G,L as B,M as j,a6 as V,ax as W,G as K,y as Y,ay as H,I as J,Y as Z,Z as X,az as $,aA as ee,aB as te,aC as ne,aD as re,aE as ie,w as ae}from"./__bundle-2a729281.js";var se,oe={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},ue=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&t("number",u.parentMessageId,!0)&&t("boolean",u.isReplyToChannel)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)&&t("boolean",u.isPinnedMessage,!0)},ce=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},le=u(u({},oe),{message:null,translationTargetLanguages:null,pollId:null}),de=function(e){return ue(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(se||(se={}));var he,pe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},fe=function(e){return e===se.BLOB||e===se.FILE},me=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ve=u(u({},oe),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),ye=function(e){return ue(e)&&(l(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(he||(he={}));var ge,_e=function(){function e(e){var t,r,i;this.restrictionType=null,this.description=null,this.endAt=-1,n(he,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1}return e.payloadify=function(e){return e?c({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},e}(),Te=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new _e(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),_e.payloadify(t.restrictionInfo))):null},t}(i),Ue={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Ie=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},we=u(u({},Ue),{message:null,translationTargetLanguages:null,pollId:null}),Me=function(e){return Ie(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},Ee=u({},Ue),Se=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return d(t,e),t}(f),be=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Ce=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Se(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=o.sent(),i=r.as(be),a=i.operators,s=i.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),Pe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return d(t,e),t}(f),Ae=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.mutedUsers=[];var i=n.next,a=n.muted_list;return r.token=i,a&&a.length>0&&(r.mutedUsers=a.map((function(e){return new Te(t,e)}))),r}return d(t,e),t}(m),De=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Pe(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Ae),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),Re=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({limit:a,token:s}),n}return d(t,e),t}(f),qe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var i=n.next,a=n.banned_list;return r.token=i,a&&a.length>0&&(r.bannedUsers=a.map((function(e){return new Te(t,e.user)}))),r}return d(t,e),t}(m),ke=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Re(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(qe),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(ge||(ge={}));var Oe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ne=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var Le=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return d(t,e),t}(f),Fe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),Qe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return d(t,e),t}(f),ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return d(t,e),t}(m),xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return d(t,e),t}(f),Ge=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return d(t,e),t}(m),Be=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),je=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return d(t,e),t}(m),Ve=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),We=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return d(t,e),t}(f),Ke=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return d(t,e),t}(m),Ye=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),He=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return d(t,e),t}(m),Je=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return d(t,e),t}(f),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return d(t,e),t}(f),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return d(t,e),t}(f),tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var st=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ut=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({user_id:a,seconds:s,description:o}),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.memberCount=null,i.joinedMemberCount=null,i.user=new Te(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return d(t,e),t}(U),dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ht=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return d(t,e),t}(U),mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),vt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(w,"/users/").concat(o),n.params={channel_url:r,channel_type:i===M.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),yt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),gt=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:c({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==s.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return d(n,t),n}(E),_t=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new S(t,r);var u=T.of(t).sdkState;return o.isMentioned=b(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(a=o.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(s=r.force_update_last_message)&&void 0!==s&&s,o}return d(t,e),t}(U),Tt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:c({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return d(n,t),n}(E),Ut=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new S(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),It=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:c({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return d(n,t),n}(E),wt=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new P(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),Mt=function(e){function t(t){var n=e.call(this)||this;return n.method=h.DELETE,n.path="".concat(p(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Et=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return d(t,e),t}(U),St=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(n),r}return d(t,e),t}(m),Ct=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(u({},n)),r}return d(t,e),t}(m),At=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return d(t,e),t}(f),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),Rt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),kt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return R.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new P(t,n),r}return d(t,e),t}(m),Nt=2,Lt=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=M.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c.url=r.channel_url,c.name=null!==(a=r.name)&&void 0!==a?a:"",c.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",c.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",c.data=null!==(u=r.data)&&void 0!==u?u:"",c.isFrozen=!!t("boolean",r.freeze)&&r.freeze,c.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,c.creator=r.created_by?new i(c._iid,r.created_by):null,c.createdAt=1e3*r.created_at,c._cachedMetaData=new Map,r.metadata&&r.ts&&Object.keys(r.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})})),c}return d(h,e),h.payloadify=function(t){return c(u(u({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:i.payloadify(t.creator),created_at:t.createdAt/1e3}))},h.prototype.isGroupChannel=function(){return this.channelType===M.GROUP},h.prototype.isOpenChannel=function(){return this.channelType===M.OPEN},Object.defineProperty(h.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),h.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},h.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(_.invalidParameters),n=T.of(this._iid).requestQueue,i=new At({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Dt).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();G(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var s=new Rt(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(qt).message;V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(W(r))throw r;G(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},h.prototype.sendFileMessage=function(e){var t=u(u({},ve),e);return x(ye(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=T.of(this._iid).dispatcher,i=Y.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new H;return a||(a=this._generateRequestId(),G(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new B({messages:[t],source:j.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new B({messages:[e],source:j.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(W(t))throw t;G(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=T.of(n._iid).cacheContext.localCacheEnabled&&K(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new B({messages:[i],source:i.sendingStatus===L.PENDING?j.REQUEST_RESEND_MESSAGE:j.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},h.prototype._autoResendFileMessage=function(e){x(e instanceof P).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},h.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,s=new kt(u(u({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(s).then((function(e){var n=e.as(Ot).message;V((function(){return v(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(W(a))throw a;G(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),V((function(){return v(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},h.prototype.sendFileMessages=function(e){var t,n;x(e.every((function(e){return ye(u(u({},ve),e))}))).throw(_.invalidParameters);var r=new H;try{for(var i=F(e),a=i.next();!a.done;a=i.next()){var s=a.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},h.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){return r=Boolean(e.url)||l(t)||l(null===(n=e.messageParams)||void 0===n?void 0:n.file),x(e instanceof P&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new re,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&l(t)&&(e.messageParams.file=t),e.messageParams):c({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},h.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return r=u(u({},Ee),n),x(t("number",e)&&function(e){return Ie(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new It(u({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(t("string",e)).throw(_.invalidParameters),Y.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r;return v(this,void 0,void 0,(function(){var i,a;return y(this,(function(o){return x(e instanceof h&&t instanceof P&&t.sendingStatus===L.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),i=new re,a=u(u({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:s.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(a).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},h.prototype.deleteMessage=function(e){return v(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return x(e instanceof ie).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Mt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},h.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return x(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(bt).reactionEvent]}}))}))},h.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return x(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Pt).reactionEvent]}}))}))},h.prototype._updateMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(Ut).message,a.dispatch(new B({messages:[c],source:j.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return x(e instanceof ie&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},h.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return x(e instanceof ie&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},h.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(e instanceof ie&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},h.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(e instanceof ie&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},h.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return x(n(ge,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new mt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},h.prototype.reportUser=function(e,r,a){return v(this,void 0,void 0,(function(){var s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return x(e instanceof i&&n(ge,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new vt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},h.prototype.reportMessage=function(e,r,i){return v(this,void 0,void 0,(function(){var a,s,o,u;return y(this,(function(c){switch(c.label){case 0:return x(e instanceof ae&&n(ge,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new yt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},h}(J),Ft=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return d(t,e),t}(i);export{oe as B,qt as C,Et as D,se as F,De as M,Ce as O,Ft as P,ge as R,le as U,me as a,ue as b,pe as c,ke as d,Lt as e,Te as f,_e as g,he as h,fe as i,nt as j,Ve as k,ft as l,ht as m,lt as n,st as o,ut as p,Ut as q,wt as r,ce as s,_t as t,Ue as u,de as v,Ie as w,we as x,Me as y,Nt as z}; +import{ah as e,i as t,h as n,T as r,U as i,ai as a,aj as s,ak as o,l as u,e as c,q as l,_ as d,A as h,g as p,b as f,c as m,j as v,k as y,n as g,S as _,V as T,W as U,al as I,am as w,C as M,an as E,y as S,ao as b,ap as C,F as P,aq as A,ar as D,as as R,aa as q,at as k,au as O,av as N,D as L,x as F,t as Q,K as z,u as x,aw as G,L as B,M as j,a5 as V,ax as W,G as K,z as Y,ay as H,I as J,Y as Z,Z as X,az as $,aA as ee,aB as te,aC as ne,aD as re,aE as ie,w as ae}from"./__bundle-7175498d.js";var se,oe={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},ue=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&t("number",u.parentMessageId,!0)&&t("boolean",u.isReplyToChannel)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)&&t("boolean",u.isPinnedMessage,!0)},ce=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},le=u(u({},oe),{message:null,translationTargetLanguages:null,pollId:null}),de=function(e){return ue(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(se||(se={}));var he,pe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},fe=function(e){return e===se.BLOB||e===se.FILE},me=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ve=u(u({},oe),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),ye=function(e){return ue(e)&&(l(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(he||(he={}));var ge,_e=function(){function e(e){var t,r,i;this.restrictionType=null,this.description=null,this.endAt=-1,n(he,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1}return e.payloadify=function(e){return e?c({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},e}(),Te=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new _e(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),_e.payloadify(t.restrictionInfo))):null},t}(i),Ue={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Ie=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},we=u(u({},Ue),{message:null,translationTargetLanguages:null,pollId:null}),Me=function(e){return Ie(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},Ee=u({},Ue),Se=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return d(t,e),t}(f),be=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Ce=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Se(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=o.sent(),i=r.as(be),a=i.operators,s=i.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),Pe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return d(t,e),t}(f),Ae=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.mutedUsers=[];var i=n.next,a=n.muted_list;return r.token=i,a&&a.length>0&&(r.mutedUsers=a.map((function(e){return new Te(t,e)}))),r}return d(t,e),t}(m),De=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Pe(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Ae),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),Re=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({limit:a,token:s}),n}return d(t,e),t}(f),qe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var i=n.next,a=n.banned_list;return r.token=i,a&&a.length>0&&(r.bannedUsers=a.map((function(e){return new Te(t,e.user)}))),r}return d(t,e),t}(m),ke=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Re(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(qe),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(ge||(ge={}));var Oe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ne=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var Le=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return d(t,e),t}(f),Fe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),Qe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return d(t,e),t}(f),ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return d(t,e),t}(m),xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return d(t,e),t}(f),Ge=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return d(t,e),t}(m),Be=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),je=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return d(t,e),t}(m),Ve=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),We=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return d(t,e),t}(f),Ke=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return d(t,e),t}(m),Ye=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),He=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return d(t,e),t}(m),Je=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return d(t,e),t}(f),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return d(t,e),t}(f),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return d(t,e),t}(f),tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var st=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ut=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({user_id:a,seconds:s,description:o}),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.memberCount=null,i.joinedMemberCount=null,i.user=new Te(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return d(t,e),t}(U),dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ht=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Te(t,r.data),i}return d(t,e),t}(U),pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return d(t,e),t}(U),mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),vt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(w,"/users/").concat(o),n.params={channel_url:r,channel_type:i===M.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),yt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),gt=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:c({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==s.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return d(n,t),n}(E),_t=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new S(t,r);var u=T.of(t).sdkState;return o.isMentioned=b(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(a=o.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(s=r.force_update_last_message)&&void 0!==s&&s,o}return d(t,e),t}(U),Tt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:c({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return d(n,t),n}(E),Ut=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new S(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),It=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:c({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return d(n,t),n}(E),wt=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new P(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),Mt=function(e){function t(t){var n=e.call(this)||this;return n.method=h.DELETE,n.path="".concat(p(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Et=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return d(t,e),t}(U),St=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(n),r}return d(t,e),t}(m),Ct=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(u({},n)),r}return d(t,e),t}(m),At=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return d(t,e),t}(f),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),Rt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),kt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return R.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new P(t,n),r}return d(t,e),t}(m),Nt=2,Lt=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=M.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c.url=r.channel_url,c.name=null!==(a=r.name)&&void 0!==a?a:"",c.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",c.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",c.data=null!==(u=r.data)&&void 0!==u?u:"",c.isFrozen=!!t("boolean",r.freeze)&&r.freeze,c.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,c.creator=r.created_by?new i(c._iid,r.created_by):null,c.createdAt=1e3*r.created_at,c._cachedMetaData=new Map,r.metadata&&r.ts&&Object.keys(r.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})})),c}return d(h,e),h.payloadify=function(t){return c(u(u({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:i.payloadify(t.creator),created_at:t.createdAt/1e3}))},h.prototype.isGroupChannel=function(){return this.channelType===M.GROUP},h.prototype.isOpenChannel=function(){return this.channelType===M.OPEN},Object.defineProperty(h.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),h.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},h.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(_.invalidParameters),n=T.of(this._iid).requestQueue,i=new At({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Dt).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();G(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var s=new Rt(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(qt).message;V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(W(r))throw r;G(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},h.prototype.sendFileMessage=function(e){var t=u(u({},ve),e);return x(ye(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=T.of(this._iid).dispatcher,i=Y.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new H;return a||(a=this._generateRequestId(),G(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new B({messages:[t],source:j.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new B({messages:[e],source:j.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(W(t))throw t;G(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=T.of(n._iid).cacheContext.localCacheEnabled&&K(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new B({messages:[i],source:i.sendingStatus===L.PENDING?j.REQUEST_RESEND_MESSAGE:j.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},h.prototype._autoResendFileMessage=function(e){x(e instanceof P).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},h.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,s=new kt(u(u({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(s).then((function(e){var n=e.as(Ot).message;V((function(){return v(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(W(a))throw a;G(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),V((function(){return v(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},h.prototype.sendFileMessages=function(e){var t,n;x(e.every((function(e){return ye(u(u({},ve),e))}))).throw(_.invalidParameters);var r=new H;try{for(var i=F(e),a=i.next();!a.done;a=i.next()){var s=a.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},h.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){return r=Boolean(e.url)||l(t)||l(null===(n=e.messageParams)||void 0===n?void 0:n.file),x(e instanceof P&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new re,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&l(t)&&(e.messageParams.file=t),e.messageParams):c({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},h.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return r=u(u({},Ee),n),x(t("number",e)&&function(e){return Ie(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new It(u({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(t("string",e)).throw(_.invalidParameters),Y.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r;return v(this,void 0,void 0,(function(){var i,a;return y(this,(function(o){return x(e instanceof h&&t instanceof P&&t.sendingStatus===L.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),i=new re,a=u(u({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:s.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(a).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},h.prototype.deleteMessage=function(e){return v(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return x(e instanceof ie).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Mt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},h.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return x(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(bt).reactionEvent]}}))}))},h.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return x(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Pt).reactionEvent]}}))}))},h.prototype._updateMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(Ut).message,a.dispatch(new B({messages:[c],source:j.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return x(e instanceof ie&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},h.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return x(e instanceof ie&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},h.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(e instanceof ie&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},h.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return x(e instanceof ie&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},h.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return x(n(ge,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new mt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},h.prototype.reportUser=function(e,r,a){return v(this,void 0,void 0,(function(){var s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return x(e instanceof i&&n(ge,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new vt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},h.prototype.reportMessage=function(e,r,i){return v(this,void 0,void 0,(function(){var a,s,o,u;return y(this,(function(c){switch(c.label){case 0:return x(e instanceof ae&&n(ge,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new yt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},h}(J),Ft=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return d(t,e),t}(i);export{oe as B,qt as C,Et as D,se as F,De as M,Ce as O,Ft as P,ge as R,le as U,me as a,ue as b,pe as c,ke as d,Lt as e,Te as f,_e as g,he as h,fe as i,nt as j,Ve as k,ft as l,ht as m,lt as n,st as o,ut as p,Ut as q,wt as r,ce as s,_t as t,Ue as u,de as v,Ie as w,we as x,Me as y,Nt as z}; diff --git a/__bundle-ee341ede.js b/__bundle-ee341ede.js deleted file mode 100644 index b3d09fb..0000000 --- a/__bundle-ee341ede.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,A as t,a as n,b as r,P as i,c as s,d as o,g as a,e as u,i as c,v as l,f as h,h as d,C as f,j as p,k as v,u as _,S as m,l as y,m as g,M as b,n as w,V as I,U as E,o as k,q as N,r as T,s as O,t as S,w as C,R as A,x,F as L,y as P,I as R,z as D,E as M,B as U,D as q,G as F,H as B,J as K,K as j,L as H,W as z,N as V,O as Q,Q as G,T as W,X as Y,Y as X,Z as J,$ as Z,a0 as $,a1 as ee,a2 as te,a3 as ne,a4 as re,a5 as ie,a6 as se,a7 as oe,a8 as ae,a9 as ue,aa as ce,ab as le,ac as he}from"./__bundle-2a729281.js";import{U as de,s as fe,v as pe,B as ve,a as _e,b as me,i as ye,F as ge,c as be}from"./__bundle-a9c3db53.js";var we,Ie,Ee,ke;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(we||(we={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(Ie||(Ie={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(Ee||(Ee={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(ke||(ke={}));var Ne,Te,Oe,Se=function(r){function i(e){var i=e.title,s=e.optionTexts,o=e.data,a=e.allowUserSuggestion,u=e.allowMultipleVotes,c=e.closeAt,l=r.call(this)||this;return l.method=t.POST,l.path=n,l.params={title:i,options:s,data:o,allow_user_suggestion:a,allow_multiple_votes:u,close_at:c},l}return e(i,r),i}(r),Ce=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Ae=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=r.call(this)||this;return a.method=t.GET,a.path="".concat(n,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return e(i,r),i}(r),xe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Le=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=r.call(this)||this;return u.method=t.GET,u.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a)),u.params={channel_url:i,channel_type:s},u}return e(i,r),i}(r),Pe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pollOption=new o(e,n),r}return e(n,t),n}(s),Re=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,o=e.token,c=n.call(this)||this;return c.method=t.GET,c.path="".concat(a(r),"/").concat(encodeURIComponent(i),"/polls/changelogs"),c.params=u({change_ts:s,token:o}),c}return e(r,n),r}(r),De=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedPolls=n.updated.map((function(t){return function(e,t){return t?new i(e,t):null}(e,t)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),Me={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Ue=function(e){return c("string",e.title)&&l(e.optionTexts)&&h(e.data)&&c("boolean",e.allowUserSuggestion,!0)&&c("boolean",e.allowMultipleVotes,!0)&&c("number",e.closeAt,!0)},qe={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Fe=function(e){return c("string",e.channelUrl)&&d(f,e.channelType)&&c("number",e.pollId)&&c("number",e.pollOptionId)},Be={channelUrl:null,channelType:null,pollId:null},Ke=function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&d(f,e.channelType)&&c("number",e.pollId)},je={},He=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=o,je[e]=this}return e.of=function(e){return je[e]},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return _(Ke(e)).throw(m.invalidParameters),t=new Ae(y({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(xe).poll]}}))}))},e.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return _(Ue(e)).throw(m.invalidParameters),t=e.data,n=new Se(y(y({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(Ce).poll]}}))}))},e.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return _(Fe(e)).throw(m.invalidParameters),t=new Le(y({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Pe).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=b.SYNC_POLL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,s,o,a,c,l,h;return v(this,(function(d){switch(d.label){case 0:return i=new Re(u({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=d.sent(),o=s.as(De),a=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,a.length>0&&this._dispatcher.dispatch(new g({polls:a,source:r})),[2,{updatedPolls:a,deletedPollIds:c,hasMore:l,token:h}]}}))}))},e}(),ze=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},Ve=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Qe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.token,a=e.limit,u=r.call(this)||this;return u.method=t.GET,u.path=n,u.params={channel_url:i,channel_type:s,token:o,limit:a},u}return e(i,r),i}(r),Ge=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(t){return new i(e,t)})),s.token=n.next,s}return e(n,t),n}(s),We=function(t){function n(e,n){return t.call(this,e,n.channelUrl,n.channelType,n)||this}return e(n,t),n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new Qe(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ge),i=r.polls,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(w),Ye=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=e.token,c=e.limit,l=r.call(this)||this;return l.method=t.GET,l.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a),"/voters"),l.params={channel_url:i,channel_type:s,token:u,limit:c},l}return e(i,r),i}(r),Xe=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(t){return new E(e,t)})),i.token=n.next,i}return e(n,t),n}(s),Je=function(t){function n(e,n){var r=t.call(this,e,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("number",this.pollId)&&c("number",this.pollOptionId)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new Ye(y(y({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Xe),i=r.voters,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(w),Ze=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new He(e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c})},n.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},Me),e),_(Ue(t)).throw(m.invalidParameters),[2,this._manager.create(t)]}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},Be),e),_(Ke(t)).throw(m.invalidParameters),[2,this._manager.get(t)]}))}))},n.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=y(y({},qe),e),_(Fe(t)).throw(m.invalidParameters),[2,this._manager.getOption(t)]}))}))},n}(k),$e={profileImage:null,profileUrl:null,nickname:null},et=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=T,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=T,this.onSessionRefreshed=T,this.onSessionClosed=T})),tt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=T,this.onReconnectStarted=T,this.onReconnectSucceeded=T,this.onReconnectFailed=T,this.onDisconnected=T})),nt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=T,this.onTotalUnreadMessageCountUpdated=T})),rt=100,it="GroupChannel",st=100,ot=10,at=20;!function(e){e.LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Ne||(Ne={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Te||(Te={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(Oe||(Oe={}));var ut,ct=function(e){switch(e){case Ne.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case Ne.CHRONOLOGICAL:return["-createdAt","syncIndex"];case Ne.CHANNEL_NAME_ALPHABETICAL:return["name"]}},lt=function(){function e(){this.messageTypeFilter=O.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=A.NONE}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){switch(this.messageTypeFilter){case O.USER:if(e.messageType!==S.USER)return!1;break;case O.FILE:if(e.messageType!==S.FILE)return!1;break;case O.ADMIN:if(e.messageType!==S.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof C))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case A.NONE:if(e.parentMessageId>0)return!1;break;case A.ONLY_REPLY_TO_CHANNEL:if(e instanceof C&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ut||(ut={}));var ht,dt=function(e){switch(e){case ut.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ut.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ft=y(y({},de),{scheduledAt:null}),pt=function(e){return pe(e)&&c("number",e.scheduledAt,!0)},vt=y(y({},ve),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),_t=function(e){return me(e)&&c("number",e.scheduledAt)&&(N(e.file)||c("string",e.fileUrl))&&c("string",e.fileName,!0)&&c("string",e.mimeType,!0)&&c("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return c("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mt={},yt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._sdkState=r,s._cacheContext=i,mt[e]=s,s}return e(n,t),n.of=function(e){return mt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw m.invalidParameters;var t,n=y({},e.serialize());return e instanceof x?(e.messageParams&&(n.messageParams=fe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,y(y({},fe(t)),{scheduledAt:t.scheduledAt})))):e instanceof L&&(e.messageParams&&(n.messageParams=_e(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return y(y({},_e(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},n.prototype._deserialize=function(e){return e?(e=y(y({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype._deserializeWithMessageCreateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof x?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof L?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&ye(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=a.sent(),a.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),a.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof x?(s=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(s,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof L?(s=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof s.fileKey&&ye(s.fileType)?(o=s,[4,this.collection.getBlob(s.fileKey)]):[3,7]:[3,8];case 6:o.file=a.sent(),a.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(s,n),a.label=8;case 8:return[2,n]}}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,i=void 0===r?new lt:r,s=e.order,o=void 0===s?ut.CHANNEL_LATEST:s,a=e.sendingStatus,u=void 0===a?null:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return p(this,void 0,void 0,(function(){var e,t,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(o),t={"/where":function(e){return!!(o!==ut.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&i.match(a._deserialize(e))}},n&&(t.channelUrl=n),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new lt),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:ut.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return p(this,void 0,void 0,(function(){var t,n=this;return v(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return e instanceof L?e.messageParams&&(t=e.messageParams).file&&be(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=ge.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&be(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=ge.BLOB,i.label=4;case 4:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),gt=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return p(void 0,void 0,void 0,(function(){return v(this,(function(t){return[2,e.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[ct(Ne.LATEST_LAST_MESSAGE),ct(Ne.CHRONOLOGICAL),ct(Ne.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:"Message",keyName:"messageId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"UnsentMessage",keyName:"reqId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},bt={},wt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=t.call(this,e)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,bt[e]=o,o}return e(n,t),n.of=function(e){return bt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return y(y({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=y(y({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,o=void 0===s?new lt:s,a=e.order,u=void 0===a?ut.CHANNEL_LATEST:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h,f=e.isPollOnly,_=void 0!==f&&f;return p(this,void 0,void 0,(function(){var e,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case ut.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:dt(ut.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:dt(ut.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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]}}))}))},n.prototype.countBetween=function(e,t,n){return p(this,void 0,void 0,(function(){var r,i=this;return v(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=dt(ut.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return e instanceof L&&e.messageParams&&((t=e.messageParams).file&&be(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),It=function(t){function n(){var e=t.call(this)||this;return e._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(e),e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},n}(M),Et=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:t.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),kt=function(t){function n(e){var n=e.message,r=t.call(this)||this;return r.message=n,r}return e(n,t),n}(U),Nt={},Tt=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;Nt[e]=this,this._iid=e,Nt[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof B)switch(e.stateType){case K.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case K.DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return Nt[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=q.FAILED,r.errorCode=j.ACK_TIMEOUT,this._dispatcher.dispatch(new H({messages:[r],source:b.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=u.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&F(r.errorCode)&&(i=(new Date).getTime(),s=r.createdAt+2592e5,i<=s?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(r.reqId)<0&&this._autoResendQueue.push(r):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(s).toLocaleString()),r.sendingStatus=q.FAILED,this._dispatcher.dispatch(new H({messages:[r],source:b.LOCAL_MESSAGE_FAILED}))))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===q.SUCCEEDED||e.sendingStatus===q.FAILED&&!F(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return(e=yt.of(this._iid))?[4,e.fetch({sendingStatus:q.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new kt({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ht||(ht={}));var Ot=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,i=n.blockee;return{blocker:new E(e,r),blockee:new E(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new E(e,t)})):[]}},e}(),St=function(t){function n(e,n){var r=n.userId,i=t.call(this)||this;return i._iid=e,i.userId=r,i}return e(n,t),n}(U),Ct=function(t){function n(e,n,r){var i=t.call(this,e,"USEV",r)||this;return i.event=new Ot(r),i}return e(n,t),n}(z),At=function(n){function r(e){var r=e.userId,i=e.nickname,s=void 0===i?null:i,o=e.profileUrl,a=void 0===o?null:o,c=e.profileImage,l=void 0===c?null:c,h=e.preferredLanguages,d=void 0===h?null:h,f=n.call(this)||this;return f.method=t.PUT,f.path="".concat(V,"/").concat(encodeURIComponent(r)),f.params=u({nickname:s,profile_url:a,profile_file:l,preferred_languages:d}),f}return e(r,n),r}(r),xt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new E(e,y({},n)),r}return e(n,t),n}(s),Lt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),s.params={apns_device_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var Pt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),s.params={gcm_reg_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var Rt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new E(e,n.user),r}e(n,t)}(s);var Dt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new E(e,n.user),r}e(n,t)}(s);var Mt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var Ut=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,r.user=new E(e,n.user),r}e(n,t)}(s);var qt=function(n){function r(e){var r=e.userId,i=e.type,s=e.token,o=e.ts,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:o,token:s},a}return e(r,n),r}(r),Ft=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?Ee[n.type.toLowerCase()]:Ee.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(s),Bt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),i}return e(r,n),r}(r),Kt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),jt=function(n){function r(e){var r=e.userId,i=e.willAutoAccept,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),s.params={auto_accept:i},s}return e(r,n),r}(r),Ht=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),zt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),Vt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Qt=function(n){function r(e){var r=e.userId,i=e.doNotDisturbOn,s=e.startHour,o=e.startMin,a=e.endHour,u=e.endMin,c=e.timezone,l=n.call(this)||this;return l.method=t.PUT,l.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),l.params={do_not_disturb:i,start_hour:s,start_min:o,end_hour:a,end_min:u,timezone:c},l}return e(r,n),r}(r),Gt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Wt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),Yt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Xt=function(n){function r(e){var r=e.userId,i=e.snoozeOn,s=e.startTs,o=e.endTs,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:o},a}return e(r,n),r}(r),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Zt=function(n){function r(e){var r=e.userId,i=e.blockedUserId,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block"),s.params={target_id:i},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new E(e,n),r}e(n,t)}(s);var $t=function(n){function r(e){var r=e.userId,i=e.unblockedUserId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var en=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),tn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),nn=function(n){function r(e){var r=e.userId,i=e.pushTriggerOption,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),s.params={push_trigger_option:i},s}return e(r,n),r}(r),rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),sn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),i}return e(r,n),r}(r),on=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),an=function(n){function r(e){var r=e.userId,i=e.templateName,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),s.params={name:i},s}return e(r,n),r}(r),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),cn=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends/changelogs"),s.params={token:i},s}return e(r,n),r}(r),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new E(e,t)})),updatedUsers:n.updated.map((function(t){return new E(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(s),hn=function(n){function r(e){var r=e.userId,i=e.discoveries,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},s}return e(r,n),r}(r),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(s),fn=function(n){function r(e){var r=e.userId,i=e.discoveryKeys,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discovery_keys:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var pn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r),vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r}return e(n,t),n}(s),_n=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var mn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),i.params={},i}return e(r,n),r}(r),yn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(s),gn=function(n){function r(e){var r=e.userId,i=e.allowFriendDiscovery,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),s.params={allow_friend_discovery:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var bn,wn=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},In=function(e){var t,n,r;this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(t=e.id)&&void 0!==t?t:0,this.name=null!==(n=e.name)&&void 0!==n?n:"",this.url=null!==(r=e.url)&&void 0!==r?r:"",this.emojis=e.emojis?e.emojis.map((function(e){return new wn(e)})):[]},En=function(e){this.emojiHash=null,this.emojiCategories=[],this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new In(e)})):[]},kn=function(n){function r(){var e=n.call(this)||this;return e.method=t.GET,e.path=Q,e}return e(r,n),r}(r),Nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new En(n),r}return e(n,t),n}(s),Tn=function(n){function r(e){var r=e.categoryId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(Q,"/").concat(r),i}return e(r,n),r}(r),On=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new In(n),r}return e(n,t),n}(s),Sn=function(n){function r(e){var r=e.key,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(r),i}return e(r,n),r}(r),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new wn(n),r}return e(n,t),n}(s),An=function(n){function r(e){var r=e.limit,i=e.token,s=e.userIdsFilter,o=e.metaDataKeyFilter,a=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=V,l.params=u({limit:r,token:i,user_ids:s,metadatakey:o,metadatavalues_in:a,nickname_startswith:c}),l}return e(r,n),r}(r),xn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Ln=function(t){function n(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)&&c("string",this.metaDataKeyFilter,!0)&&W("string",this.metaDataValuesFilter,!0)&&c("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid).requestQueue,t=new An(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(xn),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),Pn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=e.userIdsFilter,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(r,"/block"),a.params=u({limit:i,token:s,user_ids:o}),a}return e(r,n),r}(r),Rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Dn=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pn(y(y({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Rn),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),Mn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),o.params={limit:i,token:s},o}return e(r,n),r}(r),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new E(e,t)})),r.next=n.next,r}return e(n,t),n}(s),qn=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mn(y(y({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Un),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw m.queryInProgress;case 4:return[3,6];case 5:throw m.invalidParameters;case 6:return[2]}}))}))},n}(Y),Fn={},Bn=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,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,v=void 0!==p&&p;return Fn[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Fn[t]=this),Fn[t]}return e.get=function(e){return Fn[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"}(bn||(bn={}));var Kn,jn=function(t){function n(e){var r=e.code,i=void 0===r?bn.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:bn.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:bn.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:bn.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:bn.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:bn.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:bn.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:bn.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:bn.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:bn.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:bn.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:bn.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:bn.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:bn.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:bn.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:bn.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:bn.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:bn.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:bn.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:bn.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:bn.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:bn.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:bn.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:bn.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:bn.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Kn||(Kn={}));var Hn,zn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw jn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return zn(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]=zn(e[r],t);return t.delete(e),n}return e},Vn=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw jn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Qn=function(e,t){for(var n=0,r=0;r>>0)%t},Gn=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Wn=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!Wn(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Wn(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((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!(Vn(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(Vn(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(Vn(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(Vn(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))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)},Yn=function(){},Xn=function(){return Promise.resolve()},Jn=function(e){return e},Zn=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Hn||(Hn={}));var $n,er,tr,nr=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,o=e.map,a=void 0===o?Jn:o,u=e.backward,c=void 0===u?Xn:u,l=e.forward,h=void 0===l?Xn:l,d=e.complete,f=void 0===d?Yn:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(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}(),rr=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}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],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*Vn(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*Vn(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i-1){var r=this._items[n];return t===tr.PERSISTENT&&(r.state=er.PERSISTENT),t!==tr.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)hr.includes(this._items[r].state)&&hr.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===er.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=D(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===er.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},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!==er.VOLATILE}))},e}(),pr=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(or(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(or(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,X([],J(e),!1)),[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=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return v(this,(function(h){switch(h.label){case 0:n=fr.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return y(y({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=fr.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=vr.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return n=Bn.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,fr.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?vr.createFromCacheItem(s):new vr({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=ur(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),fr.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),mr={},yr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[];var u=function(e,t,n){return"".concat(or(e,t),"/index.").concat(n)}(t,n,i.join(">"));return mr[u]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._transaction=s,this._store=o,this._transaction.on($n.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on($n.ERROR,this.indexerKey,(function(){return a.abort()}))),mr[u]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in mr)delete mr[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=J(this.indexOf(n),2),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=J(this.indexOf(n),2),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){var t,n,r,i,s=[];try{for(var o=D(this.fields),a=o.next();!a.done;a=o.next()){var u=a.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw jn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Vn(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,f,p,_,m;return v(this,(function(v){switch(v.label){case 0:return[4,(e=fr.get(this.dbname)).find(this._store,this.indexerKey,tr.PERSISTENT)];case 1:return(t=v.sent())?[3,11]:(n=ur(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=v.sent(),v.label=3;case 3:v.trys.push([3,8,9,10]),i=D(r),s=i.next(),v.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,tr.NO_CACHE)]:[3,6];case 5:a=v.sent(),u=vr.createFromCacheItem(a);try{for(_=void 0,c=D(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}v.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=v.sent(),f={error:d},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=zn(this._origin),v.label=12;case 12:return mr[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return fr.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete mr[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=zn(this._origin)},e.prototype.abort=function(){this._table=zn(this._origin)},e}(),gr="undefined"!=typeof document&&"undefined"!=typeof navigator;gr&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var br=gr&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");gr&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),gr&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),gr&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var wr,Ir,Er=gr&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),kr=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)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(wr||(wr={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Ir||(Ir={}));var Nr={},Tr=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=wr.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Nr[e]&&!t.forceCreate||(this.nodeId=kr(),this.key=e,gr&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case Ir.NEWNODE:n._sendSync();break;case Ir.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Ir.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Ir.REQUEST_LOCK,ts:e.ts})};try{for(var p=D(d),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case Ir.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Ir.REQUEST_LOCK:n._requestLock(i);break;case Ir.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case Ir.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Ir.REMOVENODE)}))),Nr[e]=this),Nr[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==wr.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:kr(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return gr&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Ir.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-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(Ir.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(Ir.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 p(this,void 0,void 0,(function(){var e=this;return v(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=wr.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Ir.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Ir.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Ir.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}(),Or=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=Kn.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=X([[r]],J(s.filter((function(e){return yr.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Tr(function(e,t){return"".concat(or(e,t),".lock")}(t,n)),this._blobContainer=new lr({dbname:t,collectionName:n,store:o}),this._transaction=new pr({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return p(this,void 0,void 0,(function(){var r;return v(this,(function(i){switch(i.label){case 0:return r=ar(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}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Kn.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,p,_=this;return v(this,(function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=Bn.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.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:v.sent(),this._blockManager=new _r({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=X([],J(this.indexes),!1),i=[],s=r.map((function(e){return yr.createKey(e)})),o=n?n.indexes.map((function(e){return yr.createKey(e)})):[];try{for(a=D(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(yr.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(p=a.return)&&p.call(a)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,X([],J(r.map((function(e){var t=new yr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,X([],J(i.map((function(e){return new yr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=ar(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:v.sent(),v.label=8;case 8:return this._state=Kn.READY,this._mutex.unlock(),[3,10];case 9:throw d=v.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Kn.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=yr.createKey(e);try{for(var i=D(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===yr.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return e=ar(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=D(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw jn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f;return v(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=D(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),o=D(this._indexers),a=o.next(),p.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=D(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=D(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=D(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,zn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw jn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new ir({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw jn.collectionKeyNotGiven;return[4,this._requestInsert(zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw jn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw jn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(zn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw jn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw jn.collectionKeyNotGiven;return[4,this._requestUpsert(zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw jn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw jn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(zn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw jn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw jn.collectionKeyNotGiven;return[4,this._requestUpdate(zn(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw jn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,h,d,f,_,m,y=this;return v(this,(function(g){switch(g.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new rr({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return p(y,void 0,void 0,(function(){var n,i;return v(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Wn(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:g.sent(),g.label=4;case 4:g.trys.push([4,9,10,11]),c=D(u),l=c.next(),g.label=5;case 5:return l.done?[3,8]:(h=l.value,[4,this._requestUpdate(zn(h))]);case 6:g.sent(),g.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return d=g.sent(),_={error:d},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return g.sent(),this._mutex.unlock(),[2,u];case 13:return f=g.sent(),[4,this._transaction.clear()];case 14:throw g.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),jn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw jn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,_,m=this;return v(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,o=void 0!==s&&s,a=[],[4,new rr({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return p(m,void 0,void 0,(function(){var t,r;return v(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Wn(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=D(a),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return h=y.sent(),f={error:h},[3,11];case 10:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw d=y.sent(),this._mutex.unlock(),d;case 14:return[3,16];case 15:throw this._transaction.clear(),jn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw jn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Sr=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:Z,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),X([],J(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=c.sent(),c.label=2;case 2:c.trys.push([2,7,8,9]),n=D(t),r=n.next(),c.label=3;case 3:return r.done?[3,6]:(i=r.value,[4,this._getRaw(i)]);case 4:(s=c.sent())&&(e+=JSON.stringify(s).length),c.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return o=c.sent(),a={error:o},[3,9];case 8:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(a)throw a.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a=this;return v(this,(function(u){switch(u.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=u.sent()))return[3,7];u.label=2;case 2:return u.trys.push([2,6,,7]),r=n.data,(null==(i=n.metadata)?void 0:i.shards)>1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return p(a,void 0,void 0,(function(){var n,i;return v(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw jn.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}}))}))})))]:[3,4];case 3:return o=u.sent(),[3,5];case 4:o=[r],u.label=5;case 5:return s=o,[2,this.encryption.decrypt(JSON.parse(s.join("")))];case 6:return u.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,y({},e.value)]}}))}))},e.prototype.setMany=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._setRaw([].concat.apply([],X([],J(e.map((function(e){return t._shardify(e)}))),!1)))];case 1:return n.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i=this;return v(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l=this;return v(this,(function(h){switch(h.label){case 0:t=[],n=function(e){var n,i,s;return v(this,(function(o){switch(o.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=o.sent())&&(s=i.metadata,t.push.apply(t,X([],J(r._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return l._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,h.label=1;case 1:h.trys.push([1,6,7,8]),i=D(e),s=i.next(),h.label=2;case 2:return s.done?[3,5]:(o=s.value,[5,n(o)]);case 3:h.sent(),h.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return a=h.sent(),u={error:a},[3,8];case 7:try{s&&!s.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}}))}))},e}(),Cr={},Ar=function(t){function n(e){void 0===e&&(e={});var n,r=this;r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=e.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return e(n,t),Object.defineProperty(n.prototype,"rawData",{get:function(){return Cr[this.dbname]},set:function(e){Cr[this.dbname]=e},enumerable:!1,configurable:!0}),n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){if(Cr[this.dbname])return[2,Object.keys(Cr[this.dbname])];throw jn.storeNotAvailable}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return Cr[this.dbname]?[4,Gn(this.delay)]:[3,2];case 1:return t.sent(),[2,Cr[this.dbname][e]?y({key:e},Cr[this.dbname][e]):null];case 2:throw jn.storeNotAvailable}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return Cr[this.dbname]?[4,Gn(this.delay)]:[3,2];case 1:c.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,s=r.data,o=r.metadata,Cr[this.dbname][i]=Object.freeze({data:s,metadata:o})}catch(e){a={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw jn.storeNotAvailable;case 3:return[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return Cr[this.dbname]?[4,Gn(this.delay)]:[3,2];case 1:o.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())r=n.value,Cr[this.dbname][r]&&delete Cr[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw jn.storeNotAvailable;case 3:return[2]}}))}))},n.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!0]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,Cr[this.dbname]={},[2]}))}))},n.prototype.set=function(e){return p(this,void 0,void 0,(function(){var n;return v(this,(function(r){if(this.observer[e.key]&&"function"==typeof this.observer[e.key].set&&(n=this.observer[e.key].set()))throw n;return[2,t.prototype.set.call(this,e)]}))}))},n.prototype.setMany=function(e){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a;return v(this,(function(u){try{for(n=D(e),r=n.next();!r.done;r=n.next())if(i=r.value,this.observer[i.key]&&"function"==typeof this.observer[i.key].set&&(s=this.observer[i.key].set()))throw s}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[2,t.prototype.setMany.call(this,e)]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,Gn(this.delay)];case 1:return e.sent(),Cr[this.dbname]={},[2]}}))}))},n}(Sr),xr=function(t){function n(e){void 0===e&&(e={});var n,r=this;return(r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName="NestDBStore",r._window="undefined"!=typeof window?window:null,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:null,r}return e(n,t),n.prototype._getObjectStore=function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i=this;return v(this,(function(s){switch(s.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,t="undefined"!=typeof document&&"undefined"!=typeof navigator,n=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),r=navigator.userAgent&&navigator.userAgent.includes("Edge/"),[4,new Promise((function(s,o){if(t)if(n){var a=i._indexedDb.open("_testMozilla");a.onerror=function(){return o("Private browsing mode.")},a.onsuccess=function(){return s()}}else r?(e.PointerEvent||e.MSPointerEvent)&&o("Private browsing mode."):s()}))];case 2:return s.sent(),[2,!0];case 3:return s.sent(),[2,!1];case 4:return[2,!1]}}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){var t,n=this;return v(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,new Promise((function(e,t){if(n._window&&gr)if(br){var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(jn.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}else Er?n._window.indexedDB||!n._window.PointerEvent&&!n._window.MSPointerEvent||t(jn.storeNotAvailableInPrivateBrowsing):e();else t(jn.storeNotAvailable)}))];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore("NestDBStore",{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return t._database=r.sent(),[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},n}(Sr),Lr=function(t){function n(e){var n=this,r=e.AsyncStorage,i=e.itemSizeLimit,s=void 0===i?6291456:i,o=$(e,["AsyncStorage","itemSizeLimit"]);return(n=t.call(this,y(y({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e,t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:t=[];try{for(n=D(e),r=n.next();!r.done;r=n.next())i=r.value,s=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(s),JSON.stringify(i)])}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return u.sent(),[2]}}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!!this._asyncStorage]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,[2]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},n}(Sr);!function(t){function n(e){var n,r=this;return(r=t.call(this,y(y({},e),{itemSizeLimit:null!==(n=e.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=e.MMKV,r}e(n,t),n.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},n.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},n.prototype._getAllRawKeys=function(){return p(this,void 0,void 0,(function(){var e,t=this;return v(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},n.prototype._getRaw=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},n.prototype._setRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){try{for(t=D(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}}return[2]}))}))},n.prototype._removeRaw=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){try{for(t=D(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}))}))},n.prototype.isAvailable=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,!!this._mmkv]}))}))},n.prototype.init=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return this.dbname=e,[2]}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(Sr);var Pr,Rr=!0,Dr=function(){function e(){}return e.off=function(){Rr=!1},e.log=function(){for(var e=[],t=0;ta.ts){if(a.all!==t.all&&(u=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(u=!0),a.customTypes[l]=t.customTypes[l];u=u&&a.ts>0,a.ts=c}u&&se((function(){return p(r,void 0,void 0,(function(){return v(this,(function(e){return[2,h.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof ae&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),ue.payloadify(t.userProfile))}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ce:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,v=t.logLevel,_=t.localCacheEnabled,m=void 0!==_&&_,y=t.localCacheEncryption,g=t.useAsyncStorageStore,b=void 0===g?null:g;if(!Ur||p){var w="su-".concat(le()),E=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},k=new Ar({encryption:E});l||(k=b?new Lr({AsyncStorage:b,encryption:E}):new xr({encryption:E})),new I(w,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:k,encryption:E,logLevel:v,localCacheEnabled:m,debugMode:l});var N=[new he,new Ze],T=new e(w,u,X(X([],J(o),!1),J(N),!1));return Ur||(Ur=T),T}return Ur},Object.defineProperty(e,"instance",{get:function(){return Ur},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return ee},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return I.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appInfo",{get:function(){return I.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=I.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return I.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return I.of(this._iid).logger.level},set:function(e){I.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return I.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return te(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=I.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=I.of(this._iid).connectionManager;return e.isConnected?ne.OPEN:e.isConnecting?ne.CONNECTING:ne.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=I.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},e.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},e.prototype.getMemoryStoreForDebugging=function(){var e=I.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ar?n.store:null;throw m.debugModeRequired},e.prototype.addExtension=function(e,t){var n=I.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},e.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},e.prototype.initializeCache=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=I.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,9]:[4,i.logout()];case 1:return c.sent(),n.userId=e,o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.localCacheEnabled?r.nestdb&&r.nestdb.state!==Pr.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Mr({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",gt(a,r.store)),[4,a.open()]):[3,4];case 2:c.sent(),s.dispatch(new St(this._iid,{userId:e})),c.label=3;case 3:return[3,6];case 4:return[4,r.store.init(o)];case 5:c.sent(),c.label=6;case 6:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 7:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 8:(u=c.sent())&&new ue(this._iid,u).apply(),c.label=9;case 9:return[2]}}))}))},e.prototype.clearCachedData=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return(e=I.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()];case 1:return t.sent(),[2]}}))}))},e.prototype.clearCachedMessages=function(e){return p(this,void 0,void 0,(function(){var t,n,r=this;return v(this,(function(i){switch(i.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=wt.of(this._iid),n=yt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return p(r,void 0,void 0,(function(){return v(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:_(c("string",e)&&c("string",t,!0)).throw(m.invalidParameters),n=I.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return u.sent(),[3,4];case 3:return u.sent(),a=I.of(this._iid).logger,i.localCacheEnabled=!1,a.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return u.sent(),this._onlineDetector.start(),this._appStateChangeDetector.start(),[4,s.connect(t)];case 6:return u.sent(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},e.prototype.disconnect=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=I.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},e.prototype.setBackgroundState=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},e.prototype.setForegroundState=function(){var e=I.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},e.prototype.setSessionHandler=function(e){_(e instanceof et).throw(m.invalidParameters),I.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){_(c("string",e)&&t instanceof nt).throw(m.invalidParameters),I.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){I.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){I.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){_(c("string",e)&&t instanceof tt).throw(m.invalidParameters),I.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){I.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){I.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Ln(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Dn(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new qn(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new re(this._iid,e)},e.prototype.createPollListQuery=function(e){return new We(this._iid,y({},e))},e.prototype.createPollVoterListQuery=function(e){return new Je(this._iid,y({},e))},e.prototype.buildUserFromSerializedData=function(e){var t=ie(e);return new E(this._iid,E.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return t=y(y({},$e),e),_(function(e){return N(e.profileImage,!0)&&c("string",e.profileUrl,!0)&&c("string",e.nickname,!0)}(t)).throw(m.invalidParameters),this.currentUser?(n=I.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new At(y({userId:r.userId},t)),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(xt).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=a.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=a.profileUrl)),[2,a];case 2:throw m.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return _(W("string",e)).throw(m.invalidParameters),this.currentUser?(t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(xt).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw m.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 3:return s.sent(),[2,we.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,we.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Dt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 3:return s.sent(),[2,we.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,we.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ut({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Lt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 3:return s.sent(),[2,we.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,we.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(_(c("string",e)).throw(m.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,we.SUCCESS];case 3:return s.sent(),[2,we.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,we.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mt({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Bt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Kt).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(c("boolean",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,{autoAccept:s.as(Ht).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Vt).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,n,r,i,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=""),p(this,void 0,void 0,(function(){var o,a,u,l,h;return v(this,(function(d){switch(d.label){case 0:return _(c("boolean",e)&&c("number",t)&&c("number",n)&&c("number",r)&&c("number",i)&&c("string",s)).throw(m.invalidParameters),o=I.of(this._iid),a=o.sdkState,u=o.requestQueue,l=new Qt({userId:a.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s}),[4,u.send(l)];case 1:return h=d.sent(),[2,h.as(Gt).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Wt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Yt).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return _(c("boolean",e)&&c("number",t)&&c("number",n)).throw(m.invalidParameters),r=I.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new Xt({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(Jt).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return _(c("string",e)&&d(Ee,t)).throw(m.invalidParameters),n=I.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qt({userId:r.userId,type:t,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Ft).pushTokens]}}))}))},e.prototype.getPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(tn).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(d(Ie,e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new nn({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(rn).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new sn({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(on).name]}}))}))},e.prototype.setPushTemplate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(d(ke,e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(un).name]}}))}))},e.prototype.blockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(e instanceof E||c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Zt({userId:n.userId,blockedUserId:e instanceof E?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(e instanceof E||c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $t({userId:n.userId,unblockedUserId:e instanceof E?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(c("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,token:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(ln).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=I.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new mn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(yn).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(c("boolean",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new gn({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new hn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(dn).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new fn({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new pn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(vn).users]}}))}))},e.prototype.deleteFriend=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return _(W("string",e)).throw(m.invalidParameters),t=I.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new _n({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=I.of(this._iid).requestQueue,t=new kn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Nn).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=I.of(this._iid).requestQueue,n=new Tn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(On).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=I.of(this._iid).requestQueue,n=new Sn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Cn).emoji]}}))}))},e}();export{kt as A,Dn as B,tt as C,rt as D,wn as E,qn as F,Ne as G,ke as H,we as I,Ee as J,et as K,nt as L,wt as M,it as N,ze as P,ft as S,yt as U,St as a,Ve as b,Ct as c,ht as d,Ot as e,st as f,ct as g,He as h,lt as i,Tt as j,vt as k,_t as l,We as m,Je as n,Ie as o,ot as p,at as q,Te as r,Oe as s,Ze as t,qr as u,pt as v,Ln as w,In as x,En as y,Ar as z}; diff --git a/groupChannel.js b/groupChannel.js index 9365c08..10b6c79 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,h as t,af as n,e as a,l as o,C as u,U as l,I as c,aF as h,Y as d,Z as p,j as _,k as f,z as m,T as v,i as g,q as E,s as y,aG as C,B as N,aH as b,aI as T,aJ as U,m as S,aK as A,aL as I,L as w,w as D,A as L,N as P,b as R,c as k,aM as O,aN as x,aO as F,aP as H,an as V,W as q,aQ as B,aR as Q,X as j,S as z,aS as W,a5 as K,V as Y,x as J,F as X,ax as Z,a6 as $,M as ee,aT as te,u as ne,aU as re,E as se,H as ie,J as ae,y as oe,R as ue,g as le,D as ce,aV as he,ab as de,aW as pe,n as _e,ah as fe,ar as me,as as ve,ai as ge,ak as Ee,f as ye,a as Ce,P as Ne,aX as be,aw as Me,ay as Te,aY as Ue,aZ as Se,r as Ae,o as Ie}from"./__bundle-2a729281.js";export{M as MessageEventSource,aG as ScheduledStatus}from"./__bundle-2a729281.js";import{N as we,G as De,g as Le,D as Pe,a as Re,P as ke,b as Oe,U as xe,M as Fe,A as He,c as Ve,d as Ge,e as qe,f as Be,h as Qe,i as je,j as ze,S as We,v as Ke,k as Ye,l as Je,m as Xe,n as Ze,o as $e,p as et,q as tt,r as nt,s as rt}from"./__bundle-ee341ede.js";export{G as GroupChannelListOrder,i as MessageFilter,r as PublicGroupChannelListOrder,s as ScheduledMessageListOrder}from"./__bundle-ee341ede.js";import{f as st,j as it,k as at,l as ot,m as ut,n as lt,o as ct,p as ht,D as dt,q as pt,r as _t,t as ft,u as mt,w as vt,x as gt,y as Et,e as yt,C as Ct,z as Nt}from"./__bundle-a9c3db53.js";import{C as bt,a as Mt,O as Tt,M as Ut,T as St,R as At,U as It,A as wt,B as Dt}from"./__bundle-43418632.js";var Lt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Lt||(Lt={}));var Pt,Rt,kt,Ot,xt,Ft,Ht,Vt,Gt=function(r){function s(e,s){var i=r.call(this,e,s)||this;return i.state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=t(Lt,s.state)?s.state:null,i.role=t(n,s.role)?s.role:null,s.hasOwnProperty("is_muted")&&(i.isMuted=s.is_muted),s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),s.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return e(s,r),s.payloadify=function(e){return e?a(o(o({},r.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null},s}(st),qt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:u.GROUP,i.reader=new l(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Pt||(Pt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Rt||(Rt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(kt||(kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(xt||(xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Ft||(Ft={})),function(e){e.AND="AND",e.OR="OR"}(Ht||(Ht={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Vt||(Vt={}));var Bt,Qt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Rt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=kt.ALL,this.publicChannelFilter=Pt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ot.ALL,this.hiddenChannelFilter=xt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=Ht.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Vt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Vt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case Ht.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case Ht.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!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 p=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Rt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Rt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Rt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Rt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case xt.HIDDEN:if(!e.isHidden)return!1;break;case xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ot.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Pt.PUBLIC:if(!e.isPublic)return!1;break;case Pt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case kt.SUPER:if(!e.isSuper)return!1;break;case kt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),jt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(we):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),o(o({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return rr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],p(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case De.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return _(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return _(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],p(this._channels.keys()),!1)),_(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:n=[],c.label=1;case 1:c.trys.push([1,6,7,8]),r=m(t),s=r.next(),c.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=c.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),c.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:c.sent(),c.label=10;case 10:return[2]}}))}))},n}(c),zt={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Wt=function(e){return v("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Kt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Yt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Jt={myMemberStateFilter:Rt.ALL},Xt=function(e){return t(Rt,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Bt||(Bt={}));var Zt,$t={keys:[]},en={channelCustomTypesFilter:null,superChannelFilter:kt.ALL},tn={channelUrl:null,scheduledStatus:null,messageTypeFilter:y.ALL};!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(Zt||(Zt={}));var nn=function(e){return e.startsWith("EVENT_")||e===Zt.SYNC_CHANNEL_BACKGROUND||e===Zt.SYNC_CHANNEL_CHANGELOGS},rn=function(t){function n(e){var n=e.channels,r=e.source,s=t.call(this)||this;return s.channels=n,s.source=r,s}return e(n,t),n}(N),sn=function(t){function n(e){var n=e.channelUrls,r=e.source,s=t.call(this)||this;return s.channelUrls=n,s.source=r,s}return e(n,t),n}(N),an=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return _(i,void 0,void 0,(function(){var s,i,a,o,u,l,c,h,d,p,v,g=this;return f(this,(function(E){switch(E.label){case 0:if(!(e instanceof rn))return[3,10];s=e.channels,d=e.source,i=s.filter((function(e){return e instanceof ms})),a=t.filterOffsetChanged(i),E.label=1;case 1:E.trys.push([1,6,7,8]),o=m(a),u=o.next(),E.label=2;case 2:return u.done?[3,5]:(l=u.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:E.sent(),E.label=4;case 4:return u=o.next(),[3,2];case 5:return[3,8];case 6:return c=E.sent(),p={error:c},[3,8];case 7:try{u&&!u.done&&(v=o.return)&&v.call(o)}finally{if(p)throw p.error}return[7];case 8:return[4,t.upsert(i)];case 9:return E.sent(),this._broadcastUpdateEvent(i,d),[3,15];case 10:return e instanceof sn?(h=e.channelUrls,d=e.source,[4,t.remove(h)]):[3,13];case 11:return E.sent(),[4,b((function(){return _(g,void 0,void 0,(function(){var e,t,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=m(h),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return E.sent(),this._broadcastRemoveEvent(h,d),[3,15];case 13:return e instanceof Re?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:E.sent(),E.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return _(a,void 0,void 0,(function(){var t,s,i,a,o,u,l,c,h,d,p,m,v,g=this;return f(this,(function(E){switch(E.label){case 0:return e instanceof w?(t=e.messages,m=e.source,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof D?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:E.sent(),this._broadcastUpdateEvent(s,m),E.label=2;case 2:return i.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),this._broadcastUpdateEvent(i,m),E.label=4;case 4:return[3,21];case 5:return e instanceof I?(a=e.messageIds,m=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return E.sent(),this._broadcastRemoveEvent(a,m),[3,21];case 7:return e instanceof A?(o=e.reqId,m=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return E.sent(),this._broadcastRemoveUnsentEvent(o,m),[3,21];case 9:return e instanceof S?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(l=u.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(c=E.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:E.sent(),E.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof U?(h=e.event,m=e.source,[4,n.get(h.messageId)]):[3,17];case 14:return(d=E.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(h)?[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:E.sent(),E.label=16;case 16:return this._broadcastPollUpdateEvent(h,m),[3,21];case 17:return e instanceof T?(p=e.event,m=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,b((function(){return _(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:E.sent(),E.label=20;case 20:this._broadcastPollVoteEvent(p,m),E.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(t){function n(e){var n=e.userId,r=e.ts,s=e.token,i=e.filter,u=t.call(this)||this,l=o(o({},Kt),i),c=l.customTypes,h=l.includeEmpty,d=l.includeFrozen;return u.method=L.GET,u.path="".concat(P,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=a({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:r>0?r:null,token:s,custom_types:c,show_empty:h,show_frozen:d}),u}return e(n,t),n}(R),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new ms(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(k),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=L.GET,s.path="".concat(r?O:x,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(R),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new ms(e,n),r}return e(n,t),n}(k),dn=function(t){function n(e){var n=this,r=e.userId,s=e.token,i=e.limit,o=e.order,u=e.includeEmpty,l=e.myMemberStateFilter,c=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,p=e.nicknameContainsFilter,_=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,y=e.hiddenChannelFilter,C=e.metadataOrderKeyFilter,N=e.metadataKey,b=e.metadataValues,M=e.metadataValueStartsWith,T=e.includeFrozen,U=e.includeMetaData,S=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=L.GET,n.path="".concat(P,"/").concat(encodeURIComponent(r),"/my_group_channels"),n.params=a({token:s,limit:i,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:l,super_mode:c,public_mode:h,unread_filter:d,members_nickname_contains:p,members_nickname_startswith:_,members_nickname:f,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:E,hidden_mode:y,metadata_order_key:C,metadata_key:N,metadata_values:b,metadata_value_startswith:M,show_frozen:T,show_metadata:U}),S&&S.query&&S.fields&&(n.params.search_query=S.query,n.params.search_fields=S.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(n.params.members_include_in=A.userIds,n.params.query_type=A.queryType.toUpperCase()):n.params.members_exactly_in=A.userIds),n}return e(n,t),n}(R),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new ms(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(k),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Rt.ALL},s}return e(n,t),n}(R),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(k),mn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(R),vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Bt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Bt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Bt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Bt.SUPER_INVITATION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Bt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Bt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(k),gn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=L.GET,r.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(R),En=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(k),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:kt.ALL,custom_types:i},s}return e(n,t),n}(R),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(k),Nn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=L.GET,i.path="".concat(F,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(R),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(k),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case C.PENDING:t.push(H.PENDING);break;case C.SENT:t.push(H.IN_QUEUE),t.push(H.SENT);break;case C.CANCELED:t.push(H.CANCELED);break;case C.FAILED:t.push(H.FAILED)}})),t}},Tn=function(t){function n(e){var n=this,r=e.userId,s=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,l=e.isSuper,c=e.isBroadcast,h=e.isPublic,_=e.isExclusive,f=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,E=e.name,y=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(n=t.call(this)||this).method=L.POST,n.path=x,n.params=a({user_ids:d([r],p(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:i,cover_file:o,is_distinct:u,is_super:l,is_broadcast:c,is_exclusive:_,is_public:h,is_discoverable:f,strict:m,is_ephemeral:v,access_code:g,name:E,data:y,custom_type:C,operator_ids:M,message_survival_seconds:N}),n}return e(n,t),n}(R),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(k),Sn=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=L.PUT,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var An=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),wn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u,c=i.users,h=void 0===c?null:c;return s.memberCount=o,s.joinedMemberCount=l,s.members=Array.isArray(h)?h.map((function(t){return new Gt(e,t)})):[new Gt(e,r.data)],s}return e(n,t),n}(bt),Dn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var Ln=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=l,s.member=new Gt(s._iid,r.data),s}return e(n,t),n}(bt),Pn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=L.POST,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(R),Rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),kn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,p=i.invitees,_=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitees=_.map((function(t){return new Gt(e,t)})),s}return e(n,t),n}(bt),On=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.channel.myMemberState=Lt.NONE,r}e(n,t)}(k);var xn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,p=i.invitee,_=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitee=_?new Gt(e,_):null,s}return e(n,t),n}(bt),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(V),Hn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new qt(e,r),s}return e(n,t),n}(q),Vn=function(t){function n(e){var n=e.channelUrl,r=e.userId,s=t.call(this)||this;return(s=t.call(this)||this).method=L.PUT,s.path="".concat(x,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),s.params=a({userId:r}),s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var Gn,qn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(q),Bn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(R),Qn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(q),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Wn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new l(e,r.data),s}return e(n,t),n}(q),Kn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new l(e,r.data),s}return e(n,t),n}(q),Jn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(V),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"PEDI",r)||this;return s.event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new ke(e,r),s.status=B(r.poll.status)||r.poll.status,s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),Zn=function(t){function n(e,n,r){var s=t.call(this,e,"VOTE",r)||this;return s.event=null,s.channelUrl=null,s.channelType=null,s.event=new Oe(r),s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),$n=function(n){function r(e,t){var r,s,i,a,o,u,l,c,h,d,p,_,f,m,v,g,E,y,C,N,b,M,T=this;return(T=n.call(this,e,t)||this).includeEmpty=!1,T.includeFrozen=!0,T.includeMetaData=!0,T.channelUrlsFilter=null,T.customTypesFilter=null,T.customTypeStartsWithFilter=null,T.nicknameContainsFilter=null,T.nicknameStartsWithFilter=null,T.nicknameExactMatchFilter=null,T.channelNameContainsFilter="",T.myMemberStateFilter=Rt.ALL,T.unreadChannelFilter=Ot.ALL,T.superChannelFilter=kt.ALL,T.publicChannelFilter=Pt.ALL,T.hiddenChannelFilter=xt.UNHIDDEN,T.searchFilter={fields:[],query:null},T.userIdsFilter={userIds:[],includeMode:!0,queryType:Ht.AND},T.metadataKey=null,T.metadataValues=null,T.metadataOrderKeyFilter=null,T.metadataValueStartsWith=null,T.order=De.LATEST_LAST_MESSAGE,T.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,T.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,T.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,T.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,T.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,T.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",T.nicknameContainsFilter=null!==(l=t.nicknameContainsFilter)&&void 0!==l?l:null,T.nicknameStartsWithFilter=null!==(c=t.nicknameStartsWithFilter)&&void 0!==c?c:null,T.nicknameExactMatchFilter=null!==(h=t.nicknameExactMatchFilter)&&void 0!==h?h:null,T.channelNameContainsFilter=null!==(d=t.channelNameContainsFilter)&&void 0!==d?d:"",T.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:Rt.ALL,T.unreadChannelFilter=null!==(_=t.unreadChannelFilter)&&void 0!==_?_:Ot.ALL,T.superChannelFilter=null!==(f=t.superChannelFilter)&&void 0!==f?f:kt.ALL,T.publicChannelFilter=null!==(m=t.publicChannelFilter)&&void 0!==m?m:Pt.ALL,T.hiddenChannelFilter=null!==(v=t.hiddenChannelFilter)&&void 0!==v?v:xt.UNHIDDEN,T.searchFilter=null!==(g=t.searchFilter)&&void 0!==g?g:{fields:[],query:null},T.userIdsFilter=null!==(E=t.userIdsFilter)&&void 0!==E?E:{userIds:[],includeMode:!0,queryType:Ht.AND},T.metadataKey=null!==(y=t.metadataKey)&&void 0!==y?y:null,T.metadataValues=null!==(C=t.metadataValues)&&void 0!==C?C:null,T.metadataOrderKeyFilter=null!==(N=t.metadataOrderKeyFilter)&&void 0!==N?N:null,T.metadataValueStartsWith=null!==(b=t.metadataValueStartsWith)&&void 0!==b?b:null,T.order=null!==(M=t.order)&&void 0!==M?M:De.LATEST_LAST_MESSAGE,T}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&t(Rt,this.myMemberStateFilter)&&t(kt,this.superChannelFilter)&&t(Pt,this.publicChannelFilter)&&t(Ot,this.unreadChannelFilter)&&t(xt,this.hiddenChannelFilter)&&v(Vt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&t(Ht,this.userIdsFilter.queryType)&&t(De,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return Q(this)},r.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,rr.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),er=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||A.unreadMentionCount>0)&&(A._updateUnreadCount(0,0),this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==A.unreadMessageCount&&0!==A.unreadMentionCount||(this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),yn.label=12;case 12:return[3,77];case 13:return L=e.as(qn),ce=L.channelUrl,P=L.deliveredStateUpdate,R=void 0===P?{}:P,k=this._groupChannelCache.isCachedInMemory(ce),[4,this.getChannel(ce,!0)];case 14:if(O=yn.sent(),k)for(x in R)O._updateUndeliveredMemberState(x,R[x]);return this._dispatcher.dispatch(new rn({channels:[O],source:Zt.EVENT_CHANNEL_DELIVERED})),Object.keys(R).some((function(e){return e!==En._sdkState.userId}))&&$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,77];case 15:return F=e.as(At),ce=F.channelUrl,he=F.channelType,H=F.event,he!==u.GROUP?[3,18]:[4,this.getChannel(ce,!0)];case 16:return V=yn.sent(),[4,this.getMessageFromCache(H.messageId)];case 17:(B=yn.sent())&&(B.applyReactionEvent(H),this._dispatcher.dispatch(new w({messages:[B],source:ee.EVENT_MESSAGE_REACTION_UPDATED}))),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(V,H)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),yn.label=18;case 18:return[3,77];case 19:return(G=e.as(St).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return q=yn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(B=yn.sent())&&(B.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new w({messages:[B],source:ee.EVENT_MESSAGE_THREADINFO_UPDATED}))),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(q,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),yn.label=22;case 22:return[3,77];case 23:Q=e.as(Ut).groupChannelMemberCounts,j=[],yn.label=24;case 24:yn.trys.push([24,29,30,31]),z=m(Q),W=z.next(),yn.label=25;case 25:return W.done?[3,28]:(K=W.value,ce=K.channelUrl,Be=K.memberCount,Qe=K.joinedMemberCount,J=K.updatedAt,[4,this.getChannelFromCache(ce)]);case 26:(X=yn.sent())&&X._setLatestMemberCount(Be,Qe,J)&&j.push(X),yn.label=27;case 27:return W=z.next(),[3,25];case 28:return[3,31];case 29:return ne=yn.sent(),hn={error:ne},[3,31];case 30:try{W&&!W.done&&(dn=z.return)&&dn.call(z)}finally{if(hn)throw hn.error}return[7];case 31:return j.length>0&&(this._dispatcher.dispatch(new rn({channels:j,source:Zt.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(j)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 32:return se=e.as(Xn),ie=se.event,ae=se.status,ce=se.channelUrl,he=se.channelType,ce&&he?[4,this.getChannel(ce,!0)]:[3,77];case 33:return oe=yn.sent(),this._dispatcher.dispatch(new U({event:ie,source:ee.EVENT_POLL_UPDATED})),$(ae===re?function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(oe,ie.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(oe,ie)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),[3,77];case 34:return ue=e.as(Zn),le=ue.event,ce=ue.channelUrl,he=ue.channelType,ce&&he?[4,this.getChannel(ce,!0)]:[3,77];case 35:return de=yn.sent(),this._dispatcher.dispatch(new T({event:le,source:ee.EVENT_POLL_VOTED})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(de,le)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,77];case 36:if(!(pe=e.as(bt).event).isGroupChannelEvent)return[3,75];switch(pe.category){case Mt.CHANNEL_JOIN:return[3,37];case Mt.CHANNEL_LEAVE:return[3,39];case Mt.CHANNEL_OPERATOR_UPDATE:return[3,43];case Mt.CHANNEL_INVITE:return[3,45];case Mt.CHANNEL_DECLINE_INVITE:return[3,47];case Mt.TYPING_START:case Mt.TYPING_END:return[3,49];case Mt.USER_CHANNEL_MUTE:case Mt.USER_CHANNEL_UNMUTE:return[3,51];case Mt.USER_CHANNEL_BAN:return[3,53];case Mt.USER_CHANNEL_UNBAN:return[3,57];case Mt.CHANNEL_FREEZE:case Mt.CHANNEL_UNFREEZE:return[3,59];case Mt.CHANNEL_HIDE:return[3,61];case Mt.CHANNEL_UNHIDE:return[3,63];case Mt.CHANNEL_DELETED:return[3,65];case Mt.CHANNEL_PROP_CHANGED:return[3,67];case Mt.CHANNEL_META_DATA_CHANGED:return[3,69];case Mt.CHANNEL_META_COUNTERS_CHANGED:return[3,71];case Mt.PINNED_MESSAGE_CHANGED:return[3,73]}return[3,75];case 37:return[4,this.getChannel(pe.channelUrl,!0)];case 38:return _e=yn.sent(),fe=e.as(wn),me=fe.memberCount,ve=fe.joinedMemberCount,ge=fe.members,Ee=!1,ge.forEach((function(e){_e.isExclusive||_e.isSuper||_e.isBroadcast?Ee=Ee||_e._setLatestMemberCount(me,ve,pe.ts):(e.state=Lt.JOINED,_e.addMember(e,pe.ts),En._updateJoinedMemberCount(_e)),e.userId===En._sdkState.userId&&(_e.myMemberState=Lt.JOINED)})),this._dispatcher.dispatch(new rn({channels:[_e],source:Zt.EVENT_CHANNEL_JOINED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(ge),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(_e,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}_e.isBroadcast&&Ee&&e.onChannelMemberCountChanged([_e])})),[2]}))}))})),[3,75];case 39:return(nt=this._leftChannels.get(pe.channelUrl))?(Ce=nt.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(pe.channelUrl,!0)];case 41:Ce=yn.sent(),yn.label=42;case 42:return ye=Ce,Ne=e.as(Ln),Be=Ne.memberCount,Qe=Ne.joinedMemberCount,be=Ne.member,Me=!1,Te=Y.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?Me=ye._setLatestMemberCount(Be,Qe,pe.ts):(Te.enabledChannelMemberShipHistory?(ye.members.find((function(e){return e.userId===be.userId})).state=Lt.LEFT,ye.memberCount=Be):ye.removeMember(be),this._updateJoinedMemberCount(ye)),be.userId===this._sdkState.userId?(ye.myMemberState=Lt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new rn({channels:[ye],source:Zt.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new sn({channelUrls:[ye.url],source:Zt.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new rn({channels:[ye],source:Zt.EVENT_CHANNEL_LEFT})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ye,be),ye.isBroadcast&&Me&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,75];case 43:return[4,this.getChannel(pe.channelUrl,!0)];case 44:Ue=yn.sent(),Se=e.as(Tt).operators,Ae=Se.map((function(e){return e.userId}));try{for(Ie=m(Ue.members),we=Ie.next();!we.done;we=Ie.next())(tt=we.value).role=Ae.includes(tt.userId)?n.OPERATOR:n.NONE}catch(e){pn={error:e}}finally{try{we&&!we.done&&(_n=Ie.return)&&_n.call(Ie)}finally{if(pn)throw pn.error}}return Ue.myRole=Ae.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new rn({channels:[Ue],source:Zt.EVENT_CHANNEL_OPERATOR_UPDATED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Ue,Se)})),[2]}))}))})),[3,75];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:De=yn.sent(),Le=e.as(kn),Be=Le.memberCount,Qe=Le.joinedMemberCount,Pe=Le.inviter,(Re=Le.invitees).forEach((function(e){return e.state=Lt.INVITED}));try{for(ke=m(Re),Oe=ke.next();!Oe.done;Oe=ke.next())xe=Oe.value,De.isExclusive||De.isSuper||De.isBroadcast?De._setLatestMemberCount(Be,Qe,pe.ts):De.addMember(xe,pe.ts),this._sdkState.userId===xe.userId&&(De.hiddenState=ps.UNHIDDEN,De.myMemberState!==Lt.JOINED&&(De.myMemberState=Lt.INVITED),De.invitedAt=pe.ts)}catch(e){fn={error:e}}finally{try{Oe&&!Oe.done&&(mn=ke.return)&&mn.call(ke)}finally{if(fn)throw fn.error}}return this._dispatcher.dispatch(new rn({channels:[De],source:Zt.EVENT_CHANNEL_INVITED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(De,Pe,Re)})),[2]}))}))})),[3,75];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:return Fe=yn.sent(),He=e.as(xn),Be=He.memberCount,Qe=He.joinedMemberCount,je=He.inviter,ze=He.invitee,Fe.isExclusive||Fe.isSuper||Fe.isBroadcast?Fe._setLatestMemberCount(Be,Qe,pe.ts):Fe.removeMember(ze),this._sdkState.userId===ze.userId?(Fe.invitedAt=0,Fe.myMemberState=Lt.NONE,Fe.isPublic?this._dispatcher.dispatch(new rn({channels:[Fe],source:Zt.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new sn({channelUrls:[Fe.url],source:Zt.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new rn({channels:[Fe],source:Zt.EVENT_CHANNEL_DECLINED_INVITE})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Fe,je,ze)})),[2]}))}))})),[3,75];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return We=yn.sent(),Ke=pe.category===Mt.TYPING_START,Ye=e.as(Ke?Wn:Yn).user,We._updateTypingStatus(Ye,Ke?pe.ts:0),this._dispatcher.dispatch(new rn({channels:[We],source:Zt.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(We)})),[2]}))}))})),[3,75];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:Je=yn.sent(),Xe=pe.category===Mt.USER_CHANNEL_MUTE,(Ze=e.as(Xe?ct:ht).user).userId===this._sdkState.userId&&(Je.myMutedState=Xe?ds.MUTED:ds.UNMUTED);try{for($e=m(Je.members),et=$e.next();!et.done;et=$e.next())if((tt=et.value).userId===Ze.userId){tt.isMuted=Xe;break}}catch(e){vn={error:e}}finally{try{et&&!et.done&&(gn=$e.return)&&gn.call($e)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new rn({channels:[Je],source:Xe?Zt.EVENT_CHANNEL_MUTED:Zt.EVENT_CHANNEL_UNMUTED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Xe?e.onUserMuted(Je,Ze):e.onUserUnmuted(Je,Ze)})),[2]}))}))})),[3,75];case 53:return(nt=this._leftChannels.get(pe.channelUrl))?(st=nt.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(pe.channelUrl,!0)];case 55:st=yn.sent(),yn.label=56;case 56:return rt=st,this._markAsLeave(rt),mt=e.as(lt).user,$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(rt,mt)})),[2]}))}))})),[3,75];case 57:return[4,this.getChannel(pe.channelUrl,!0)];case 58:return vt=yn.sent(),gt=e.as(ut).user,$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(vt,gt)})),[2]}))}))})),[3,75];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return Et=yn.sent(),yt=e.as(ot).freeze,Et.isFrozen=yt,this._dispatcher.dispatch(new rn({channels:[Et],source:yt?Zt.EVENT_CHANNEL_FROZEN:Zt.EVENT_CHANNEL_UNFROZEN})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onChannelFrozen(Et):e.onChannelUnfrozen(Et)})),[2]}))}))})),[3,75];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Ct=yn.sent(),Nt=e.as(jn),Dt=Nt.allowAutoUnhide,Pt=Nt.hidePreviousMessages,Rt=Nt.messageOffsetTimestamp,null!==Dt&&(Ct.hiddenState=Dt?ps.HIDDEN_ALLOW_AUTO_UNHIDE:ps.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Ct._updateUnreadCount(0,0),null!==Rt&&(Ct.messageOffsetTimestamp=Rt),this._dispatcher.dispatch(new rn({channels:[Ct],source:Zt.EVENT_CHANNEL_HIDDEN})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Ct)})),[2]}))}))})),[3,75];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return(kt=yn.sent()).hiddenState=ps.UNHIDDEN,this._dispatcher.dispatch(new rn({channels:[kt],source:Zt.EVENT_CHANNEL_UNHIDDEN})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(kt)})),[2]}))}))})),[3,75];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return Ot=yn.sent(),this._dispatcher.dispatch(new sn({channelUrls:[pe.channelUrl],source:Zt.EVENT_CHANNEL_DELETED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Ot.url,Ot.channelType)})),[2]}))}))})),[3,75];case 67:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 68:return xt=yn.sent(),this._dispatcher.dispatch(new rn({channels:[xt],source:Zt.EVENT_CHANNEL_UPDATED})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(xt)})),[2]}))}))})),[3,75];case 69:return[4,this.getChannel(pe.channelUrl,!0)];case 70:return Ft=yn.sent(),Ht=e.as(at),Vt=Ht.created,Gt=Ht.updated,qt=Ht.deleted,Vt&&Ft._upsertCachedMetaData(Vt,pe.ts),Gt&&Ft._upsertCachedMetaData(Gt,pe.ts),qt&&Ft._removeFromCachedMetaData(qt,pe.ts),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated(Ft,Vt),Gt&&e.onMetaDataUpdated(Ft,Gt),qt&&e.onMetaDataDeleted(Ft,qt)})),[2]}))}))})),[3,75];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return Bt=yn.sent(),Qt=e.as(it),jt=Qt.created,zt=Qt.updated,Wt=Qt.deleted,$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){jt&&e.onMetaCounterCreated(Bt,jt),zt&&e.onMetaCounterUpdated(Bt,zt),Wt&&e.onMetaCounterDeleted(Bt,Wt)})),[2]}))}))})),[3,75];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Kt=yn.sent(),Yt=e.as(tr),Jt=Yt.pinnedMessageIds,Xt=Yt.latestPinnedMessage,($t=Yt.ts)>Kt._pinnedMessagesUpdatedAt&&(Kt.pinnedMessageIds=Jt,Kt.lastPinnedMessage=Xt,Kt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new rn({channels:[Kt],source:Zt.EVENT_PINNED_MESSAGE_UPDATED})),$((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(Kt)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),$((function(){return _(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Kt)})),[2]}))}))}))),[3,75];case 75:return[3,77];case 76:switch((en=e.as(Ve).event).category){case Ge.USER_BLOCK:tn=qe.getDataAsUserBlockEvent(this._iid,en),an=tn.blocker,on=tn.blockee,this._groupChannelCache.block(an.userId,on.userId);break;case Ge.USER_UNBLOCK:nn=qe.getDataAsUserBlockEvent(this._iid,en),an=nn.blocker,on=nn.blockee,this._groupChannelCache.unblock(an.userId,on.userId)}return[3,77];case 77:return[3,79];case 78:if(un=yn.sent(),Z(un))throw un;return[3,79];case 79:return[2]}}))}))},e.prototype._markAsLeave=function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Lt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),_(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:ne(g("string",e)).throw(z.invalidParameters),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=r.sent())?[2,n]:[3,4];case 3:return r.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,r.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),_(this,void 0,void 0,(function(){var n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return ne(g("string",e)).throw(z.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case hs.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case hs.UNREAD_MENTION_COUNT_ONLY:i=0;break;case hs.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=Zt.REQUEST_CHANNEL),_(this,void 0,void 0,(function(){var s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return s=new dn(o(o({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(s)];case 1:return i=c.sent(),a=i.as(pn),u=a.channels,l=a.token,this._dispatcher.dispatch(new rn({channels:u,source:r})),[2,{channels:u,token:l}]}}))}))},e.prototype.getMessageFromCache=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=Be),_(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=Be),_(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return _(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},e.prototype.getCachedMessageCountBetween=function(e,t,n,r){return _(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new er({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=Zt.REQUEST_CHANNEL_CHANGELOGS),_(this,void 0,void 0,(function(){var r,s,i,u,l,c;return f(this,(function(h){switch(h.label){case 0:return r=o(o({},Kt),t),ne((g("string",e)||g("number",e))&&Yt(r)).throw(z.invalidParameters),s=new un(a({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:r})),[4,this._requestQueue.send(s)];case 1:return i=h.sent(),u=i.as(ln),l=u.updatedChannels,c=u.deletedChannelUrls,l.length>0&&this._dispatcher.dispatch(new rn({channels:l,source:n})),c.length>0&&this._dispatcher.dispatch(new sn({channelUrls:c,source:n})),[2,u]}}))}))},e.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(s){switch(s.label){case 0:return t=o(o({},Jt),e),ne(Xt(t)).throw(z.invalidParameters),n=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return t=o(o({},$t),e),ne(function(e){return v(Bt,e.keys)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new mn({userId:r.userId,filter:t}),[4,s.send(i)];case 1:return[2,a.sent().as(vn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(En).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return _(this,void 0,void 0,(function(){var n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return n=o(o({},en),e),ne(function(e){return v("string",e.channelCustomTypesFilter,!0)&&t(kt,e.superChannelFilter)}(n)).throw(z.invalidParameters),r=Y.of(this._iid),s=r.sdkState,i=r.requestQueue,a=new yn({userId:s.userId,filter:n}),[4,i.send(a)];case 1:return u=l.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=o(o({},tn),e),ne(function(e){return g("string",e.channelUrl,!0)&&v(C,e.scheduledStatus,!0)&&t(y,e.messageTypeFilter)}(n)).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new Nn(n),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=Y.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=Y.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},e.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=Y.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),t.isPublic||(t.accessCode=null),n=new Tn(o({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),s=r.as(Un).channel,[4,this.upsertChannelsToCache([s])];case 2:return i.sent(),[2,s]}}))}))},e.prototype.markAsReadAll=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),ne(e-this._markAsReadAllLastSentAt>=1e3).throw(z.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Sn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=m(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:return t=Date.now(),ne(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(z.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Sn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:c.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=m(r),a=i.next();!a.done;a=i.next())o=a.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),s.push(o))}catch(e){u={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this.upsertChannelsToCache(s)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var sr,ir=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return _(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount=this._limit,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,h.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return r=o.sent(),h.debug("message background prev sync error",r),r instanceof z&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw r;case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new ir(d,(function(e){return _(i,void 0,void 0,(function(){var t,n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:o.sent(),h.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,oe.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(a=null===(i=this._metadata.range)||void 0===i?void 0:i.bottom)&&void 0!==a?a:e,{prevResultSize:0,nextResultSize:this._limit,replyType:ue.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},ee.SYNC_MESSAGE_BACKGROUND)];case 3:return n=o.sent(),this.extendRange(n),t.hasNext=n.length>=this._limit,t.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,6];case 5:throw r=o.sent(),h.debug("message background next sync error",r),r;case 6:return[2,t]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ur[t]||(ur[t]={}),ur[t][n.url]||(ur[t][n.url]=new e({_iid:t,channel:n})),ur[t][n.url].ref++,ur[t][n.url]},e.clear=function(e,t){ur[e]&&ur[e][t]&&(ur[e][t].close(),delete ur[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],p(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],p(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n,r;Y.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},e.prototype.pause=function(){Y.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ur[this._iid][this._channel.url])},e}(),cr={},hr=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=Y.of(this._iid),o=a.logger,u=a.sdkState,l=a.dispatcher;this._metadataKey=(s=u.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var c=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(u.userId,this._channel.url);this._sync=new ir(c,(function(){return _(r,void 0,void 0,(function(){var e,t,n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),o.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,oe.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:ue.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},ee.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,s=t.hasMore,i=t.token,e.hasNext=s,e.nextToken=i,(n.length>0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return a=l.sent(),o.debug("message changelog sync error",a),a instanceof z&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n})),cr[t][n.url].ref++,cr[t][n.url]},e.clear=function(e,t){cr[e]&&cr[e][t]&&(cr[e][t].close(),delete cr[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=Y.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){Y.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){Y.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),dr=function(t){function n(e){var n,r,s,i,o,u,l=this;return(l=t.call(this)||this).method=L.GET,l.path="".concat(le(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),l.params=a({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(s=e.messageType)&&void 0!==s?s:null,include_reactions:null===(i=e.includeReactions)||void 0===i||i,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u,include_poll_details:!0}),l}return e(n,t),n}(R),pr=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return W(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return W(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(k),_r=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){var r=_r(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:mr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},mr=function(e,t,n){switch(n){case De.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case De.CHRONOLOGICAL:return t.createdAt-e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},vr=function(e,t){return t instanceof D?e.findIndex((function(e){return e instanceof D&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},gr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Er=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr={},Cr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=Y.of(this._iid),u=o.logger,l=o.sdkState,c=o.dispatcher;this._metadataKey=(i=l.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(l.userId,this._channel.url);this._sync=new ir(h,(function(){return _(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,l;return f(this,(function(c){switch(c.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return c.sent(),u.debug("poll changelog sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!c.sent(),c.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=Y.of(this._iid).firstConnectedAt,this._metadata={token:n}),c.label=4;case 4:return c.trys.push([4,7,,10]),[4,Qe.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=c.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return c.sent(),[3,10];case 7:return o=c.sent(),u.debug("poll changelog sync error",o),o instanceof z&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:c.sent(),c.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return yr[t]||(yr[t]={}),yr[t][n.url]||(yr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),yr[t][n.url].ref++,yr[t][n.url]},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){Y.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){Y.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete yr[this._iid][this._channel.url])},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(sr||(sr={}));var Nr,br,Mr,Tr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;$((function(){return _(r,void 0,void 0,(function(){return f(this,(function(r){switch(e){case"local":this._onCacheResult(t,n);break;case"remote":this._onApiResult(t,n)}return[2]}))}))}))},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),Ur=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._iid=e,this._key="mc-".concat(de()),this.filter=null!=r?r:new je,this._channel=n,this._syncRange=new er({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||Be;var o=rr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=_r(e,a._channel);if(o>=0)switch($((function(){return _(a,void 0,void 0,(function(){var n,r;return f(this,(function(s){return n=new ar(t),this._channel=e[o],(null===(r=this._handler)||void 0===r?void 0:r.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case Zt.EVENT_CHANNEL_UPDATED:var u=!1;for(var l in a._messages){if((g=a._messages[l]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var c=parseInt(l);if(c>0){var h=a._messages.splice(0,c);a._removeMessagesFromView(h.map((function(e){return e.messageId})),ee.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),ee.EVENT_MESSAGE_OFFSET_UPDATED);break;case Zt.EVENT_CHANNEL_READ:var d=[];try{for(var p=m(a._messages),v=p.next();!v.done;v=p.next()){var g=v.value;if((C=a._readReceiptMap.get(g.messageId))>0)C!==a._channel.getUnreadMemberCount(g)&&d.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}d.length>0&&a._updateMessagesToView(d,ee.EVENT_MESSAGE_READ);break;case Zt.EVENT_CHANNEL_DELIVERED:d=[];try{for(var E=m(a._messages),y=E.next();!y.done;y=E.next()){var C;g=y.value;if((C=a._deliveryReceiptMap.get(g.messageId))>0)C!==a._channel.getUndeliveredMemberCount(g)&&d.push(g)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(i=E.return)&&i.call(E)}finally{if(s)throw s.error}}d.length>0&&a._updateMessagesToView(d,ee.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&$((function(){return _(a,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var l=u.value;l.channelUrl===a._channel.url&&(a.filter.match(l)?s.push(l):i.push(l.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(he(t)){if(s.length>0)switch(t){case ee.EVENT_MESSAGE_SENT_FAILED:case ee.EVENT_MESSAGE_SENT_SUCCESS:case ee.EVENT_MESSAGE_UPDATED:case ee.EVENT_MESSAGE_THREADINFO_UPDATED:case ee.EVENT_MESSAGE_REACTION_UPDATED:case ee.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case ee.EVENT_MESSAGE_SENT_PENDING:case ee.EVENT_MESSAGE_RECEIVED:case ee.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=Y.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&(this._backgroundSync=lr.of(this._iid,this._channel),this._backgroundSync.resume()),this._changelogSync=hr.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Cr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new ir(this._key,(function(e){return _(a,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:ee.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,d([],p(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this.viewTop0?(n=Math.max.apply(Math,d([],p(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:!(t.length>=this._limit&&this._hasNext)||this.viewBottom>n,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var l=Y.of(this._iid),c=l.dispatcher,h=l.logger;this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)h.debug("check huge gap"),a._checkHugeGap();else a._prevFill.stop(),a._nextFill.stop()}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],p(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ce.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ce.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],p(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],p(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=m(i),l=u.next();!l.done;l=u.next()){var c=l.value;if(t===ee.SYNC_MESSAGE_FILL){if(c.messageId>0){if((E=vr(this._messages,c))<0){vr(this._unsentMessages,c)<0&&a.push(c);var h=Er(this._messages,c);this._messages.splice(h,0,c)}this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c))}else if(c instanceof D){(E=vr(this._unsentMessages,c))<0&&vr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c))}}else if(c.messageId>0){if((E=vr(this._messages,c))<0){var v=vr(this._unsentMessages,c);v<0?a.push(c):(this._unsentMessages.splice(v,1),o.push(c));h=Er(this._messages,c);this._messages.splice(h,0,c)}else o.push(c),this._messages[E]=c;if(this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c)),c.updatedAt>0){var g=this._updateChildMessagesInView(c);o.push.apply(o,d([],p(g),!1))}}else if(c instanceof D){var E;(E=vr(this._unsentMessages,c))<0?vr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c)):(o.push(c),this._unsentMessages[E]=c)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}he(t)&&$((function(){return _(s,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),a.length>0&&this._handler.onMessagesAdded(e,this.channel,a),o.length>0&&this._handler.onMessagesUpdated(e,this.channel,o),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,l=gr(this._messages,u.messageId);if(l>=0){var c=this._messages[l];c&&c.applyPoll(u),i.push(c)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&he(t)&&$((function(){return _(s,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=gr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&he(t)&&$((function(){return _(n,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=gr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&he(t)&&$((function(){return _(n,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u,l=o.value;if(l.messageId>0)if((u=vr(this._messages,l))>=0)i.push(l),this._messages[u]=l;else{var c=vr(this._unsentMessages,l);if(c>=0){i.push(l),this._unsentMessages.splice(c,1);var h=Er(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof D)(u=vr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[u]=l)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return he(t)&&$((function(){return _(s,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(i.push(o._messages[t].messageId),o._messages.splice(t,1))},o=this;try{for(var u=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return he(t)&&i.length>0&&$((function(){return _(s,void 0,void 0,(function(){var e;return f(this,(function(n){return e=new or(t),i.length>0&&this._handler.onMessagesDeleted(e,this.channel,i),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return _(this,void 0,void 0,(function(){var t,n,s,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:return t=rr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=c.sent(),[3,3];case 2:s=[],c.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=c.sent(),[3,6];case 5:o=[],c.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(l in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[l].messageId)){a.splice(parseInt(l),1);break}return[2,d(d([],p(n),!1),p(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s,a=t.source,u=void 0===a?ee.REQUEST_MESSAGE:a,l=t.reverse,c=void 0!==l&&l;return _(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:return t=oe.of(this._iid),r>0||i>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,o(o({},this.filter),{isInclusive:!0,reverse:c,prevResultSize:r,nextResultSize:i,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=s.sent(),[3,3];case 2:n=[],s.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,u,l,c,h=this;return f(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,n=this._syncRange.bottom,r=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(s=rr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return i=m.sent(),[4,s.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return a=m.sent(),[4,pe((function(){return _(h,void 0,void 0,(function(){var s,u,l,c,h,m,v,g,E,y,C,N,b,M,T,U,S,A=this;return f(this,(function(I){switch(I.label){case 0:return s=Y.of(this._iid),u=s.dispatcher,l=s.requestQueue,c=new dr(o({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:i,nextStart:n,nextEnd:r,nextCount:a},this.filter)),[4,l.send(c)];case 1:return h=I.sent(),m=h.as(pr),v=m.isHugeGap,g=m.prevMessages,E=void 0===g?[]:g,y=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?$((function(){return _(A,void 0,void 0,(function(){return f(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=y,this._hasNext=b,M=this.viewTop,T=this.viewBottom,U=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,M],p(E.map((function(e){return e.createdAt}))),!1)),S=Math.max.apply(Math,d([0,T],p(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new w({messages:E,source:ee.SYNC_MESSAGE_FILL})),u.dispatch(new w({messages:N,source:ee.SYNC_MESSAGE_FILL})),this._syncRange.extends(U,S),MS&&this._nextFill.start(S)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:u,nextLimit:u,source:ee.SYNC_MESSAGE_FILL})];case 5:(l=m.sent()).length>0&&((c=this._syncRange).extends.apply(c,d([],p(l.map((function(e){return e.createdAt}))),!1)),l.length0?[2,!0]:[2,!1]}}))}))},e.prototype.initialize=function(e){var t=this,n=new Tr;this._messages=[],this._unsentMessages=[],this._syncRange=new er({}),this._hasNext=!0,this._hasPrevious=!0;var r=Math.floor(this._limit/2);if(e===sr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return _(t,void 0,void 0,(function(){var t;return f(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,ee.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Z(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0}).then((function(e){var s;t._messages=[];var i=t._filterUnderOffsetMessage(e);i.length0&&((s=t._syncRange).extends.apply(s,d([],p(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,ee.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(Z(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return _(this,void 0,void 0,(function(){var e,t,n,r=this;return f(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return _(r,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,b((function(){return _(r,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[a.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],p(t.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,ee.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,d([],p(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,ee.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return _(this,void 0,void 0,(function(){var t,n,r,s=this;return f(this,(function(i){switch(i.label){case 0:return t=this.viewBottom,n=[],[4,b((function(){return _(s,void 0,void 0,(function(){var e;return f(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,b((function(){return _(s,void 0,void 0,(function(){var e,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[a.sent()]),this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],p(n.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,ee.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],p(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,ee.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return _(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return[4,rr.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n;Y.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var r=rr.of(this._iid);r.unsubscribeGroupChannelEvent(this._key),r.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ar={hidePreviousMessages:!1,allowAutoUnhide:!0},Ir=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,l=e.nicknameStartsWithFilter,c=e.operatorFilter;return(n=t.call(this)||this).method=L.GET,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:l,operator_filter:c,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(R),wr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new Gt(e,t)}))),r}return e(n,t),n}(k);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Nr||(Nr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(br||(br={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Mr||(Mr={}));var Dr=function(n){function r(e,t,r){var s,i,a,o,l=this;return(l=n.call(this,e,t,u.GROUP,r)||this).mutedMemberFilter=Nr.ALL,l.memberStateFilter=Mr.ALL,l.nicknameStartsWithFilter=null,l.operatorFilter=Ft.ALL,l.order=br.MEMBER_NICKNAME_ALPHABETICAL,l.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Nr.ALL,l.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Mr.ALL,l.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,l.order=null!==(o=r.order)&&void 0!==o?o:br.MEMBER_NICKNAME_ALPHABETICAL,l}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(Nr,this.mutedMemberFilter)&&t(Mr,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(Ft,this.operatorFilter)&&t(br,this.order)},r.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Y.of(this._iid).requestQueue,t=new Ir(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(wr),s=r.members,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(_e),Lr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),Pr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.channel.myMemberState=Lt.JOINED,r}return e(n,t),n}(k),Rr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,l=e.coverImage,c=e.accessCode,h=e.name,d=e.data,p=e.customType,_=e.operatorUserIds,f=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n.params=a({is_distinct:s,is_public:i,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:l,access_code:c,operator_ids:_,message_survival_seconds:f}),n}return e(n,t),n}(R),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var Fr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(P,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(R),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(k),Vr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(R),Gr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),qr=o(o({},mt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Br=o(o({},gt),{scheduledAt:null}),Qr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=null;e.mentionType===fe.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return r.method=L.PUT,r.path="".concat(le(i),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),r.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:me.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return ve.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ge.payloadify(e)})),apple_critical_alert_options:Ee.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),r}return e(n,t),n}(R),jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new X(e,n),r}return e(n,t),n}(k),zr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=null;e.mentionType===fe.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return r.method=L.PUT,r.path="".concat(le(i),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),r.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:me.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ge.payloadify(e)})),apple_critical_alert_options:Ee.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),r}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new J(e,n),r}e(n,t)}(k);var Wr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=L.DELETE,n.path="".concat(le(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(R),Kr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=L.POST,n.path="".concat(le(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(R),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(P,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(R),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(k),Xr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R),Zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(k),$r=function(t){function n(e){var n=e.pollId,r=e.title,s=e.data,i=e.allowUserSuggestion,a=e.allowMultipleVotes,o=e.closeAt,u=t.call(this)||this;return u.method=L.PUT,u.path="".concat(Ce,"/").concat(encodeURIComponent(n)),u.params={title:r,data:s,allow_user_suggestion:i,allow_multiple_votes:a,close_at:o},u}return e(n,t),n}(R),es=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),ts=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=L.DELETE,r.path="".concat(Ce,"/").concat(encodeURIComponent(n)),r}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var ns=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=L.PUT,r.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/close"),r}return e(n,t),n}(R),rs=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),ss=function(t){function n(e){var n=e.channelUrl,r=e.channelType,s=e.pollId,i=e.optionText,a=t.call(this)||this;return a.method=L.POST,a.path="".concat(Ce,"/").concat(encodeURIComponent(s),"/options"),a.params={channel_url:n,channel_type:r,text:i},a}return e(n,t),n}(R),is=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),as=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=e.optionText,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i.params={text:s},i}return e(n,t),n}(R),os=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),us=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=t.call(this)||this;return s.method=L.DELETE,s.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var ls=function(t){function n(e){var n=e.reqId,r=e.channelType,s=e.channelUrl,i=e.pollId,o=e.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:a({req_id:n,channel_type:r===u.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:i,option_ids:o})})||this}return e(n,t),n}(V),cs=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=L.POST,i.path="".concat(le(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var hs,ds,ps,_s=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=L.DELETE,i.path="".concat(le(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k),function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}(hs||(hs={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(ds||(ds={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ps||(ps={}));var fs,ms=function(r){function s(e,s){var i,a,c,h,_,f,m,v,E,y,C,N,b,M,T,U,S,A,I,w=this;return(w=r.call(this,e,s)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ps.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=Lt.NONE,w.myRole=n.NONE,w.myMutedState=ds.UNMUTED,w.myLastRead=0,w.myCountPreference=hs.ALL,w.myPushTriggerOption=$e.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w.channelType=u.GROUP,w.isDistinct=null!==(a=s.is_distinct)&&void 0!==a&&a,w.isSuper=null!==(c=s.is_super)&&void 0!==c&&c,w.isBroadcast=null!==(h=s.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(_=s.is_exclusive)&&void 0!==_&&_,w.isPublic=null!==(f=s.is_public)&&void 0!==f&&f,w.isDiscoverable=null!==(m=s.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=s.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(E=s.is_push_enabled)&&void 0!==E&&E,Array.isArray(s.members)&&(i=w.members).push.apply(i,d([],p(s.members.map((function(e){return new Gt(w._iid,e)}))),!1)),w.memberCount=null!==(y=s.member_count)&&void 0!==y?y:0,w.joinedMemberCount=null!==(C=s.joined_member_count)&&void 0!==C?C:0,w.hiddenState=t(ps,s.hidden_state)?s.hidden_state:ps.UNHIDDEN,w.messageOffsetTimestamp=null!==(N=s.ts_message_offset)&&void 0!==N?N:0,w.messageSurvivalSeconds=null!==(b=s.message_survival_seconds)&&void 0!==b?b:-1,w.lastMessage=s.last_message?W(w._iid,o({channel_type:w.channelType},s.last_message)):null,s.read_receipt&&Object.keys(s.read_receipt).forEach((function(e){g("number",s.read_receipt[e])&&w._updateUnreadMemberState(e,s.read_receipt[e])})),s.delivery_receipt&&Object.keys(s.delivery_receipt).forEach((function(e){g("number",s.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,s.delivery_receipt[e])})),w.myMemberState=t(Lt,s.member_state)?s.member_state:Lt.NONE,w.myRole=t(n,s.my_role)?s.my_role:n.NONE,t(ds,s.is_muted)?w.myMutedState=s.is_muted:g("boolean",s.is_muted)?w.myMutedState=s.is_muted?ds.MUTED:ds.UNMUTED:w.myMutedState=ds.UNMUTED,w.myCountPreference=t(hs,s.count_preference)?s.count_preference:hs.ALL,w.myPushTriggerOption=t($e,s.push_trigger_option)?s.push_trigger_option:$e.ALL,w.myLastRead=null!==(M=s.user_last_read)&&void 0!==M?M:0,w.inviter=s.inviter?new l(w._iid,s.inviter):null,w.invitedAt=null!==(T=s.invited_at)&&void 0!==T?T:0,w.joinedAt=null!==(U=s.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(S=s.unread_message_count)&&void 0!==S?S:0,null!==(A=s.unread_mention_count)&&void 0!==A?A:0),w.pinnedMessageIds=null!==(I=s.pinned_message_ids)&&void 0!==I?I:[],w.lastPinnedMessage=s.latest_pinned_message?W(w._iid,o({channel_type:w.channelType},s.latest_pinned_message)):null,w}return e(s,r),Object.defineProperty(s.prototype,"isHidden",{get:function(){return this.hiddenState!==ps.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=p(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=p(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),s.payloadify=function(e){return e?a(o(o({},r.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return Gt.payloadify(e)})),last_message:be(e.lastMessage),inviter:e.inviter?l.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:be(e.lastPinnedMessage)})):null},s.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof D&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===hs.ALL||this.myCountPreference===hs.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=Y.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===hs.ALL||this.myCountPreference===hs.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},s.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},s.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},s.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},s.prototype.isReadMessage=function(e){var t=Y.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},s.prototype.serialize=function(){var e=this;return Q(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},s.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Ur(this._iid,o({channel:this},e))},s.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Dr(this._iid,this.url,e)},s.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var r=this.members[n];r.state===Lt.JOINED&&(e.state=r.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},s.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof Gt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},s.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof D&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=Y.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=m(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Lt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},s.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=Y.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof D?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},s.prototype.refresh=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(hn).channel,n.dispatch(new rn({channels:[i],source:Zt.REQUEST_CHANNEL})),[2,i]}}))}))},s.prototype.freeze=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.prototype.freeze.call(this)];case 1:return e.sent(),Y.of(this._iid).dispatcher.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},s.prototype.unfreeze=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.prototype.unfreeze.call(this)];case 1:return e.sent(),Y.of(this._iid).dispatcher.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},s.prototype.updateChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return t=o(o({},Sr),e),ne(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.requestQueue,i=new Rr(o({channelUrl:this.url},t)),[4,s.send(i)];case 1:return a=l.sent(),u=a.as(kr).channel,r.dispatch(new rn({channels:[u],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.invite=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){return ne(e.every((function(e){return e instanceof l}))).throw(z.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},s.prototype.inviteWithUserIds=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return ne(v("string",e)).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Pn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Rn).channel,n.dispatch(new rn({channels:[a],source:Zt.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},s.prototype.join=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return ne(g("string",e)||null===e).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new An({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=Lt.JOINED,n.dispatch(new rn({channels:[o],source:Zt.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},s.prototype.leave=function(e){return void 0===e&&(e=!1),_(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=Y.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Dn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=Lt.NONE,[2]}}))}))},s.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return ne(g("string",e)||null===e).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Lr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Pr).channel).myMemberState=this.myMemberState=Lt.JOINED,n.dispatch(new rn({channels:[o],source:Zt.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},s.prototype.declineInvitation=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new On({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=Lt.NONE,[2,this]}}))}))},s.prototype.sendUserMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){t.hiddenState===ps.HIDDEN_ALLOW_AUTO_UNHIDE&&(t.hiddenState=ps.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),rr.of(t._iid).handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateUserMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return n=Y.of(this._iid).dispatcher,[4,r.prototype.updateUserMessage.call(this,e,t)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),n.dispatch(new rn({channels:[this],source:a?Zt.EVENT_PINNED_MESSAGE_UPDATED:Zt.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),n.dispatch(new w({messages:[s],source:ee.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendUserMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.sendFileMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateFileMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return n=Y.of(this._iid).dispatcher,[4,r.prototype.updateFileMessage.call(this,e,t)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),n.dispatch(new rn({channels:[this],source:a?Zt.EVENT_PINNED_MESSAGE_UPDATED:Zt.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),n.dispatch(new w({messages:[s],source:ee.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendFileMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.deleteMessage=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,r.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof D&&Y.of(this._iid).dispatcher.dispatch(new A({reqId:e.reqId,source:ee.EVENT_MESSAGE_DELETED})),[2]}}))}))},s.prototype.hide=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return t=o(o({},Ar),e),ne(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Bn(o({channelUrl:this.url,userId:s.userId},t)),[4,i.send(a)];case 1:return u=c.sent(),l=u.as(Qn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ps.HIDDEN_ALLOW_AUTO_UNHIDE:ps.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),l&&(this.messageOffsetTimestamp=l),r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},s.prototype.unhide=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ps.UNHIDDEN,t.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},s.prototype.delete=function(){return _(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=Y.of(this._iid).requestQueue,t=new Or({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.markAsRead=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(Hn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_READ})),[2]}}))}))},s.prototype.markAsDelivered=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.startTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){return e=Y.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.endTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){return e=Y.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Kn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.createScheduledUserMessage=function(e){e=o(o({},We),e),ne(Ke(e)).throw(z.invalidParameters);var t=new Te;return this._createScheduledUserMessage(e,t),t},s.prototype.updateScheduledUserMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=o(o({},Br),t),ne(function(e){return Et(e)&&g("number",e.scheduledAt,!0)}(n)).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new zr(o({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(Ct).message]}}))}))},s.prototype.createScheduledFileMessage=function(e){var t=this;e=o(o({},Ye),e),ne(Je(e)).throw(z.invalidParameters);var n=Date.now(),r=this._generateRequestId(),s=new Te;return Me(Nt).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);$((function(){return _(t,void 0,void 0,(function(){return f(this,(function(e){return[2,s._trigger(null,i)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,s,r,n)})):this._createScheduledFileMessage(e,s,r,n),s},s.prototype.updateScheduledFileMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return n=o(o({},qr),t),ne(function(e){return vt(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(z.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Qr(o({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,Y.of(this._iid).requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(jr).message]}}))}))},s.prototype.cancelScheduledMessage=function(e){return _(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Wr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,Y.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.sendScheduledMessageNow=function(e){return _(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Kr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,Y.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.getMyPushTriggerOption=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Zr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},s.prototype.setMyPushTriggerOption=function(e){return _(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return ne(t($e,e)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Yr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Jr).pushTriggerOption,this.myPushTriggerOption=u,r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.setMyCountPreference=function(e){return _(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return ne(t(hs,e)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Fr({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Hr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.resetMyHistory=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Vr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Gr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},s.prototype.updatePoll=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return ne(g("number",e)&&function(e){return g("string",e.title,!0)&&ye(e.data)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new $r(o({pollId:e},t)),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(es).poll]}}))}))},s.prototype.deletePoll=function(e){return _(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(s){switch(s.label){case 0:return t=g("number",e),ne(t).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new ts({pollId:e}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=g("number",e),ne(t).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new ns({pollId:e}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(rs).poll]}}))}))},s.prototype.addPollOption=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),ne(n).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(is).poll]}}))}))},s.prototype.updatePollOption=function(e,t,n){return _(this,void 0,void 0,(function(){var r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),ne(r).throw(z.invalidParameters),s=Y.of(this._iid).requestQueue,i=new as({pollId:e,pollOptionId:t,optionText:n}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(os).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return n=g("number",e)&&g("number",t),ne(n).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new us({pollId:e,pollOptionId:t}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return _(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return n=g("number",e)&&v("number",t),ne(n).throw(z.invalidParameters),r=Y.of(this._iid),s=r.requestQueue,i=r.dispatcher,a=new ls({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(a)];case 1:return o=l.sent(),u=o.as(Zn).event,i.dispatch(new T({event:u,source:ee.EVENT_POLL_VOTED})),[2,u]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("number",e)).throw(z.invalidParameters),[4,Qe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("string",e,!0)),[4,Qe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=et),new Xe(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=tt),new Ze(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return ne(g("number",e)&&e>0).throw(z.invalidParameters),t=Y.of(this._iid).requestQueue,n=new cs({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return ne(g("number",e)&&e>0).throw(z.invalidParameters),t=Y.of(this._iid).requestQueue,n=new _s({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},s.prototype._uploadFileAndUpdateParams=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l,c,h;return f(this,(function(d){switch(d.label){case 0:return E(e.file)?(t=Y.of(this._iid).requestQueue,n=new Se({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Ue),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,l=void 0===u?e.thumbnailSizes:u,c=s.requireAuth,h=void 0!==c&&c,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=l,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},s}(yt),vs={},gs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=Y.of(this._iid),o=a.sdkState,u=a.dispatcher,l=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var c=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new ir(c,(function(){return _(s,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(a.sent(),l.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:De.CHRONOLOGICAL},this._limit,Zt.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,d([],p(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,l.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),l.debug("channel background sync error",s),s instanceof z&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return vs[t]||(vs[t]=new e({_iid:t})),vs[t].ref++,vs[t]},e.clear=function(e){vs[e]&&(vs[e].close(),delete vs[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t;Y.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},e.prototype.pause=function(){Y.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete vs[this._iid])},e}(),Es={},ys=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=Y.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new ir(u,(function(){return _(n,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),i.debug("channel changelog sync from",this._metadata.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},Zt.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),i.debug("channel changelog sync error",s),s instanceof z&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Es[t]||(Es[t]=new e({_iid:t})),Es[t].ref++,Es[t]},e.clear=function(e){Es[e]&&(Es[e].close(),delete Es[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=Y.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Es[this._iid])},e}(),Cs=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(de()),this.filter=null!=n?n:new Qt,this.order=null!=r?r:De.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Pe;var a=Y.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&(this._backgroundSync=gs.of(e),this._backgroundSync.resume()),this._changelogSync=ys.of(e),this._changelogSync.resume(),rr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)},onRemove:function(e,t){i._removeChannelsFromView(e,t)}})}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i=this;void 0===n&&(n=!1);var a=[],o=[];try{for(var u=m(e),l=u.next();!l.done;l=u.next()){var c=l.value,h=fr(this.channels,c,this.order),d=h.place;if(h.contains)switch(o.push(c),t){case Zt.EVENT_CHANNEL_UPDATED:case Zt.EVENT_MESSAGE_RECEIVED:this.channels.splice(d,1);var p=fr(this.channels,c,this.order).place;this.channels.splice(p,0,c);break;default:this.channels[d]=c}else d===this.channels.length?(n||!this._backgroundSync||this._backgroundSync.completed)&&(a.push(c),this.channels.push(c)):(a.push(c),this.channels.splice(d,0,c))}}catch(e){r={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}nn(t)&&$((function(){return _(i,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=new ar(t),a.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,a),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,o),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return nn(t)&&i.length>0&&$((function(){return _(s,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return _(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case De.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case De.CHRONOLOGICAL:return e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return _(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return[4,rr.of(this._iid).getMyGroupChannels(this._token,o(o({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype.loadMore=function(){return _(this,void 0,void 0,(function(){var e,t=this;return f(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,b((function(){return _(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalChannels()];case 1:return e=t.sent(),[2]}}))}))}))]):[3,3];case 1:return n.sent(),[4,b((function(){return _(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._getRemoteChannels()];case 1:return e=t.sent(),[2]}}))}))}))];case 2:return n.sent(),this._addChannelsToView(e,Zt.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),rr.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Ns=function(t){function n(e){var n=this,r=e.token,s=e.limit,i=e.order,o=e.includeEmpty,u=e.membershipFilter,l=e.channelNameContainsFilter,c=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,p=e.superChannelFilter,_=e.metadataOrderKeyFilter,f=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,E=e.includeMetaData;return(n=t.call(this)||this).method=L.GET,n.path=x,n.params=a({token:r,limit:s,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Pt.PUBLIC,public_membership_mode:u,name_contains:l,channel_urls:c,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:_,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:E}),n}return e(n,t),n}(R),bs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new ms(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(k);!function(e){e.ALL="all",e.JOINED="joined"}(fs||(fs={}));var Ms=function(n){function r(e,t){var r,s,i,a,o,u,l,c,h,d,p,_,f,m,v=this;return(v=n.call(this,e,t)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=fs.ALL,v.superChannelFilter=kt.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=nt.CHRONOLOGICAL,v.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:null,v.membershipFilter=null!==(c=t.membershipFilter)&&void 0!==c?c:fs.ALL,v.superChannelFilter=null!==(h=t.superChannelFilter)&&void 0!==h?h:kt.ALL,v.metadataKey=null!==(d=t.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=t.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(_=t.metadataOrderKeyFilter)&&void 0!==_?_:null,v.metadataValueStartsWith=null!==(f=t.metadataValueStartsWith)&&void 0!==f?f:null,v.order=null!==(m=t.order)&&void 0!==m?m:nt.CHRONOLOGICAL,v}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&t(fs,this.membershipFilter)&&t(kt,this.superChannelFilter)&&t(nt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=Y.of(this._iid),n=t.requestQueue,r=t.dispatcher,s=new Ns(o(o({},this),{token:this._token})),[4,n.send(s)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(bs),u=a.channels,l=a.token,this._token=l,this._hasNext=!!l,r.dispatch(new rn({channels:u,source:Zt.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),Ts=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=Ae,e.onUserLeft=Ae,e.onUserReceivedInvitation=Ae,e.onUserDeclinedInvitation=Ae,e.onChannelHidden=Ae,e.onUnreadMemberStatusUpdated=Ae,e.onUndeliveredMemberStatusUpdated=Ae,e.onTypingStatusUpdated=Ae,e.onPollUpdated=Ae,e.onPollVoted=Ae,e.onPollDeleted=Ae,e.onPinnedMessageUpdated=Ae,e}return e(n,t),n}(Dt)),Us=function(t){function n(e){var n=this,r=e.token,s=e.limit,i=e.order,o=e.reverse,u=e.channelUrl,l=e.messageTypeFilter,c=e.scheduledStatus;return(n=t.call(this)||this).method=L.GET,n.path="".concat(F),n.params=a({limit:s,reverse:o,channel_url:u,order:i,status:c}),r&&(n.params.token=r),l&&(n.params.message_type=l),n}return e(n,t),n}(R),Ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return W(e,t)})),r}return e(n,t),n}(k),As=function(n){function r(e,t){var r,s,i,a,o,u=this;return(u=n.call(this,e,t)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=y.ALL,u.channelUrl=null!==(r=t.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=t.order)&&void 0!==s?s:null,u.reverse=null!==(i=t.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=t.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=t.messageTypeFilter)&&void 0!==o?o:y.ALL,u}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(t(rt,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(C,this.scheduledStatus)||null===this.scheduledStatus)&&t(y,this.messageTypeFilter)},r.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Y.of(this._iid).requestQueue,t=new Us(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Ss),s=r.scheduledMessages,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),Is=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new rr(e,{sdkState:r,cacheContext:l,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Cs(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new $n(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Ms(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new As(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){ne(g("string",e)&&t instanceof Ts).throw(z.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){ne(g("string",e)).throw(z.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){return ne(g("string",e)).throw(z.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){return ne(g("string",e)).throw(z.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=o(o({},Kt),t),ne(g("string",e)&&Yt(n)).throw(z.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=o(o({},Kt),t),ne(g("number",e)&&Yt(n)).throw(z.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},Jt),e),ne(Xt(t)).throw(z.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,s,i){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===s&&(s=""),void 0===i&&(i=""),_(this,void 0,void 0,(function(){var a;return f(this,(function(u){return a=o(o({},zt),{invitedUserIds:e,isDistinct:t,name:n,data:s,customType:i}),"string"==typeof r?a.coverUrl=r:a.coverImage=r,[2,this.createChannel(a)]}))}))},n.prototype.markAsReadAll=function(){return _(this,void 0,void 0,(function(){return f(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){return ne(v("string",e)).throw(z.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("string",e)).throw(z.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(Ie);export{hs as CountPreference,ms as GroupChannel,Cs as GroupChannelCollection,ar as GroupChannelEventContext,Zt as GroupChannelEventSource,Qt as GroupChannelFilter,Ts as GroupChannelHandler,$n as GroupChannelListQuery,Is as GroupChannelModule,Vt as GroupChannelSearchField,xt as HiddenChannelFilter,ps as HiddenState,Gt as Member,br as MemberListOrder,Dr as MemberListQuery,Lt as MemberState,Mr as MemberStateFilter,fs as MembershipFilter,Ur as MessageCollection,Tr as MessageCollectionInitHandler,sr as MessageCollectionInitPolicy,or as MessageEventContext,Nr as MutedMemberFilter,ds as MutedState,Rt as MyMemberStateFilter,Ft as OperatorFilter,Pt as PublicChannelFilter,Ms as PublicGroupChannelListQuery,Ht as QueryType,qt as ReadStatus,As as ScheduledMessageListQuery,kt as SuperChannelFilter,Ot as UnreadChannelFilter,Bt as UnreadItemKey}; +import{_ as e,h as t,af as n,e as a,l as o,C as u,U as l,I as c,aF as h,Y as d,Z as _,j as p,k as f,x as m,T as v,i as g,q as E,s as y,aG as C,B as N,ac as b,aH as T,aI as U,m as S,aJ as A,aK as I,L as w,w as D,A as L,N as P,b as R,c as k,aL as O,aM as x,aN as F,aO as H,an as V,W as q,aP as B,aQ as Q,X as j,S as z,aR as W,a4 as K,V as Y,y as J,F as X,ax as Z,a5 as $,M as ee,aS as te,u as ne,aT as re,E as se,H as ie,J as ae,z as oe,R as ue,g as le,D as ce,aU as he,aa as de,aV as _e,n as pe,ah as fe,ar as me,as as ve,ai as ge,ak as Ee,f as ye,a as Ce,P as Ne,aW as be,aw as Me,ay as Te,aX as Ue,aY as Se,r as Ae,o as Ie}from"./__bundle-7175498d.js";export{M as MessageEventSource,aG as ScheduledStatus}from"./__bundle-7175498d.js";import{N as we,G as De,g as Le,D as Pe,a as Re,P as ke,b as Oe,U as xe,M as Fe,A as He,c as Ve,d as Ge,e as qe,f as Be,h as Qe,i as je,j as ze,S as We,v as Ke,k as Ye,l as Je,m as Xe,n as Ze,o as $e,p as et,q as tt,r as nt,s as rt}from"./__bundle-c01340eb.js";export{G as GroupChannelListOrder,i as MessageFilter,r as PublicGroupChannelListOrder,s as ScheduledMessageListOrder}from"./__bundle-c01340eb.js";import{f as st,j as it,k as at,l as ot,m as ut,n as lt,o as ct,p as ht,D as dt,q as _t,r as pt,t as ft,u as mt,w as vt,x as gt,y as Et,e as yt,C as Ct,z as Nt}from"./__bundle-d8d501e8.js";import{C as bt,a as Mt,O as Tt,M as Ut,T as St,R as At,U as It,A as wt,B as Dt}from"./__bundle-c20e72f4.js";var Lt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Lt||(Lt={}));var Pt,Rt,kt,Ot,xt,Ft,Ht,Vt,Gt=function(r){function s(e,s){var i=r.call(this,e,s)||this;return i.state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=t(Lt,s.state)?s.state:null,i.role=t(n,s.role)?s.role:null,s.hasOwnProperty("is_muted")&&(i.isMuted=s.is_muted),s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),s.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return e(s,r),s.payloadify=function(e){return e?a(o(o({},r.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null},s}(st),qt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:u.GROUP,i.reader=new l(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Pt||(Pt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Rt||(Rt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(kt||(kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(xt||(xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Ft||(Ft={})),function(e){e.AND="AND",e.OR="OR"}(Ht||(Ht={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Vt||(Vt={}));var Bt,Qt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Rt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=kt.ALL,this.publicChannelFilter=Pt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ot.ALL,this.hiddenChannelFilter=xt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=Ht.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Vt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Vt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case Ht.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case Ht.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!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 _=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!=_})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Rt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Rt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Rt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Rt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case xt.HIDDEN:if(!e.isHidden)return!1;break;case xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ot.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Pt.PUBLIC:if(!e.isPublic)return!1;break;case Pt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case kt.SUPER:if(!e.isSuper)return!1;break;case kt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),jt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(we):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),o(o({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return rr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case De.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:n=[],c.label=1;case 1:c.trys.push([1,6,7,8]),r=m(t),s=r.next(),c.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=c.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),c.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:c.sent(),c.label=10;case 10:return[2]}}))}))},n}(c),zt={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Wt=function(e){return v("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Kt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Yt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Jt={myMemberStateFilter:Rt.ALL},Xt=function(e){return t(Rt,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Bt||(Bt={}));var Zt,$t={keys:[]},en={channelCustomTypesFilter:null,superChannelFilter:kt.ALL},tn={channelUrl:null,scheduledStatus:null,messageTypeFilter:y.ALL};!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(Zt||(Zt={}));var nn=function(e){return e.startsWith("EVENT_")||e===Zt.SYNC_CHANNEL_BACKGROUND||e===Zt.SYNC_CHANNEL_CHANGELOGS},rn=function(t){function n(e){var n=e.channels,r=e.source,s=t.call(this)||this;return s.channels=n,s.source=r,s}return e(n,t),n}(N),sn=function(t){function n(e){var n=e.channelUrls,r=e.source,s=t.call(this)||this;return s.channelUrls=n,s.source=r,s}return e(n,t),n}(N),an=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return p(i,void 0,void 0,(function(){var s,i,a,o,u,l,c,h,d,_,v,g=this;return f(this,(function(E){switch(E.label){case 0:if(!(e instanceof rn))return[3,10];s=e.channels,d=e.source,i=s.filter((function(e){return e instanceof ms})),a=t.filterOffsetChanged(i),E.label=1;case 1:E.trys.push([1,6,7,8]),o=m(a),u=o.next(),E.label=2;case 2:return u.done?[3,5]:(l=u.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:E.sent(),E.label=4;case 4:return u=o.next(),[3,2];case 5:return[3,8];case 6:return c=E.sent(),_={error:c},[3,8];case 7:try{u&&!u.done&&(v=o.return)&&v.call(o)}finally{if(_)throw _.error}return[7];case 8:return[4,t.upsert(i)];case 9:return E.sent(),this._broadcastUpdateEvent(i,d),[3,15];case 10:return e instanceof sn?(h=e.channelUrls,d=e.source,[4,t.remove(h)]):[3,13];case 11:return E.sent(),[4,b((function(){return p(g,void 0,void 0,(function(){var e,t,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=m(h),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return E.sent(),this._broadcastRemoveEvent(h,d),[3,15];case 13:return e instanceof Re?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:E.sent(),E.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return p(a,void 0,void 0,(function(){var t,s,i,a,o,u,l,c,h,d,_,m,v,g=this;return f(this,(function(E){switch(E.label){case 0:return e instanceof w?(t=e.messages,m=e.source,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof D?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:E.sent(),this._broadcastUpdateEvent(s,m),E.label=2;case 2:return i.length>0?[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:E.sent(),this._broadcastUpdateEvent(i,m),E.label=4;case 4:return[3,21];case 5:return e instanceof I?(a=e.messageIds,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return E.sent(),this._broadcastRemoveEvent(a,m),[3,21];case 7:return e instanceof A?(o=e.reqId,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return E.sent(),this._broadcastRemoveUnsentEvent(o,m),[3,21];case 9:return e instanceof S?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(l=u.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(c=E.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:E.sent(),E.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof U?(h=e.event,m=e.source,[4,n.get(h.messageId)]):[3,17];case 14:return(d=E.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(h)?[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:E.sent(),E.label=16;case 16:return this._broadcastPollUpdateEvent(h,m),[3,21];case 17:return e instanceof T?(_=e.event,m=e.source,[4,n.get(_.messageId)]):[3,21];case 18:return(v=E.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(_)?[4,b((function(){return p(g,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:E.sent(),E.label=20;case 20:this._broadcastPollVoteEvent(_,m),E.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(t){function n(e){var n=e.userId,r=e.ts,s=e.token,i=e.filter,u=t.call(this)||this,l=o(o({},Kt),i),c=l.customTypes,h=l.includeEmpty,d=l.includeFrozen;return u.method=L.GET,u.path="".concat(P,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=a({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:r>0?r:null,token:s,custom_types:c,show_empty:h,show_frozen:d}),u}return e(n,t),n}(R),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new ms(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(k),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=L.GET,s.path="".concat(r?O:x,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(R),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new ms(e,n),r}return e(n,t),n}(k),dn=function(t){function n(e){var n=this,r=e.userId,s=e.token,i=e.limit,o=e.order,u=e.includeEmpty,l=e.myMemberStateFilter,c=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,E=e.customTypeStartsWithFilter,y=e.hiddenChannelFilter,C=e.metadataOrderKeyFilter,N=e.metadataKey,b=e.metadataValues,M=e.metadataValueStartsWith,T=e.includeFrozen,U=e.includeMetaData,S=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=L.GET,n.path="".concat(P,"/").concat(encodeURIComponent(r),"/my_group_channels"),n.params=a({token:s,limit:i,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:l,super_mode:c,public_mode:h,unread_filter:d,members_nickname_contains:_,members_nickname_startswith:p,members_nickname:f,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:E,hidden_mode:y,metadata_order_key:C,metadata_key:N,metadata_values:b,metadata_value_startswith:M,show_frozen:T,show_metadata:U}),S&&S.query&&S.fields&&(n.params.search_query=S.query,n.params.search_fields=S.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(n.params.members_include_in=A.userIds,n.params.query_type=A.queryType.toUpperCase()):n.params.members_exactly_in=A.userIds),n}return e(n,t),n}(R),_n=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new ms(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(k),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Rt.ALL},s}return e(n,t),n}(R),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(k),mn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(R),vn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Bt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Bt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Bt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Bt.SUPER_INVITATION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Bt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Bt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(k),gn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=L.GET,r.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(R),En=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(k),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:kt.ALL,custom_types:i},s}return e(n,t),n}(R),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(k),Nn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=L.GET,i.path="".concat(F,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(R),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(k),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case C.PENDING:t.push(H.PENDING);break;case C.SENT:t.push(H.IN_QUEUE),t.push(H.SENT);break;case C.CANCELED:t.push(H.CANCELED);break;case C.FAILED:t.push(H.FAILED)}})),t}},Tn=function(t){function n(e){var n=this,r=e.userId,s=e.channelUrl,i=e.coverUrl,o=e.coverImage,u=e.isDistinct,l=e.isSuper,c=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,E=e.name,y=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(n=t.call(this)||this).method=L.POST,n.path=x,n.params=a({user_ids:d([r],_(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:i,cover_file:o,is_distinct:u,is_super:l,is_broadcast:c,is_exclusive:p,is_public:h,is_discoverable:f,strict:m,is_ephemeral:v,access_code:g,name:E,data:y,custom_type:C,operator_ids:M,message_survival_seconds:N}),n}return e(n,t),n}(R),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(k),Sn=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=L.PUT,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var An=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),wn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u,c=i.users,h=void 0===c?null:c;return s.memberCount=o,s.joinedMemberCount=l,s.members=Array.isArray(h)?h.map((function(t){return new Gt(e,t)})):[new Gt(e,r.data)],s}return e(n,t),n}(bt),Dn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var Ln=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=l,s.member=new Gt(s._iid,r.data),s}return e(n,t),n}(bt),Pn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=L.POST,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(R),Rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),kn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,_=i.invitees,p=void 0===_?[]:_;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitees=p.map((function(t){return new Gt(e,t)})),s}return e(n,t),n}(bt),On=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.channel.myMemberState=Lt.NONE,r}e(n,t)}(k);var xn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,_=i.invitee,p=void 0===_?null:_;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitee=p?new Gt(e,p):null,s}return e(n,t),n}(bt),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(V),Hn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new qt(e,r),s}return e(n,t),n}(q),Vn=function(t){function n(e){var n=e.channelUrl,r=e.userId,s=t.call(this)||this;return(s=t.call(this)||this).method=L.PUT,s.path="".concat(x,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),s.params=a({userId:r}),s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var Gn,qn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(q),Bn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(R),Qn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(q),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Wn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new l(e,r.data),s}return e(n,t),n}(q),Kn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new l(e,r.data),s}return e(n,t),n}(q),Jn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(V),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"PEDI",r)||this;return s.event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new ke(e,r),s.status=B(r.poll.status)||r.poll.status,s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),Zn=function(t){function n(e,n,r){var s=t.call(this,e,"VOTE",r)||this;return s.event=null,s.channelUrl=null,s.channelType=null,s.event=new Oe(r),s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),$n=function(n){function r(e,t){var r,s,i,a,o,u,l,c,h,d,_,p,f,m,v,g,E,y,C,N,b,M,T=this;return(T=n.call(this,e,t)||this).includeEmpty=!1,T.includeFrozen=!0,T.includeMetaData=!0,T.channelUrlsFilter=null,T.customTypesFilter=null,T.customTypeStartsWithFilter=null,T.nicknameContainsFilter=null,T.nicknameStartsWithFilter=null,T.nicknameExactMatchFilter=null,T.channelNameContainsFilter="",T.myMemberStateFilter=Rt.ALL,T.unreadChannelFilter=Ot.ALL,T.superChannelFilter=kt.ALL,T.publicChannelFilter=Pt.ALL,T.hiddenChannelFilter=xt.UNHIDDEN,T.searchFilter={fields:[],query:null},T.userIdsFilter={userIds:[],includeMode:!0,queryType:Ht.AND},T.metadataKey=null,T.metadataValues=null,T.metadataOrderKeyFilter=null,T.metadataValueStartsWith=null,T.order=De.LATEST_LAST_MESSAGE,T.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,T.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,T.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,T.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,T.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,T.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",T.nicknameContainsFilter=null!==(l=t.nicknameContainsFilter)&&void 0!==l?l:null,T.nicknameStartsWithFilter=null!==(c=t.nicknameStartsWithFilter)&&void 0!==c?c:null,T.nicknameExactMatchFilter=null!==(h=t.nicknameExactMatchFilter)&&void 0!==h?h:null,T.channelNameContainsFilter=null!==(d=t.channelNameContainsFilter)&&void 0!==d?d:"",T.myMemberStateFilter=null!==(_=t.myMemberStateFilter)&&void 0!==_?_:Rt.ALL,T.unreadChannelFilter=null!==(p=t.unreadChannelFilter)&&void 0!==p?p:Ot.ALL,T.superChannelFilter=null!==(f=t.superChannelFilter)&&void 0!==f?f:kt.ALL,T.publicChannelFilter=null!==(m=t.publicChannelFilter)&&void 0!==m?m:Pt.ALL,T.hiddenChannelFilter=null!==(v=t.hiddenChannelFilter)&&void 0!==v?v:xt.UNHIDDEN,T.searchFilter=null!==(g=t.searchFilter)&&void 0!==g?g:{fields:[],query:null},T.userIdsFilter=null!==(E=t.userIdsFilter)&&void 0!==E?E:{userIds:[],includeMode:!0,queryType:Ht.AND},T.metadataKey=null!==(y=t.metadataKey)&&void 0!==y?y:null,T.metadataValues=null!==(C=t.metadataValues)&&void 0!==C?C:null,T.metadataOrderKeyFilter=null!==(N=t.metadataOrderKeyFilter)&&void 0!==N?N:null,T.metadataValueStartsWith=null!==(b=t.metadataValueStartsWith)&&void 0!==b?b:null,T.order=null!==(M=t.order)&&void 0!==M?M:De.LATEST_LAST_MESSAGE,T}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&t(Rt,this.myMemberStateFilter)&&t(kt,this.superChannelFilter)&&t(Pt,this.publicChannelFilter)&&t(Ot,this.unreadChannelFilter)&&t(xt,this.hiddenChannelFilter)&&v(Vt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&t(Ht,this.userIdsFilter.queryType)&&t(De,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return Q(this)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,rr.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),er=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||A.unreadMentionCount>0)&&(A._updateUnreadCount(0,0),this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==A.unreadMessageCount&&0!==A.unreadMentionCount||(this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new rn({channels:[A],source:Zt.EVENT_CHANNEL_READ})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),yn.label=12;case 12:return[3,77];case 13:return L=e.as(qn),ce=L.channelUrl,P=L.deliveredStateUpdate,R=void 0===P?{}:P,k=this._groupChannelCache.isCachedInMemory(ce),[4,this.getChannel(ce,!0)];case 14:if(O=yn.sent(),k)for(x in R)O._updateUndeliveredMemberState(x,R[x]);return Object.keys(R).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new rn({channels:[O],source:Zt.EVENT_CHANNEL_DELIVERED})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 15:return F=e.as(At),ce=F.channelUrl,he=F.channelType,H=F.event,he!==u.GROUP?[3,18]:[4,this.getChannel(ce,!0)];case 16:return V=yn.sent(),[4,this.getMessageFromCache(H.messageId)];case 17:(B=yn.sent())&&(B.applyReactionEvent(H),this._dispatcher.dispatch(new w({messages:[B],source:ee.EVENT_MESSAGE_REACTION_UPDATED}))),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(V,H)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),yn.label=18;case 18:return[3,77];case 19:return(G=e.as(St).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return q=yn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(B=yn.sent())&&(B.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new w({messages:[B],source:ee.EVENT_MESSAGE_THREADINFO_UPDATED}))),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(q,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),yn.label=22;case 22:return[3,77];case 23:Q=e.as(Ut).groupChannelMemberCounts,j=[],yn.label=24;case 24:yn.trys.push([24,29,30,31]),z=m(Q),W=z.next(),yn.label=25;case 25:return W.done?[3,28]:(K=W.value,ce=K.channelUrl,Be=K.memberCount,Qe=K.joinedMemberCount,J=K.updatedAt,[4,this.getChannelFromCache(ce)]);case 26:(X=yn.sent())&&X._setLatestMemberCount(Be,Qe,J)&&j.push(X),yn.label=27;case 27:return W=z.next(),[3,25];case 28:return[3,31];case 29:return ne=yn.sent(),hn={error:ne},[3,31];case 30:try{W&&!W.done&&(dn=z.return)&&dn.call(z)}finally{if(hn)throw hn.error}return[7];case 31:return j.length>0&&(this._dispatcher.dispatch(new rn({channels:j,source:Zt.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(j)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 32:return se=e.as(Xn),ie=se.event,ae=se.status,ce=se.channelUrl,he=se.channelType,ce&&he?[4,this.getChannel(ce,!0)]:[3,77];case 33:return oe=yn.sent(),this._dispatcher.dispatch(new U({event:ie,source:ee.EVENT_POLL_UPDATED})),$(ae===re?function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(oe,ie.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(oe,ie)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),[3,77];case 34:return ue=e.as(Zn),le=ue.event,ce=ue.channelUrl,he=ue.channelType,ce&&he?[4,this.getChannel(ce,!0)]:[3,77];case 35:return de=yn.sent(),this._dispatcher.dispatch(new T({event:le,source:ee.EVENT_POLL_VOTED})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(de,le)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,77];case 36:if(!(_e=e.as(bt).event).isGroupChannelEvent)return[3,75];switch(_e.category){case Mt.CHANNEL_JOIN:return[3,37];case Mt.CHANNEL_LEAVE:return[3,39];case Mt.CHANNEL_OPERATOR_UPDATE:return[3,43];case Mt.CHANNEL_INVITE:return[3,45];case Mt.CHANNEL_DECLINE_INVITE:return[3,47];case Mt.TYPING_START:case Mt.TYPING_END:return[3,49];case Mt.USER_CHANNEL_MUTE:case Mt.USER_CHANNEL_UNMUTE:return[3,51];case Mt.USER_CHANNEL_BAN:return[3,53];case Mt.USER_CHANNEL_UNBAN:return[3,57];case Mt.CHANNEL_FREEZE:case Mt.CHANNEL_UNFREEZE:return[3,59];case Mt.CHANNEL_HIDE:return[3,61];case Mt.CHANNEL_UNHIDE:return[3,63];case Mt.CHANNEL_DELETED:return[3,65];case Mt.CHANNEL_PROP_CHANGED:return[3,67];case Mt.CHANNEL_META_DATA_CHANGED:return[3,69];case Mt.CHANNEL_META_COUNTERS_CHANGED:return[3,71];case Mt.PINNED_MESSAGE_CHANGED:return[3,73]}return[3,75];case 37:return[4,this.getChannel(_e.channelUrl,!0)];case 38:return pe=yn.sent(),fe=e.as(wn),me=fe.memberCount,ve=fe.joinedMemberCount,ge=fe.members,Ee=!1,ge.forEach((function(e){pe.isExclusive||pe.isSuper||pe.isBroadcast?Ee=Ee||pe._setLatestMemberCount(me,ve,_e.ts):(e.state=Lt.JOINED,pe.addMember(e,_e.ts),En._updateJoinedMemberCount(pe)),e.userId===En._sdkState.userId&&(pe.myMemberState=Lt.JOINED)})),this._dispatcher.dispatch(new rn({channels:[pe],source:Zt.EVENT_CHANNEL_JOINED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(ge),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(pe,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}pe.isBroadcast&&Ee&&e.onChannelMemberCountChanged([pe])})),[2]}))}))})),[3,75];case 39:return(nt=this._leftChannels.get(_e.channelUrl))?(Ce=nt.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(_e.channelUrl,!0)];case 41:Ce=yn.sent(),yn.label=42;case 42:return ye=Ce,Ne=e.as(Ln),Be=Ne.memberCount,Qe=Ne.joinedMemberCount,be=Ne.member,Me=!1,Te=Y.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?Me=ye._setLatestMemberCount(Be,Qe,_e.ts):(Te.enabledChannelMemberShipHistory?(ye.members.find((function(e){return e.userId===be.userId})).state=Lt.LEFT,ye.memberCount=Be):ye.removeMember(be),this._updateJoinedMemberCount(ye)),be.userId===this._sdkState.userId?(ye.myMemberState=Lt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new rn({channels:[ye],source:Zt.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new sn({channelUrls:[ye.url],source:Zt.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new rn({channels:[ye],source:Zt.EVENT_CHANNEL_LEFT})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ye,be),ye.isBroadcast&&Me&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,75];case 43:return[4,this.getChannel(_e.channelUrl,!0)];case 44:Ue=yn.sent(),Se=e.as(Tt).operators,Ae=Se.map((function(e){return e.userId}));try{for(Ie=m(Ue.members),we=Ie.next();!we.done;we=Ie.next())(tt=we.value).role=Ae.includes(tt.userId)?n.OPERATOR:n.NONE}catch(e){_n={error:e}}finally{try{we&&!we.done&&(pn=Ie.return)&&pn.call(Ie)}finally{if(_n)throw _n.error}}return Ue.myRole=Ae.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new rn({channels:[Ue],source:Zt.EVENT_CHANNEL_OPERATOR_UPDATED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Ue,Se)})),[2]}))}))})),[3,75];case 45:return[4,this.getChannel(_e.channelUrl,!0)];case 46:De=yn.sent(),Le=e.as(kn),Be=Le.memberCount,Qe=Le.joinedMemberCount,Pe=Le.inviter,(Re=Le.invitees).forEach((function(e){return e.state=Lt.INVITED}));try{for(ke=m(Re),Oe=ke.next();!Oe.done;Oe=ke.next())xe=Oe.value,De.isExclusive||De.isSuper||De.isBroadcast?De._setLatestMemberCount(Be,Qe,_e.ts):De.addMember(xe,_e.ts),this._sdkState.userId===xe.userId&&(De.hiddenState=_s.UNHIDDEN,De.myMemberState!==Lt.JOINED&&(De.myMemberState=Lt.INVITED),De.invitedAt=_e.ts)}catch(e){fn={error:e}}finally{try{Oe&&!Oe.done&&(mn=ke.return)&&mn.call(ke)}finally{if(fn)throw fn.error}}return this._dispatcher.dispatch(new rn({channels:[De],source:Zt.EVENT_CHANNEL_INVITED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(De,Pe,Re)})),[2]}))}))})),[3,75];case 47:return[4,this.getChannel(_e.channelUrl,!0)];case 48:return Fe=yn.sent(),He=e.as(xn),Be=He.memberCount,Qe=He.joinedMemberCount,je=He.inviter,ze=He.invitee,Fe.isExclusive||Fe.isSuper||Fe.isBroadcast?Fe._setLatestMemberCount(Be,Qe,_e.ts):Fe.removeMember(ze),this._sdkState.userId===ze.userId?(Fe.invitedAt=0,Fe.myMemberState=Lt.NONE,Fe.isPublic?this._dispatcher.dispatch(new rn({channels:[Fe],source:Zt.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new sn({channelUrls:[Fe.url],source:Zt.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new rn({channels:[Fe],source:Zt.EVENT_CHANNEL_DECLINED_INVITE})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Fe,je,ze)})),[2]}))}))})),[3,75];case 49:return[4,this.getChannel(_e.channelUrl,!0)];case 50:return We=yn.sent(),Ke=_e.category===Mt.TYPING_START,Ye=e.as(Ke?Wn:Yn).user,We._updateTypingStatus(Ye,Ke?_e.ts:0),this._dispatcher.dispatch(new rn({channels:[We],source:Zt.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(We)})),[2]}))}))})),[3,75];case 51:return[4,this.getChannel(_e.channelUrl,!0)];case 52:Je=yn.sent(),Xe=_e.category===Mt.USER_CHANNEL_MUTE,(Ze=e.as(Xe?ct:ht).user).userId===this._sdkState.userId&&(Je.myMutedState=Xe?ds.MUTED:ds.UNMUTED);try{for($e=m(Je.members),et=$e.next();!et.done;et=$e.next())if((tt=et.value).userId===Ze.userId){tt.isMuted=Xe;break}}catch(e){vn={error:e}}finally{try{et&&!et.done&&(gn=$e.return)&&gn.call($e)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new rn({channels:[Je],source:Xe?Zt.EVENT_CHANNEL_MUTED:Zt.EVENT_CHANNEL_UNMUTED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Xe?e.onUserMuted(Je,Ze):e.onUserUnmuted(Je,Ze)})),[2]}))}))})),[3,75];case 53:return(nt=this._leftChannels.get(_e.channelUrl))?(st=nt.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(_e.channelUrl,!0)];case 55:st=yn.sent(),yn.label=56;case 56:return rt=st,this._markAsLeave(rt),mt=e.as(lt).user,$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(rt,mt)})),[2]}))}))})),[3,75];case 57:return[4,this.getChannel(_e.channelUrl,!0)];case 58:return vt=yn.sent(),gt=e.as(ut).user,$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(vt,gt)})),[2]}))}))})),[3,75];case 59:return[4,this.getChannel(_e.channelUrl,!0)];case 60:return Et=yn.sent(),yt=e.as(ot).freeze,Et.isFrozen=yt,this._dispatcher.dispatch(new rn({channels:[Et],source:yt?Zt.EVENT_CHANNEL_FROZEN:Zt.EVENT_CHANNEL_UNFROZEN})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onChannelFrozen(Et):e.onChannelUnfrozen(Et)})),[2]}))}))})),[3,75];case 61:return[4,this.getChannel(_e.channelUrl,!0)];case 62:return Ct=yn.sent(),Nt=e.as(jn),Dt=Nt.allowAutoUnhide,Pt=Nt.hidePreviousMessages,Rt=Nt.messageOffsetTimestamp,null!==Dt&&(Ct.hiddenState=Dt?_s.HIDDEN_ALLOW_AUTO_UNHIDE:_s.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Ct._updateUnreadCount(0,0),null!==Rt&&(Ct.messageOffsetTimestamp=Rt),this._dispatcher.dispatch(new rn({channels:[Ct],source:Zt.EVENT_CHANNEL_HIDDEN})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Ct)})),[2]}))}))})),[3,75];case 63:return[4,this.getChannel(_e.channelUrl,!0)];case 64:return(kt=yn.sent()).hiddenState=_s.UNHIDDEN,this._dispatcher.dispatch(new rn({channels:[kt],source:Zt.EVENT_CHANNEL_UNHIDDEN})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(kt)})),[2]}))}))})),[3,75];case 65:return[4,this.getChannel(_e.channelUrl,!0)];case 66:return Ot=yn.sent(),this._dispatcher.dispatch(new sn({channelUrls:[_e.channelUrl],source:Zt.EVENT_CHANNEL_DELETED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Ot.url,Ot.channelType)})),[2]}))}))})),[3,75];case 67:return[4,this.getChannelWithoutCache(_e.channelUrl,!0)];case 68:return xt=yn.sent(),this._dispatcher.dispatch(new rn({channels:[xt],source:Zt.EVENT_CHANNEL_UPDATED})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(xt)})),[2]}))}))})),[3,75];case 69:return[4,this.getChannel(_e.channelUrl,!0)];case 70:return Ft=yn.sent(),Ht=e.as(at),Vt=Ht.created,Gt=Ht.updated,qt=Ht.deleted,Vt&&Ft._upsertCachedMetaData(Vt,_e.ts),Gt&&Ft._upsertCachedMetaData(Gt,_e.ts),qt&&Ft._removeFromCachedMetaData(qt,_e.ts),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated(Ft,Vt),Gt&&e.onMetaDataUpdated(Ft,Gt),qt&&e.onMetaDataDeleted(Ft,qt)})),[2]}))}))})),[3,75];case 71:return[4,this.getChannel(_e.channelUrl,!0)];case 72:return Bt=yn.sent(),Qt=e.as(it),jt=Qt.created,zt=Qt.updated,Wt=Qt.deleted,$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){jt&&e.onMetaCounterCreated(Bt,jt),zt&&e.onMetaCounterUpdated(Bt,zt),Wt&&e.onMetaCounterDeleted(Bt,Wt)})),[2]}))}))})),[3,75];case 73:return[4,this.getChannel(_e.channelUrl,!0)];case 74:return Kt=yn.sent(),Yt=e.as(tr),Jt=Yt.pinnedMessageIds,Xt=Yt.latestPinnedMessage,($t=Yt.ts)>Kt._pinnedMessagesUpdatedAt&&(Kt.pinnedMessageIds=Jt,Kt.lastPinnedMessage=Xt,Kt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new rn({channels:[Kt],source:Zt.EVENT_PINNED_MESSAGE_UPDATED})),$((function(){return p(En,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(Kt)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),$((function(){return p(En,void 0,void 0,(function(){return f(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Kt)})),[2]}))}))}))),[3,75];case 75:return[3,77];case 76:switch((en=e.as(Ve).event).category){case Ge.USER_BLOCK:tn=qe.getDataAsUserBlockEvent(this._iid,en),an=tn.blocker,on=tn.blockee,this._groupChannelCache.block(an.userId,on.userId);break;case Ge.USER_UNBLOCK:nn=qe.getDataAsUserBlockEvent(this._iid,en),an=nn.blocker,on=nn.blockee,this._groupChannelCache.unblock(an.userId,on.userId)}return[3,77];case 77:return[3,79];case 78:if(un=yn.sent(),Z(un))throw un;return[3,79];case 79:return[2]}}))}))},e.prototype._markAsLeave=function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===Lt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:ne(g("string",e)).throw(z.invalidParameters),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=r.sent())?[2,n]:[3,4];case 3:return r.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,r.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return ne(g("string",e)).throw(z.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case hs.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case hs.UNREAD_MENTION_COUNT_ONLY:i=0;break;case hs.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=Zt.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return s=new dn(o(o({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(s)];case 1:return i=c.sent(),a=i.as(_n),u=a.channels,l=a.token,this._dispatcher.dispatch(new rn({channels:u,source:r})),[2,{channels:u,token:l}]}}))}))},e.prototype.getMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=Be),p(this,void 0,void 0,(function(){return f(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=Be),p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},e.prototype.getCachedMessageCountBetween=function(e,t,n,r){return p(this,void 0,void 0,(function(){return f(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new er({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=Zt.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var r,s,i,u,l,c;return f(this,(function(h){switch(h.label){case 0:return r=o(o({},Kt),t),ne((g("string",e)||g("number",e))&&Yt(r)).throw(z.invalidParameters),s=new un(a({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:r})),[4,this._requestQueue.send(s)];case 1:return i=h.sent(),u=i.as(ln),l=u.updatedChannels,c=u.deletedChannelUrls,l.length>0&&this._dispatcher.dispatch(new rn({channels:l,source:n})),c.length>0&&this._dispatcher.dispatch(new sn({channelUrls:c,source:n})),[2,u]}}))}))},e.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(s){switch(s.label){case 0:return t=o(o({},Jt),e),ne(Xt(t)).throw(z.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return t=o(o({},$t),e),ne(function(e){return v(Bt,e.keys)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new mn({userId:r.userId,filter:t}),[4,s.send(i)];case 1:return[2,a.sent().as(vn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(En).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return n=o(o({},en),e),ne(function(e){return v("string",e.channelCustomTypesFilter,!0)&&t(kt,e.superChannelFilter)}(n)).throw(z.invalidParameters),r=Y.of(this._iid),s=r.sdkState,i=r.requestQueue,a=new yn({userId:s.userId,filter:n}),[4,i.send(a)];case 1:return u=l.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=o(o({},tn),e),ne(function(e){return g("string",e.channelUrl,!0)&&v(C,e.scheduledStatus,!0)&&t(y,e.messageTypeFilter)}(n)).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new Nn(n),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=Y.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=Y.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},e.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=Y.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),t.isPublic||(t.accessCode=null),n=new Tn(o({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),s=r.as(Un).channel,[4,this.upsertChannelsToCache([s])];case 2:return i.sent(),[2,s]}}))}))},e.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return e=Date.now(),ne(e-this._markAsReadAllLastSentAt>=1e3).throw(z.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Sn({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=m(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:return t=Date.now(),ne(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(z.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Sn({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:c.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=m(r),a=i.next();!a.done;a=i.next())o=a.value,e.includes(o.url)&&(o._updateUnreadMemberState(this._sdkState.userId,t),o._updateUnreadCount(0,0),s.push(o))}catch(e){u={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this.upsertChannelsToCache(s)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var sr,ir=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount=this._limit,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,h.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return r=o.sent(),h.debug("message background prev sync error",r),r instanceof z&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw r;case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new ir(d,(function(e){return p(i,void 0,void 0,(function(){var t,n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:o.sent(),h.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,oe.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(a=null===(i=this._metadata.range)||void 0===i?void 0:i.bottom)&&void 0!==a?a:e,{prevResultSize:0,nextResultSize:this._limit,replyType:ue.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},ee.SYNC_MESSAGE_BACKGROUND)];case 3:return n=o.sent(),this.extendRange(n),t.hasNext=n.length>=this._limit,t.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,6];case 5:throw r=o.sent(),h.debug("message background next sync error",r),r;case 6:return[2,t]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ur[t]||(ur[t]={}),ur[t][n.url]||(ur[t][n.url]=new e({_iid:t,channel:n})),ur[t][n.url].ref++,ur[t][n.url]},e.clear=function(e,t){ur[e]&&ur[e][t]&&(ur[e][t].close(),delete ur[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n,r,s=Y.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now()))},e.prototype.pause=function(){Y.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ur[this._iid][this._channel.url])},e}(),cr={},hr=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=Y.of(this._iid),o=a.logger,u=a.sdkState,l=a.dispatcher;this._metadataKey=(s=u.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var c=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(u.userId,this._channel.url);this._sync=new ir(c,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:l.sent(),o.debug("message changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),l.label=2;case 2:return l.trys.push([2,5,,8]),[4,oe.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:ue.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},ee.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=l.sent(),n=t.updatedMessages,r=t.deletedMessageIds,s=t.hasMore,i=t.token,e.hasNext=s,e.nextToken=i,(n.length>0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return l.sent(),[3,8];case 5:return a=l.sent(),o.debug("message changelog sync error",a),a instanceof z&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:l.sent(),l.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n})),cr[t][n.url].ref++,cr[t][n.url]},e.clear=function(e,t){cr[e]&&cr[e][t]&&(cr[e][t].close(),delete cr[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=Y.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){Y.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){var e=Y.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),dr=function(t){function n(e){var n,r,s,i,o,u,l=this;return(l=t.call(this)||this).method=L.GET,l.path="".concat(le(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),l.params=a({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(r=e.customTypes)&&void 0!==r?r:["*"],message_type:null!==(s=e.messageType)&&void 0!==s?s:null,include_reactions:null===(i=e.includeReactions)||void 0===i||i,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u,include_poll_details:!0}),l}return e(n,t),n}(R),_r=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return W(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return W(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(k),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){var r=pr(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:mr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},mr=function(e,t,n){switch(n){case De.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case De.CHRONOLOGICAL:return t.createdAt-e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},vr=function(e,t){return t instanceof D?e.findIndex((function(e){return e instanceof D&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},gr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Er=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr={},Cr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=Y.of(this._iid),u=o.logger,l=o.sdkState,c=o.dispatcher;this._metadataKey=(i=l.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(l.userId,this._channel.url);this._sync=new ir(h,(function(){return p(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,l;return f(this,(function(c){switch(c.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return c.sent(),u.debug("poll changelog sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!c.sent(),c.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=Y.of(this._iid).firstConnectedAt,this._metadata={token:n}),c.label=4;case 4:return c.trys.push([4,7,,10]),[4,Qe.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=c.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return c.sent(),[3,10];case 7:return o=c.sent(),u.debug("poll changelog sync error",o),o instanceof z&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:c.sent(),c.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return yr[t]||(yr[t]={}),yr[t][n.url]||(yr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),yr[t][n.url].ref++,yr[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){Y.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){Y.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete yr[this._iid][this._channel.url])},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(sr||(sr={}));var Nr,br,Mr,Tr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;$((function(){return p(r,void 0,void 0,(function(){return f(this,(function(r){switch(e){case"local":this._onCacheResult(t,n);break;case"remote":this._onApiResult(t,n)}return[2]}))}))}))},e.prototype.onCacheResult=function(e){return this._onCacheResult=e,this},e.prototype.onApiResult=function(e){return this._onApiResult=e,this},e}(),Ur=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._iid=e,this._key="mc-".concat(de()),this.filter=null!=r?r:new je,this._channel=n,this._syncRange=new er({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+6e5,this._limit=i||Be;var o=rr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=pr(e,a._channel);if(n>=0&&($((function(){return p(a,void 0,void 0,(function(){var r,s;return f(this,(function(i){return r=new ar(t),this._channel=e[n],(null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)&&this._handler.onChannelUpdated(r,this.channel),[2]}))}))})),t===Zt.EVENT_CHANNEL_UPDATED)){var r=!1;for(var s in a._messages){if(a._messages[s].createdAt>=a._channel.messageOffsetTimestamp){r=!0;var i=parseInt(s);if(i>0){var o=a._messages.splice(0,i);a._removeMessagesFromView(o.map((function(e){return e.messageId})),ee.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!r&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),ee.EVENT_MESSAGE_OFFSET_UPDATED)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&$((function(){return p(a,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var l=u.value;l.channelUrl===a._channel.url&&(a.filter.match(l)?s.push(l):i.push(l.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(he(t)){if(s.length>0)switch(t){case ee.EVENT_MESSAGE_SENT_FAILED:case ee.EVENT_MESSAGE_SENT_SUCCESS:case ee.EVENT_MESSAGE_UPDATED:case ee.EVENT_MESSAGE_THREADINFO_UPDATED:case ee.EVENT_MESSAGE_REACTION_UPDATED:case ee.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case ee.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case ee.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case ee.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=Y.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&(this._backgroundSync=lr.of(this._iid,this._channel),this._backgroundSync.resume()),this._changelogSync=hr.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Cr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new ir(this._key,(function(e){return p(a,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:ee.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,d([],_(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this.viewTop0?(n=Math.max.apply(Math,d([],_(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:!(t.length>=this._limit&&this._hasNext)||this.viewBottom>n,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var l=Y.of(this._iid),c=l.dispatcher,h=l.logger;this._connectionEventContext=c.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)h.debug("check huge gap"),a._checkHugeGap();else a._prevFill.stop(),a._nextFill.stop()}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ce.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ce.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=m(i),l=u.next();!l.done;l=u.next()){var c=l.value;if(t===ee.SYNC_MESSAGE_FILL){if(c.messageId>0){if((E=vr(this._messages,c))<0){vr(this._unsentMessages,c)<0&&a.push(c);var h=Er(this._messages,c);this._messages.splice(h,0,c)}}else if(c instanceof D){(E=vr(this._unsentMessages,c))<0&&vr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c))}}else if(c.messageId>0){if((E=vr(this._messages,c))<0){var v=vr(this._unsentMessages,c);v<0?a.push(c):(this._unsentMessages.splice(v,1),o.push(c));h=Er(this._messages,c);this._messages.splice(h,0,c)}else o.push(c),this._messages[E]=c;if(c.updatedAt>0){var g=this._updateChildMessagesInView(c);o.push.apply(o,d([],_(g),!1))}}else if(c instanceof D){var E;(E=vr(this._unsentMessages,c))<0?vr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c)):(o.push(c),this._unsentMessages[E]=c)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}he(t)&&$((function(){return p(s,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=new or(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,l=gr(this._messages,u.messageId);if(l>=0){var c=this._messages[l];c&&c.applyPoll(u),i.push(c)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&he(t)&&$((function(){return p(s,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new or(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=gr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&he(t)&&$((function(){return p(n,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=gr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&he(t)&&$((function(){return p(n,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var l,c=u.value;if(c.messageId>0)if((l=vr(this._messages,c))>=0)i.push(c),this._messages[l]=c;else{var h=vr(this._unsentMessages,c);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(c);var _=Er(this._messages,c);this._messages.splice(_,0,c)}}}else if(c instanceof D)(l=vr(this._unsentMessages,c))>=0&&(i.push(c),this._unsentMessages[l]=c)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return he(t)&&$((function(){return p(s,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=new or(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var l=m(e),c=l.next();!c.done;c=l.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return he(t)&&a.length>0&&$((function(){return p(s,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return p(this,void 0,void 0,(function(){var t,n,s,a,o,u,l;return f(this,(function(c){switch(c.label){case 0:return t=rr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=c.sent(),[3,3];case 2:s=[],c.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=c.sent(),[3,6];case 5:o=[],c.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(l in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[l].messageId)){a.splice(parseInt(l),1);break}return[2,d(d([],_(n),!1),_(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s,a=t.source,u=void 0===a?ee.REQUEST_MESSAGE:a,l=t.reverse,c=void 0!==l&&l;return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(s){switch(s.label){case 0:return t=oe.of(this._iid),r>0||i>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,o(o({},this.filter),{isInclusive:!0,reverse:c,prevResultSize:r,nextResultSize:i,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=s.sent(),[3,3];case 2:n=[],s.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,u,l,c,h,m,v,g,E,y,C=this;return f(this,(function(N){switch(N.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,n=this._syncRange.bottom,r=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(s=rr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return i=N.sent(),[4,s.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return a=N.sent(),[4,_e((function(){return p(C,void 0,void 0,(function(){var s,u,l,c,h,m,v,g,E,y,C,N,b,M,T,U,S,A=this;return f(this,(function(I){switch(I.label){case 0:return s=Y.of(this._iid),u=s.dispatcher,l=s.requestQueue,c=new dr(o({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:i,nextStart:n,nextEnd:r,nextCount:a},this.filter)),[4,l.send(c)];case 1:return h=I.sent(),m=h.as(_r),v=m.isHugeGap,g=m.prevMessages,E=void 0===g?[]:g,y=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?$((function(){return p(A,void 0,void 0,(function(){var e;return f(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=y,this._hasNext=b,M=this.viewTop,T=this.viewBottom,U=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,M],_(E.map((function(e){return e.createdAt}))),!1)),S=Math.max.apply(Math,d([0,T],_(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new w({messages:E,source:ee.SYNC_MESSAGE_FILL})),u.dispatch(new w({messages:N,source:ee.SYNC_MESSAGE_FILL})),this._syncRange.extends(U,S),MS&&this._nextFill.start(S)),[2]}}))}))}),1)];case 3:return N.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),l=Date.now(),[4,this._getRemoteMessages(l,{prevLimit:u,nextLimit:u,source:ee.SYNC_MESSAGE_FILL})];case 5:if((c=N.sent()).length>0){for(h=c.map((function(e){return e.createdAt})),m=0,v=0,g=0;g=l&&v++;this._hasPrevious=m>=u,this._hasNext=v>=u,(y=this._syncRange).extends.apply(y,d([],_(c.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(c,ee.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;N.label=6;case 6:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,rr.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+6e5,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype.initialize=function(e){var t=this,n=new Tr;this._messages=[],this._unsentMessages=[],this._syncRange=new er({}),this._hasNext=!0,this._hasPrevious=!0;var r=Math.floor(this._limit/2);if(e===sr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return p(t,void 0,void 0,(function(){var t;return f(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,ee.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Z(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0}).then((function(e){var s;t._messages=[];var i=t._filterUnderOffsetMessage(e);if(i.length>0){for(var a=i.map((function(e){return e.createdAt})),o=0,u=0,l=0;l=t._startingPoint&&u++}t._hasPrevious=o>=r,t._hasNext=u>=r,(s=t._syncRange).extends.apply(s,d([],_(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,ee.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,i)})).catch((function(e){if(Z(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return p(this,void 0,void 0,(function(){var e,t,n,r=this;return f(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return p(r,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,b((function(){return p(r,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[a.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],_(t.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,ee.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,d([],_(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,ee.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return p(this,void 0,void 0,(function(){var t,n,r,s=this;return f(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,b((function(){return p(s,void 0,void 0,(function(){var e;return f(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,b((function(){return p(s,void 0,void 0,(function(){var e,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[a.sent()]),this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],_(n.map((function(e){return e.createdAt}))),!1)),(null===(s=this._backgroundSync)||void 0===s?void 0:s.range.overlap(this._syncRange))&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,ee.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,ee.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return[4,rr.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n;Y.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var r=rr.of(this._iid);r.unsubscribeGroupChannelEvent(this._key),r.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ar={hidePreviousMessages:!1,allowAutoUnhide:!0},Ir=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,l=e.nicknameStartsWithFilter,c=e.operatorFilter;return(n=t.call(this)||this).method=L.GET,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:l,operator_filter:c,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(R),wr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new Gt(e,t)}))),r}return e(n,t),n}(k);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Nr||(Nr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(br||(br={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Mr||(Mr={}));var Dr=function(n){function r(e,t,r){var s,i,a,o,l=this;return(l=n.call(this,e,t,u.GROUP,r)||this).mutedMemberFilter=Nr.ALL,l.memberStateFilter=Mr.ALL,l.nicknameStartsWithFilter=null,l.operatorFilter=Ft.ALL,l.order=br.MEMBER_NICKNAME_ALPHABETICAL,l.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Nr.ALL,l.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Mr.ALL,l.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,l.order=null!==(o=r.order)&&void 0!==o?o:br.MEMBER_NICKNAME_ALPHABETICAL,l}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(Nr,this.mutedMemberFilter)&&t(Mr,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(Ft,this.operatorFilter)&&t(br,this.order)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Y.of(this._iid).requestQueue,t=new Ir(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(wr),s=r.members,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(pe),Lr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),Pr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r.channel.myMemberState=Lt.JOINED,r}return e(n,t),n}(k),Rr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.isDistinct,i=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,l=e.coverImage,c=e.accessCode,h=e.name,d=e.data,_=e.customType,p=e.operatorUserIds,f=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n.params=a({is_distinct:s,is_public:i,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:l,access_code:c,operator_ids:p,message_survival_seconds:f}),n}return e(n,t),n}(R),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ms(e,n),r}return e(n,t),n}(k),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var Fr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(P,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(R),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(k),Vr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=L.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(R),Gr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(k),qr=o(o({},mt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Br=o(o({},gt),{scheduledAt:null}),Qr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=null;e.mentionType===fe.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return r.method=L.PUT,r.path="".concat(le(i),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),r.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:me.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return ve.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ge.payloadify(e)})),apple_critical_alert_options:Ee.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),r}return e(n,t),n}(R),jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new X(e,n),r}return e(n,t),n}(k),zr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=null;e.mentionType===fe.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return r.method=L.PUT,r.path="".concat(le(i),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),r.params=a({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:me.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ge.payloadify(e)})),apple_critical_alert_options:Ee.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),r}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new J(e,n),r}e(n,t)}(k);var Wr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=L.DELETE,n.path="".concat(le(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(R),Kr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=L.POST,n.path="".concat(le(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(R),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(P,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(R),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(k),Xr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=L.GET,s.path="".concat(P,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R),Zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(k),$r=function(t){function n(e){var n=e.pollId,r=e.title,s=e.data,i=e.allowUserSuggestion,a=e.allowMultipleVotes,o=e.closeAt,u=t.call(this)||this;return u.method=L.PUT,u.path="".concat(Ce,"/").concat(encodeURIComponent(n)),u.params={title:r,data:s,allow_user_suggestion:i,allow_multiple_votes:a,close_at:o},u}return e(n,t),n}(R),es=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),ts=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=L.DELETE,r.path="".concat(Ce,"/").concat(encodeURIComponent(n)),r}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var ns=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=L.PUT,r.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/close"),r}return e(n,t),n}(R),rs=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),ss=function(t){function n(e){var n=e.channelUrl,r=e.channelType,s=e.pollId,i=e.optionText,a=t.call(this)||this;return a.method=L.POST,a.path="".concat(Ce,"/").concat(encodeURIComponent(s),"/options"),a.params={channel_url:n,channel_type:r,text:i},a}return e(n,t),n}(R),is=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),as=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=e.optionText,i=t.call(this)||this;return i.method=L.PUT,i.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i.params={text:s},i}return e(n,t),n}(R),os=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Ne(e,n),r}return e(n,t),n}(k),us=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=t.call(this)||this;return s.method=L.DELETE,s.path="".concat(Ce,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(k);var ls=function(t){function n(e){var n=e.reqId,r=e.channelType,s=e.channelUrl,i=e.pollId,o=e.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:a({req_id:n,channel_type:r===u.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:i,option_ids:o})})||this}return e(n,t),n}(V),cs=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=L.POST,i.path="".concat(le(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k);var hs,ds,_s,ps=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=L.DELETE,i.path="".concat(le(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(k),function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}(hs||(hs={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(ds||(ds={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(_s||(_s={}));var fs,ms=function(r){function s(e,s){var i,a,c,h,p,f,m,v,E,y,C,N,b,M,T,U,S,A,I,w=this;return(w=r.call(this,e,s)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=_s.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=Lt.NONE,w.myRole=n.NONE,w.myMutedState=ds.UNMUTED,w.myLastRead=0,w.myCountPreference=hs.ALL,w.myPushTriggerOption=$e.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w.channelType=u.GROUP,w.isDistinct=null!==(a=s.is_distinct)&&void 0!==a&&a,w.isSuper=null!==(c=s.is_super)&&void 0!==c&&c,w.isBroadcast=null!==(h=s.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(p=s.is_exclusive)&&void 0!==p&&p,w.isPublic=null!==(f=s.is_public)&&void 0!==f&&f,w.isDiscoverable=null!==(m=s.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=s.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(E=s.is_push_enabled)&&void 0!==E&&E,Array.isArray(s.members)&&(i=w.members).push.apply(i,d([],_(s.members.map((function(e){return new Gt(w._iid,e)}))),!1)),w.memberCount=null!==(y=s.member_count)&&void 0!==y?y:0,w.joinedMemberCount=null!==(C=s.joined_member_count)&&void 0!==C?C:0,w.hiddenState=t(_s,s.hidden_state)?s.hidden_state:_s.UNHIDDEN,w.messageOffsetTimestamp=null!==(N=s.ts_message_offset)&&void 0!==N?N:0,w.messageSurvivalSeconds=null!==(b=s.message_survival_seconds)&&void 0!==b?b:-1,w.lastMessage=s.last_message?W(w._iid,o({channel_type:w.channelType},s.last_message)):null,s.read_receipt&&Object.keys(s.read_receipt).forEach((function(e){g("number",s.read_receipt[e])&&w._updateUnreadMemberState(e,s.read_receipt[e])})),s.delivery_receipt&&Object.keys(s.delivery_receipt).forEach((function(e){g("number",s.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,s.delivery_receipt[e])})),w.myMemberState=t(Lt,s.member_state)?s.member_state:Lt.NONE,w.myRole=t(n,s.my_role)?s.my_role:n.NONE,t(ds,s.is_muted)?w.myMutedState=s.is_muted:g("boolean",s.is_muted)?w.myMutedState=s.is_muted?ds.MUTED:ds.UNMUTED:w.myMutedState=ds.UNMUTED,w.myCountPreference=t(hs,s.count_preference)?s.count_preference:hs.ALL,w.myPushTriggerOption=t($e,s.push_trigger_option)?s.push_trigger_option:$e.ALL,w.myLastRead=null!==(M=s.user_last_read)&&void 0!==M?M:0,w.inviter=s.inviter?new l(w._iid,s.inviter):null,w.invitedAt=null!==(T=s.invited_at)&&void 0!==T?T:0,w.joinedAt=null!==(U=s.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(S=s.unread_message_count)&&void 0!==S?S:0,null!==(A=s.unread_mention_count)&&void 0!==A?A:0),w.pinnedMessageIds=null!==(I=s.pinned_message_ids)&&void 0!==I?I:[],w.lastPinnedMessage=s.latest_pinned_message?W(w._iid,o({channel_type:w.channelType},s.latest_pinned_message)):null,w}return e(s,r),Object.defineProperty(s.prototype,"isHidden",{get:function(){return this.hiddenState!==_s.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=_(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=_(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),s.payloadify=function(e){return e?a(o(o({},r.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return Gt.payloadify(e)})),last_message:be(e.lastMessage),inviter:e.inviter?l.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:be(e.lastPinnedMessage)})):null},s.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof D&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===hs.ALL||this.myCountPreference===hs.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=Y.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===hs.ALL||this.myCountPreference===hs.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},s.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},s.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},s.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},s.prototype.isReadMessage=function(e){var t=Y.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},s.prototype.serialize=function(){var e=this;return Q(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},s.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Ur(this._iid,o({channel:this},e))},s.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Dr(this._iid,this.url,e)},s.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var r=this.members[n];r.state===Lt.JOINED&&(e.state=r.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},s.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof Gt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},s.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof D&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=Y.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=m(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Lt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},s.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=Y.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof D?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},s.prototype.refresh=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(hn).channel,n.dispatch(new rn({channels:[i],source:Zt.REQUEST_CHANNEL})),[2,i]}}))}))},s.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.prototype.freeze.call(this)];case 1:return e.sent(),Y.of(this._iid).dispatcher.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},s.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,r.prototype.unfreeze.call(this)];case 1:return e.sent(),Y.of(this._iid).dispatcher.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},s.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,u;return f(this,(function(l){switch(l.label){case 0:return t=o(o({},Sr),e),ne(function(e){return g("string",e.coverUrl,!0)&&(E(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.requestQueue,i=new Rr(o({channelUrl:this.url},t)),[4,s.send(i)];case 1:return a=l.sent(),u=a.as(kr).channel,r.dispatch(new rn({channels:[u],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return ne(e.every((function(e){return e instanceof l}))).throw(z.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},s.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return ne(v("string",e)).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Pn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Rn).channel,n.dispatch(new rn({channels:[a],source:Zt.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},s.prototype.join=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return ne(g("string",e)||null===e).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new An({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=Lt.JOINED,n.dispatch(new rn({channels:[o],source:Zt.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},s.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=Y.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Dn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=Lt.NONE,[2]}}))}))},s.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return f(this,(function(u){switch(u.label){case 0:return ne(g("string",e)||null===e).throw(z.invalidParameters),t=Y.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Lr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Pr).channel).myMemberState=this.myMemberState=Lt.JOINED,n.dispatch(new rn({channels:[o],source:Zt.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},s.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new On({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=Lt.NONE,[2,this]}}))}))},s.prototype.sendUserMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){t.hiddenState===_s.HIDDEN_ALLOW_AUTO_UNHIDE&&(t.hiddenState=_s.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),rr.of(t._iid).handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return n=Y.of(this._iid).dispatcher,[4,r.prototype.updateUserMessage.call(this,e,t)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),n.dispatch(new rn({channels:[this],source:a?Zt.EVENT_PINNED_MESSAGE_UPDATED:Zt.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),n.dispatch(new w({messages:[s],source:ee.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendUserMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.sendFileMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return n=Y.of(this._iid).dispatcher,[4,r.prototype.updateFileMessage.call(this,e,t)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),n.dispatch(new rn({channels:[this],source:a?Zt.EVENT_PINNED_MESSAGE_UPDATED:Zt.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),n.dispatch(new w({messages:[s],source:ee.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendFileMessage=function(e){var t=this,n=new Te,s=Y.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=rr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new rn({channels:[t],source:Zt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,r.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&e instanceof D&&Y.of(this._iid).dispatcher.dispatch(new A({reqId:e.reqId,source:ee.EVENT_MESSAGE_DELETED})),[2]}}))}))},s.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return t=o(o({},Ar),e),ne(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Bn(o({channelUrl:this.url,userId:s.userId},t)),[4,i.send(a)];case 1:return u=c.sent(),l=u.as(Qn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?_s.HIDDEN_ALLOW_AUTO_UNHIDE:_s.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),l&&(this.messageOffsetTimestamp=l),r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},s.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=_s.UNHIDDEN,t.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},s.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=Y.of(this._iid).requestQueue,t=new Or({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return f(this,(function(u){switch(u.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(Hn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),rr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_READ})),[2]}}))}))},s.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){return e=Y.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(i){return e=Y.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Kn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.createScheduledUserMessage=function(e){e=o(o({},We),e),ne(Ke(e)).throw(z.invalidParameters);var t=new Te;return this._createScheduledUserMessage(e,t),t},s.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=o(o({},Br),t),ne(function(e){return Et(e)&&g("number",e.scheduledAt,!0)}(n)).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new zr(o({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(Ct).message]}}))}))},s.prototype.createScheduledFileMessage=function(e){var t=this;e=o(o({},Ye),e),ne(Je(e)).throw(z.invalidParameters);var n=Date.now(),r=this._generateRequestId(),s=new Te;return Me(Nt).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);$((function(){return p(t,void 0,void 0,(function(){return f(this,(function(e){return[2,s._trigger(null,i)]}))}))}))})),E(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,s,r,n)})):this._createScheduledFileMessage(e,s,r,n),s},s.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return n=o(o({},qr),t),ne(function(e){return vt(e)&&g("number",e.scheduledAt,!0)&&(E(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(z.invalidParameters),E(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return r=new Qr(o({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,Y.of(this._iid).requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(jr).message]}}))}))},s.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Wr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,Y.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return t=new Kr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,Y.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Zr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},s.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return ne(t($e,e)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Yr({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Jr).pushTriggerOption,this.myPushTriggerOption=u,r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return ne(t(hs,e)).throw(z.invalidParameters),n=Y.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new Fr({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Hr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e=Y.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Vr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Gr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new rn({channels:[this],source:Zt.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},s.prototype.updatePoll=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return ne(g("number",e)&&function(e){return g("string",e.title,!0)&&ye(e.data)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new $r(o({pollId:e},t)),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(es).poll]}}))}))},s.prototype.deletePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(s){switch(s.label){case 0:return t=g("number",e),ne(t).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new ts({pollId:e}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s;return f(this,(function(i){switch(i.label){case 0:return t=g("number",e),ne(t).throw(z.invalidParameters),n=Y.of(this._iid).requestQueue,r=new ns({pollId:e}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(rs).poll]}}))}))},s.prototype.addPollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),ne(n).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new ss({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(is).poll]}}))}))},s.prototype.updatePollOption=function(e,t,n){return p(this,void 0,void 0,(function(){var r,s,i,a;return f(this,(function(o){switch(o.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),ne(r).throw(z.invalidParameters),s=Y.of(this._iid).requestQueue,i=new as({pollId:e,pollOptionId:t,optionText:n}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(os).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s;return f(this,(function(i){switch(i.label){case 0:return n=g("number",e)&&g("number",t),ne(n).throw(z.invalidParameters),r=Y.of(this._iid).requestQueue,s=new us({pollId:e,pollOptionId:t}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return f(this,(function(l){switch(l.label){case 0:return n=g("number",e)&&v("number",t),ne(n).throw(z.invalidParameters),r=Y.of(this._iid),s=r.requestQueue,i=r.dispatcher,a=new ls({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(a)];case 1:return o=l.sent(),u=o.as(Zn).event,i.dispatch(new T({event:u,source:ee.EVENT_POLL_VOTED})),[2,u]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("number",e)).throw(z.invalidParameters),[4,Qe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("string",e,!0)),[4,Qe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=et),new Xe(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=tt),new Ze(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype.pinMessage=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return ne(g("number",e)&&e>0).throw(z.invalidParameters),t=Y.of(this._iid).requestQueue,n=new cs({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},s.prototype.unpinMessage=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return ne(g("number",e)&&e>0).throw(z.invalidParameters),t=Y.of(this._iid).requestQueue,n=new ps({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},s.prototype._uploadFileAndUpdateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l,c,h;return f(this,(function(d){switch(d.label){case 0:return E(e.file)?(t=Y.of(this._iid).requestQueue,n=new Se({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Ue),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,l=void 0===u?e.thumbnailSizes:u,c=s.requireAuth,h=void 0!==c&&c,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=l,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},s}(yt),vs={},gs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=Y.of(this._iid),o=a.sdkState,u=a.dispatcher,l=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var c=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new ir(c,(function(){return p(s,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(a.sent(),l.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:De.CHRONOLOGICAL},this._limit,Zt.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,l.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),l.debug("channel background sync error",s),s instanceof z&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return vs[t]||(vs[t]=new e({_iid:t})),vs[t].ref++,vs[t]},e.clear=function(e){vs[e]&&(vs[e].close(),delete vs[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,Y.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n=Y.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){Y.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete vs[this._iid])},e}(),Es={},ys=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=Y.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new ir(u,(function(){return p(n,void 0,void 0,(function(){var e,t,n,r,s;return f(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),i.debug("channel changelog sync from",this._metadata.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},Zt.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),i.debug("channel changelog sync error",s),s instanceof z&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof ie)if(e.stateType===ae.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Es[t]||(Es[t]=new e({_iid:t})),Es[t].ref++,Es[t]},e.clear=function(e){Es[e]&&(Es[e].close(),delete Es[e])},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return f(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=Y.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this._metadata?[4,Y.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,Y.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){Y.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Es[this._iid])},e}(),Cs=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(de()),this.filter=null!=n?n:new Qt,this.order=null!=r?r:De.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Pe;var a=Y.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&(this._backgroundSync=gs.of(e),this._backgroundSync.resume()),this._changelogSync=ys.of(e),this._changelogSync.resume(),rr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)},onRemove:function(e,t){i._removeChannelsFromView(e,t)}})}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i=this;void 0===n&&(n=!1);var a=[],o=[];try{for(var u=m(e),l=u.next();!l.done;l=u.next()){var c=l.value,h=fr(this.channels,c,this.order),d=h.place;if(h.contains)switch(o.push(c),t){case Zt.EVENT_CHANNEL_UPDATED:case Zt.EVENT_MESSAGE_RECEIVED:this.channels.splice(d,1);var _=fr(this.channels,c,this.order).place;this.channels.splice(_,0,c);break;default:this.channels[d]=c}else d===this.channels.length?(n||!this._backgroundSync||this._backgroundSync.completed)&&(a.push(c),this.channels.push(c)):(a.push(c),this.channels.splice(d,0,c))}}catch(e){r={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}nn(t)&&$((function(){return p(i,void 0,void 0,(function(){var e,n,r;return f(this,(function(s){return e=new ar(t),a.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,a),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,o),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return nn(t)&&i.length>0&&$((function(){return p(s,void 0,void 0,(function(){var e,n;return f(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return p(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case De.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case De.CHRONOLOGICAL:return e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return p(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:return[4,rr.of(this._iid).getMyGroupChannels(this._token,o(o({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype.loadMore=function(){return p(this,void 0,void 0,(function(){var e,t=this;return f(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,b((function(){return p(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._getLocalChannels()];case 1:return e=t.sent(),[2]}}))}))}))]):[3,3];case 1:return n.sent(),[4,b((function(){return p(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._getRemoteChannels()];case 1:return e=t.sent(),[2]}}))}))}))];case 2:return n.sent(),this._addChannelsToView(e,Zt.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),rr.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Ns=function(t){function n(e){var n=this,r=e.token,s=e.limit,i=e.order,o=e.includeEmpty,u=e.membershipFilter,l=e.channelNameContainsFilter,c=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,_=e.superChannelFilter,p=e.metadataOrderKeyFilter,f=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,E=e.includeMetaData;return(n=t.call(this)||this).method=L.GET,n.path=x,n.params=a({token:r,limit:s,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Pt.PUBLIC,public_membership_mode:u,name_contains:l,channel_urls:c,custom_types:h,custom_type_startswith:d,super_mode:_,metadata_order_key:p,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:E}),n}return e(n,t),n}(R),bs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new ms(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(k);!function(e){e.ALL="all",e.JOINED="joined"}(fs||(fs={}));var Ms=function(n){function r(e,t){var r,s,i,a,o,u,l,c,h,d,_,p,f,m,v=this;return(v=n.call(this,e,t)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=fs.ALL,v.superChannelFilter=kt.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=nt.CHRONOLOGICAL,v.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:null,v.membershipFilter=null!==(c=t.membershipFilter)&&void 0!==c?c:fs.ALL,v.superChannelFilter=null!==(h=t.superChannelFilter)&&void 0!==h?h:kt.ALL,v.metadataKey=null!==(d=t.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(_=t.metadataValues)&&void 0!==_?_:null,v.metadataOrderKeyFilter=null!==(p=t.metadataOrderKeyFilter)&&void 0!==p?p:null,v.metadataValueStartsWith=null!==(f=t.metadataValueStartsWith)&&void 0!==f?f:null,v.order=null!==(m=t.order)&&void 0!==m?m:nt.CHRONOLOGICAL,v}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&t(fs,this.membershipFilter)&&t(kt,this.superChannelFilter)&&t(nt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,u,l;return f(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=Y.of(this._iid),n=t.requestQueue,r=t.dispatcher,s=new Ns(o(o({},this),{token:this._token})),[4,n.send(s)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(bs),u=a.channels,l=a.token,this._token=l,this._hasNext=!!l,r.dispatch(new rn({channels:u,source:Zt.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),Ts=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=Ae,e.onUserLeft=Ae,e.onUserReceivedInvitation=Ae,e.onUserDeclinedInvitation=Ae,e.onChannelHidden=Ae,e.onUnreadMemberStatusUpdated=Ae,e.onUndeliveredMemberStatusUpdated=Ae,e.onTypingStatusUpdated=Ae,e.onPollUpdated=Ae,e.onPollVoted=Ae,e.onPollDeleted=Ae,e.onPinnedMessageUpdated=Ae,e}return e(n,t),n}(Dt)),Us=function(t){function n(e){var n=this,r=e.token,s=e.limit,i=e.order,o=e.reverse,u=e.channelUrl,l=e.messageTypeFilter,c=e.scheduledStatus;return(n=t.call(this)||this).method=L.GET,n.path="".concat(F),n.params=a({limit:s,reverse:o,channel_url:u,order:i,status:c}),r&&(n.params.token=r),l&&(n.params.message_type=l),n}return e(n,t),n}(R),Ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return W(e,t)})),r}return e(n,t),n}(k),As=function(n){function r(e,t){var r,s,i,a,o,u=this;return(u=n.call(this,e,t)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=y.ALL,u.channelUrl=null!==(r=t.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=t.order)&&void 0!==s?s:null,u.reverse=null!==(i=t.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=t.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=t.messageTypeFilter)&&void 0!==o?o:y.ALL,u}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(t(rt,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(C,this.scheduledStatus)||null===this.scheduledStatus)&&t(y,this.messageTypeFilter)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return f(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Y.of(this._iid).requestQueue,t=new Us(o(o({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=a.sent(),r=n.as(Ss),s=r.scheduledMessages,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw z.queryInProgress;case 4:return[3,6];case 5:throw z.invalidParameters;case 6:return[2]}}))}))},r}(j),Is=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new rr(e,{sdkState:r,cacheContext:l,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Cs(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new $n(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Ms(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new As(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){ne(g("string",e)&&t instanceof Ts).throw(z.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){ne(g("string",e)).throw(z.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return ne(g("string",e)).throw(z.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return ne(g("string",e)).throw(z.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=o(o({},Kt),t),ne(g("string",e)&&Yt(n)).throw(z.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return n=o(o({},Kt),t),ne(g("number",e)&&Yt(n)).throw(z.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},Jt),e),ne(Xt(t)).throw(z.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return f(this,(function(n){return t=o(o({},zt),e),ne(Wt(t)).throw(z.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,s,i){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===s&&(s=""),void 0===i&&(i=""),p(this,void 0,void 0,(function(){var a;return f(this,(function(u){return a=o(o({},zt),{invitedUserIds:e,isDistinct:t,name:n,data:s,customType:i}),"string"==typeof r?a.coverUrl=r:a.coverImage=r,[2,this.createChannel(a)]}))}))},n.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){return f(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){return ne(v("string",e)).throw(z.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return ne(g("string",e)).throw(z.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(Ie);export{hs as CountPreference,ms as GroupChannel,Cs as GroupChannelCollection,ar as GroupChannelEventContext,Zt as GroupChannelEventSource,Qt as GroupChannelFilter,Ts as GroupChannelHandler,$n as GroupChannelListQuery,Is as GroupChannelModule,Vt as GroupChannelSearchField,xt as HiddenChannelFilter,_s as HiddenState,Gt as Member,br as MemberListOrder,Dr as MemberListQuery,Lt as MemberState,Mr as MemberStateFilter,fs as MembershipFilter,Ur as MessageCollection,Tr as MessageCollectionInitHandler,sr as MessageCollectionInitPolicy,or as MessageEventContext,Nr as MutedMemberFilter,ds as MutedState,Rt as MyMemberStateFilter,Ft as OperatorFilter,Pt as PublicChannelFilter,Ms as PublicGroupChannelListQuery,Ht as QueryType,qt as ReadStatus,As as ScheduledMessageListQuery,kt as SuperChannelFilter,Ot as UnreadChannelFilter,Bt as UnreadItemKey}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index d6f1f54..1774387 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -167,7 +167,7 @@ export declare class BaseMessage { applyParentMessage(parentMessage: BaseMessage): boolean; } -declare interface BaseMessageCreateParams { +export declare interface BaseMessageCreateParams { data?: string; customType?: string; mentionType?: MentionType; @@ -182,7 +182,7 @@ declare interface BaseMessageCreateParams { isPinnedMessage?: boolean; } -declare interface BaseMessageUpdateParams { +export declare interface BaseMessageUpdateParams { data?: string; customType?: string; mentionType?: MentionType; @@ -645,7 +645,16 @@ export declare interface MessageCollectionEventHandler { onChannelDeleted: (context: GroupChannelEventContext, channelUrl: string) => void; onMessagesAdded: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; onMessagesUpdated: (context: MessageEventContext, channel: GroupChannel, messages: BaseMessage[]) => void; - onMessagesDeleted: (context: MessageEventContext, channel: GroupChannel, messageIds: number[]) => void; + /** + * + * @param messageIds Deprecated since v4.3.1. Use messages instead. + */ + onMessagesDeleted: ( + context: MessageEventContext, + channel: GroupChannel, + messageIds: number[], + messages: BaseMessage[], + ) => void; onHugeGapDetected: () => void; } @@ -678,7 +687,13 @@ export declare enum MessageEventSource { EVENT_MESSAGE_RECEIVED = 'EVENT_MESSAGE_RECEIVED', EVENT_MESSAGE_UPDATED = 'EVENT_MESSAGE_UPDATED', EVENT_MESSAGE_DELETED = 'EVENT_MESSAGE_DELETED', + /** + * @deprecated since v4.3.1 + */ EVENT_MESSAGE_READ = 'EVENT_MESSAGE_READ', + /** + * @deprecated since v4.3.1 + */ EVENT_MESSAGE_DELIVERED = 'EVENT_MESSAGE_DELIVERED', EVENT_MESSAGE_REACTION_UPDATED = 'EVENT_MESSAGE_REACTION_UPDATED', EVENT_MESSAGE_THREADINFO_UPDATED = 'EVENT_MESSAGE_THREADINFO_UPDATED', diff --git a/message.d.ts b/message.d.ts index a8d0125..f93f0cd 100644 --- a/message.d.ts +++ b/message.d.ts @@ -2,6 +2,8 @@ export { AdminMessage, AppleCriticalAlertOptions, BaseMessage, + BaseMessageCreateParams, + BaseMessageUpdateParams, FailedMessageHandler, FileInfo, FileMessage, diff --git a/message.js b/message.js index f893890..5d1d1bb 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{a_ as AdminMessage,ak as AppleCriticalAlertOptions,aE as BaseMessage,F as FileMessage,ah as MentionType,ai as MessageMetaArray,ac as MessageModule,ay as MessageRequestHandler,b2 as MessageSearchOrder,a4 as MessageSearchQuery,t as MessageType,s as MessageTypeFilter,b3 as OGImage,b4 as OGMetaData,au as PreviousMessageListQuery,aj as PushNotificationDeliveryOption,b5 as Reaction,aq as ReactionEvent,b6 as ReactionEventOperation,R as ReplyType,av as Sender,D as SendingStatus,b7 as ThreadInfo,a$ as ThreadInfoUpdateEvent,as as Thumbnail,x as UserMessage}from"./__bundle-2a729281.js"; +export{aZ as AdminMessage,ak as AppleCriticalAlertOptions,aE as BaseMessage,F as FileMessage,ah as MentionType,ai as MessageMetaArray,ab as MessageModule,ay as MessageRequestHandler,b1 as MessageSearchOrder,a3 as MessageSearchQuery,t as MessageType,s as MessageTypeFilter,b2 as OGImage,b3 as OGMetaData,au as PreviousMessageListQuery,aj as PushNotificationDeliveryOption,b4 as Reaction,aq as ReactionEvent,b5 as ReactionEventOperation,R as ReplyType,av as Sender,D as SendingStatus,b6 as ThreadInfo,a_ as ThreadInfoUpdateEvent,as as Thumbnail,y as UserMessage}from"./__bundle-7175498d.js"; diff --git a/openChannel.js b/openChannel.js index f19b3e8..a461f55 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as n,j as e,k as t,I as r,T as a,i,q as s,A as o,b0 as u,b1 as c,b as l,c as h,e as d,an as p,U as f,W as C,H as v,J as _,z as y,a5 as m,ax as g,a6 as E,C as U,aT as w,u as T,S as N,l as M,n as H,V as b,aR as I,y as O,r as D,X as x,o as P}from"./__bundle-2a729281.js";import{j as A,k as R,l as L,n as k,m as F,o as S,p as q,D as Q,q as z,r as K,t as W,P as j,e as G}from"./__bundle-a9c3db53.js";import{C as B,a as X,O as V,M as Y,T as Z,R as J,U as $,A as nn,B as en}from"./__bundle-43418632.js";var tn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),rn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"SYEV",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(B),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(B),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;return dn[n]||(this._iid=n,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new tn(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof C)i._handleEvent(n);else if(n instanceof v&&n.stateType===_.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=y(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this),dn[n]}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new En(this._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=y(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,C,v,_,m,T,N,M,H,b,I,O,D,x,P,j,G,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,Cn,vn,_n,yn,mn,gn,En,Un,wn,Tn,Nn,Mn,Hn,bn,In,On,Dn,xn,Pn,An,Rn,Ln=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as(nn)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&(s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r))}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(z):"FEDI"===n.code?s=n.as(K):"AEDI"===n.code&&(s=n.as($)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:c=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated(c,o),u>0&&r.onMentionReceived(c,o))}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return l=n.as(Q),I=l.channelUrl,f=l.channelType,h=l.messageId,f!==U.OPEN?[3,9]:[4,this.getChannel(I,!0)];case 8:d=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted(d,h)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return p=n.as(J),I=p.channelUrl,f=p.channelType,C=p.event,f!==U.OPEN?[3,12]:[4,this.getChannel(I,!0)];case 11:v=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated(v,C)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(_=n.as(Z).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:m=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(m.url)&&r.onThreadInfoUpdated(m,_)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:T=n.as(Y).openChannelMemberCounts,N=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),M=y(T),H=M.next(),kn.label=18;case 18:return H.done?[3,21]:(b=H.value,I=b.channelUrl,sn=b.participantCount,O=b.updatedAt,[4,this.getChannelFromCache(I)]);case 19:(D=kn.sent())&&D._updateParticipantCount(sn,O)&&N.push(D),kn.label=20;case 20:return H=M.next(),[3,18];case 21:return[3,24];case 22:return x=kn.sent(),An={error:x},[3,24];case 23:try{H&&!H.done&&(Rn=M.return)&&Rn.call(M)}finally{if(An)throw An.error}return[7];case 24:return N.length>0?[4,this.upsertChannelsToCache(N)]:[3,26];case 25:kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(N)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(P=n.as(B).event).isOpenChannelEvent)return[3,49];switch(P.category){case X.CHANNEL_ENTER:return[3,28];case X.CHANNEL_EXIT:return[3,30];case X.CHANNEL_OPERATOR_UPDATE:return[3,32];case X.USER_CHANNEL_MUTE:case X.USER_CHANNEL_UNMUTE:return[3,34];case X.USER_CHANNEL_BAN:case X.USER_CHANNEL_UNBAN:return[3,36];case X.CHANNEL_FREEZE:case X.CHANNEL_UNFREEZE:return[3,38];case X.CHANNEL_DELETED:return[3,40];case X.CHANNEL_PROP_CHANGED:return[3,43];case X.CHANNEL_META_DATA_CHANGED:return[3,45];case X.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(P.channelUrl,!0)];case 29:return j=kn.sent(),G=n.as(cn),sn=G.participantCount,en=G.user,tn=j._updateParticipantCount(sn,P.ts),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(j,en),tn&&n.onChannelParticipantCountChanged(j)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(P.channelUrl,!0)];case 31:return rn=kn.sent(),an=n.as(hn),sn=an.participantCount,on=an.user,un=rn._updateParticipantCount(sn,P.ts),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(rn,on),un&&n.onChannelParticipantCountChanged(rn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(P.channelUrl,!0)];case 33:return ln=kn.sent(),dn=n.as(V).operators,ln.operators=dn,this.upsertChannelsToCache([ln]),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(ln,dn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(P.channelUrl,!0)];case 35:return pn=kn.sent(),fn=P.category===X.USER_CHANNEL_MUTE,Cn=n.as(fn?S:q).user,E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){fn?n.onUserMuted(pn,Cn):n.onUserUnmuted(pn,Cn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(P.channelUrl,!0)];case 37:return vn=kn.sent(),_n=P.category===X.USER_CHANNEL_BAN,yn=n.as(_n?k:F).user,E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){_n?n.onUserBanned(vn,yn):n.onUserUnbanned(vn,yn)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(P.channelUrl,!0)];case 39:return mn=kn.sent(),gn=n.as(L).freeze,mn.isFrozen=gn,this.upsertChannelsToCache([mn]),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){gn?n.onChannelFrozen(mn):n.onChannelUnfrozen(mn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(P.channelUrl,!0)];case 41:return En=kn.sent(),[4,this.removeChannelsFromCache([En.url])];case 42:return kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(En.url,En.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(P.channelUrl,!0)];case 44:return Un=kn.sent(),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(P.channelUrl,!0)];case 46:return wn=kn.sent(),Tn=n.as(R),Nn=Tn.created,Mn=Tn.updated,Hn=Tn.deleted,Nn&&wn._upsertCachedMetaData(Nn,P.ts),Mn&&wn._upsertCachedMetaData(Mn,P.ts),Hn&&wn._removeFromCachedMetaData(Hn,P.ts),E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Nn&&n.onMetaDataCreated(wn,Nn),Mn&&n.onMetaDataUpdated(wn,Mn),Hn&&n.onMetaDataDeleted(wn,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(P.channelUrl,!0)];case 48:return bn=kn.sent(),In=n.as(A),On=In.created,Dn=In.updated,xn=In.deleted,E((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(bn,On),Dn&&n.onMetaCounterUpdated(bn,Dn),xn&&n.onMetaCounterDeleted(bn,xn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Pn=kn.sent(),g(Pn))throw Pn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:T(i("string",n)).throw(N.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return T(i("string",n)).throw(N.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u;return t(this,(function(t){switch(t.label){case 0:return e=M(M({},rn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)&&(i("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl)}(e)).throw(N.invalidParameters),r=new on(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(sn).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),fn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),vn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new j(n,e)})),r}return n(t,e),t}(h),_n=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=b.of(this._iid).requestQueue,e=new Cn(M(M({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(vn),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},a}(H),yn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l),mn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),gn=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function o(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new f(n,e)})):[],a}return n(o,r),o.payloadify=function(n){return n?d(M(M({},G.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return I(this)},o.prototype.isOperator=function(n){return n instanceof f?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},o.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},o.prototype.createParticipantListQuery=function(n){return new _n(this._iid,this.url,n)},o.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},o.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=b.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=b.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),O.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u,c;return t(this,(function(t){switch(t.label){case 0:return e=M(M({},fn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)}(e)).throw(N.invalidParameters),r=b.of(this._iid).requestQueue,o=new yn(M({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(mn).channel,[4,pn.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,c]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return e=M(M({},fn),{name:n,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(e)]}))}))},o.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=b.of(this._iid).requestQueue,e=new gn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(n){return T(!n.isPinnedMessage).throw(N.notSupportedError),r.prototype.sendUserMessage.call(this,n)},o.prototype.sendFileMessage=function(n){return T(!n.isPinnedMessage).throw(N.notSupportedError),r.prototype.sendFileMessage.call(this,n)},o}(G),Un=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=D,n.onUserExited=D,n.onChannelParticipantCountChanged=D,n}return n(t,e),t}(en)),wn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Tn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Nn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=b.of(this._iid).requestQueue,e=new wn(M(M({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Tn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw N.queryInProgress;case 5:return[3,7];case 6:throw N.invalidParameters;case 7:return[2]}}))}))},s}(x),Mn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Nn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=M({},rn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(P);export{En as OpenChannel,Un as OpenChannelHandler,Nn as OpenChannelListQuery,Mn as OpenChannelModule,_n as ParticipantListQuery}; +import{_ as n,j as e,k as t,I as r,T as a,i,q as s,A as o,a$ as u,b0 as c,b as l,c as h,e as d,an as p,U as f,W as C,H as v,J as _,x as y,a4 as m,ax as g,a5 as E,C as U,aS as w,u as T,S as N,l as M,n as H,V as I,aQ as b,z as O,r as x,X as D,o as P}from"./__bundle-7175498d.js";import{j as A,k as L,l as R,n as k,m as F,o as S,p as q,D as Q,q as z,r as K,t as W,P as j,e as G}from"./__bundle-d8d501e8.js";import{C as B,a as X,O as V,M as Y,T as Z,R as $,U as J,A as nn,B as en}from"./__bundle-c20e72f4.js";var tn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),rn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"SYEV",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(B),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(B),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;return dn[n]||(this._iid=n,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new tn(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof C)i._handleEvent(n);else if(n instanceof v&&n.stateType===_.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=y(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this),dn[n]}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new En(this._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=y(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,C,v,_,m,T,N,M,H,I,b,O,x,D,P,j,G,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,Cn,vn,_n,yn,mn,gn,En,Un,wn,Tn,Nn,Mn,Hn,In,bn,On,xn,Dn,Pn,An,Ln,Rn=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as(nn)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&(s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r))}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(z):"FEDI"===n.code?s=n.as(K):"AEDI"===n.code&&(s=n.as(J)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:c=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated(c,o),u>0&&r.onMentionReceived(c,o))}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return l=n.as(Q),b=l.channelUrl,f=l.channelType,h=l.messageId,f!==U.OPEN?[3,9]:[4,this.getChannel(b,!0)];case 8:d=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted(d,h)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return p=n.as($),b=p.channelUrl,f=p.channelType,C=p.event,f!==U.OPEN?[3,12]:[4,this.getChannel(b,!0)];case 11:v=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated(v,C)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(_=n.as(Z).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:m=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(m.url)&&r.onThreadInfoUpdated(m,_)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:T=n.as(Y).openChannelMemberCounts,N=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),M=y(T),H=M.next(),kn.label=18;case 18:return H.done?[3,21]:(I=H.value,b=I.channelUrl,sn=I.participantCount,O=I.updatedAt,[4,this.getChannelFromCache(b)]);case 19:(x=kn.sent())&&x._updateParticipantCount(sn,O)&&N.push(x),kn.label=20;case 20:return H=M.next(),[3,18];case 21:return[3,24];case 22:return D=kn.sent(),An={error:D},[3,24];case 23:try{H&&!H.done&&(Ln=M.return)&&Ln.call(M)}finally{if(An)throw An.error}return[7];case 24:return N.length>0?[4,this.upsertChannelsToCache(N)]:[3,26];case 25:kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(N)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(P=n.as(B).event).isOpenChannelEvent)return[3,49];switch(P.category){case X.CHANNEL_ENTER:return[3,28];case X.CHANNEL_EXIT:return[3,30];case X.CHANNEL_OPERATOR_UPDATE:return[3,32];case X.USER_CHANNEL_MUTE:case X.USER_CHANNEL_UNMUTE:return[3,34];case X.USER_CHANNEL_BAN:case X.USER_CHANNEL_UNBAN:return[3,36];case X.CHANNEL_FREEZE:case X.CHANNEL_UNFREEZE:return[3,38];case X.CHANNEL_DELETED:return[3,40];case X.CHANNEL_PROP_CHANGED:return[3,43];case X.CHANNEL_META_DATA_CHANGED:return[3,45];case X.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(P.channelUrl,!0)];case 29:return j=kn.sent(),G=n.as(cn),sn=G.participantCount,en=G.user,tn=j._updateParticipantCount(sn,P.ts),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(j,en),tn&&n.onChannelParticipantCountChanged(j)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(P.channelUrl,!0)];case 31:return rn=kn.sent(),an=n.as(hn),sn=an.participantCount,on=an.user,un=rn._updateParticipantCount(sn,P.ts),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(rn,on),un&&n.onChannelParticipantCountChanged(rn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(P.channelUrl,!0)];case 33:return ln=kn.sent(),dn=n.as(V).operators,ln.operators=dn,this.upsertChannelsToCache([ln]),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(ln,dn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(P.channelUrl,!0)];case 35:return pn=kn.sent(),fn=P.category===X.USER_CHANNEL_MUTE,Cn=n.as(fn?S:q).user,E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){fn?n.onUserMuted(pn,Cn):n.onUserUnmuted(pn,Cn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(P.channelUrl,!0)];case 37:return vn=kn.sent(),_n=P.category===X.USER_CHANNEL_BAN,yn=n.as(_n?k:F).user,E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){_n?n.onUserBanned(vn,yn):n.onUserUnbanned(vn,yn)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(P.channelUrl,!0)];case 39:return mn=kn.sent(),gn=n.as(R).freeze,mn.isFrozen=gn,this.upsertChannelsToCache([mn]),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){gn?n.onChannelFrozen(mn):n.onChannelUnfrozen(mn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(P.channelUrl,!0)];case 41:return En=kn.sent(),[4,this.removeChannelsFromCache([En.url])];case 42:return kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(En.url,En.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(P.channelUrl,!0)];case 44:return Un=kn.sent(),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(P.channelUrl,!0)];case 46:return wn=kn.sent(),Tn=n.as(L),Nn=Tn.created,Mn=Tn.updated,Hn=Tn.deleted,Nn&&wn._upsertCachedMetaData(Nn,P.ts),Mn&&wn._upsertCachedMetaData(Mn,P.ts),Hn&&wn._removeFromCachedMetaData(Hn,P.ts),E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Nn&&n.onMetaDataCreated(wn,Nn),Mn&&n.onMetaDataUpdated(wn,Mn),Hn&&n.onMetaDataDeleted(wn,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(P.channelUrl,!0)];case 48:return In=kn.sent(),bn=n.as(A),On=bn.created,xn=bn.updated,Dn=bn.deleted,E((function(){return e(Rn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(In,On),xn&&n.onMetaCounterUpdated(In,xn),Dn&&n.onMetaCounterDeleted(In,Dn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Pn=kn.sent(),g(Pn))throw Pn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:T(i("string",n)).throw(N.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return T(i("string",n)).throw(N.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u;return t(this,(function(t){switch(t.label){case 0:return e=M(M({},rn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)&&(i("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl)}(e)).throw(N.invalidParameters),r=new on(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(sn).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),fn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),vn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new j(n,e)})),r}return n(t,e),t}(h),_n=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=I.of(this._iid).requestQueue,e=new Cn(M(M({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(vn),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},a}(H),yn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l),mn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),gn=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function o(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new f(n,e)})):[],a}return n(o,r),o.payloadify=function(n){return n?d(M(M({},G.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return b(this)},o.prototype.isOperator=function(n){return n instanceof f?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},o.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},o.prototype.createParticipantListQuery=function(n){return new _n(this._iid,this.url,n)},o.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},o.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=I.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=I.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),O.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u,c;return t(this,(function(t){switch(t.label){case 0:return e=M(M({},fn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)}(e)).throw(N.invalidParameters),r=I.of(this._iid).requestQueue,o=new yn(M({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(mn).channel,[4,pn.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,c]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return e=M(M({},fn),{name:n,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(e)]}))}))},o.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=I.of(this._iid).requestQueue,e=new gn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(n){return T(!n.isPinnedMessage).throw(N.notSupportedError),r.prototype.sendUserMessage.call(this,n)},o.prototype.sendFileMessage=function(n){return T(!n.isPinnedMessage).throw(N.notSupportedError),r.prototype.sendFileMessage.call(this,n)},o}(G),Un=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=x,n.onUserExited=x,n.onChannelParticipantCountChanged=x,n}return n(t,e),t}(en)),wn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Tn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Nn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=I.of(this._iid).requestQueue,e=new wn(M(M({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Tn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw N.queryInProgress;case 5:return[3,7];case 6:throw N.invalidParameters;case 7:return[2]}}))}))},s}(D),Mn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Nn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=M({},rn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(P);export{En as OpenChannel,Un as OpenChannelHandler,Nn as OpenChannelListQuery,Mn as OpenChannelModule,_n as ParticipantListQuery}; diff --git a/package.json b/package.json index 9650f22..a7e2198 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.3.0", + "version": "4.3.1", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index e9a3178..4562ad0 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -export{P as Poll,d as PollOption,p as PollStatus}from"./__bundle-2a729281.js";export{m as PollListQuery,t as PollModule,P as PollUpdateEvent,b as PollVoteEvent,n as PollVoterListQuery}from"./__bundle-ee341ede.js";import"./__bundle-a9c3db53.js"; +export{P as Poll,d as PollOption,p as PollStatus}from"./__bundle-7175498d.js";export{m as PollListQuery,t as PollModule,P as PollUpdateEvent,b as PollVoteEvent,n as PollVoterListQuery}from"./__bundle-c01340eb.js";import"./__bundle-d8d501e8.js"; diff --git a/sendbird.js b/sendbird.js index 4b307c3..e07b4a5 100644 --- a/sendbird.js +++ b/sendbird.js @@ -1 +1 @@ -export{C as ChannelType,a3 as ConnectionState,ad as LogLevel,ae as Plugin,af as Role,aa as SendbirdChatOptions,S as SendbirdError,U as User,ag as UserOnlineState}from"./__bundle-2a729281.js";export{w as ApplicationUserListQuery,B as BlockedUserListQuery,C as ConnectionHandler,E as Emoji,x as EmojiCategory,y as EmojiContainer,F as FriendListQuery,z as MemoryStore,H as PushTemplate,I as PushTokenRegistrationState,J as PushTokenType,o as PushTriggerOption,K as SessionHandler,L as UserEventHandler,u as default}from"./__bundle-ee341ede.js";export{d as BannedUserListQuery,e as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,P as Participant,R as ReportCategory,f as RestrictedUser,g as RestrictionInfo,h as RestrictionType}from"./__bundle-a9c3db53.js"; +export{C as ChannelType,a2 as ConnectionState,ad as LogLevel,ae as Plugin,af as Role,a9 as SendbirdChatOptions,S as SendbirdError,U as User,ag as UserOnlineState}from"./__bundle-7175498d.js";export{w as ApplicationUserListQuery,B as BlockedUserListQuery,C as ConnectionHandler,E as Emoji,x as EmojiCategory,y as EmojiContainer,F as FriendListQuery,z as MemoryStore,H as PushTemplate,I as PushTokenRegistrationState,J as PushTokenType,o as PushTriggerOption,K as SessionHandler,L as UserEventHandler,u as default}from"./__bundle-c01340eb.js";export{d as BannedUserListQuery,e as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,P as Participant,R as ReportCategory,f as RestrictedUser,g as RestrictionInfo,h as RestrictionType}from"./__bundle-d8d501e8.js"; diff --git a/sendbird.min.js b/sendbird.min.js index 2e20919..ab37a31 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -12,4 +12,4 @@ var Sendbird=function(e){"use strict";function t(e){return t="function"==typeof LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}var b,w="4.3.0",C=function(){function e(){n(this,e)}return a(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED"}(b||(b={}));var R,x=function(e){return!(e instanceof T&&!e.shouldThrowOutside)},T=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.code,s=void 0===i?0:i,o=e.message;return n(this,r),(a=t.call(this,o)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=s,Object.setPrototypeOf(h(a),r.prototype),a}return a(r,[{key:"isInvalidTokenError",get:function(){return this.code===b.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===b.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===b.SESSION_KEY_EXPIRED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new r({code:b.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new r({code:b.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new r({code:b.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new r({code:b.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new r({code:b.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new r({code:b.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new r({code:b.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new r({code:b.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new r({code:b.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new r({code:b.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new r({code:b.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new r({code:b.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new r({code:b.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new r({code:b.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new r({code:b.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new r({code:b.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new r({code:b.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new r({code:b.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new r({code:b.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}}]),r}(l(Error)),I=[b.CONNECTION_REQUIRED,b.NETWORK_ERROR,b.ACK_TIMEOUT,b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.FILE_UPLOAD_CANCEL_FAILED,b.REQUEST_CANCELED,b.INTERNAL_SERVER_ERROR,b.RATE_LIMIT_EXCEEDED,b.UNKNOWN_SERVER_ERROR],S=[b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.CONNECTION_REQUIRED],N=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},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},M=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!r||null!=n)||("string"!=typeof e?"object"===t(e)?A(e,n):U(e,n):t(n)===e)},A=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!n||null!=t)||Object.values(e).includes(t)},U=function(e,t){return t instanceof e},O=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!n||null!=t)||Array.isArray(t)&&t.every((function(t){return M(e,t)}))},L=function(e){return e>0&&S.indexOf(e)>=0},D=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t&&null===e)return!0;var n=M("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},P=1e4,F=1e3,G=1e4,q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.useMemberInfoInMessage,a=void 0===r||r,i=t.typingIndicatorInvalidateTime,s=void 0===i?P:i,o=t.typingIndicatorThrottle,u=void 0===o?F:o,c=t.websocketResponseTimeout,l=void 0===c?G:c,h=t.sessionTokenRefreshTimeout,d=void 0===h?60:h;n(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=P,this._typingIndicatorThrottle=F,this._websocketResponseTimeout=G,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=d}return a(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){M("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){M("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){M("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){M("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){M("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),H={encrypt:function(e){return e},decrypt:function(e){return e}},V=function(){function e(t){var r=t.store;n(this,e),this._preference=new Map,this._store=r}return a(e,[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:g(this._preference.keys()),generation:1});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._keysAddress=e,n.next=3,this._store.get(e);case 3:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=7;break}n.t0=void 0!==t;case 7:if(!n.t0){n.next=11;break}n.t2=t,n.next=12;break;case 11:n.t2=[];case 12:r=n.t2,a=k(r),n.prev=14,a.s();case 16:if((i=a.n()).done){n.next=24;break}return s=i.value,n.next=20,this._store.get(s);case 20:(o=n.sent)&&this._preference.set(s,o);case 22:n.next=16;break;case 24:n.next=29;break;case 26:n.prev=26,n.t3=n.catch(14),a.e(n.t3);case 29:return n.prev=29,a.f(),n.finish(29);case 32:case"end":return n.stop()}}),n,this,[[14,26,29,32]])})))}},{key:"get",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null!==(t=this._preference.get(e))&&void 0!==t?t:null);case 1:case"end":return n.stop()}}),n,this)})))}},{key:"set",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=!this._preference.has(e),n.next=3,this._store.set({key:e,value:t,generation:1});case 3:if(this._preference.set(e,t),!r){n.next=7;break}return n.next=7,this._savePreferenceKeys();case 7:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.remove(e);case 2:return this._preference.delete(e),t.next=5,this._savePreferenceKeys();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.removeMany(g(this._preference.keys()));case 2:return this._preference.clear(),e.next=5,this._savePreferenceKeys();case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),j=a((function e(t){var r=t.encryption,a=void 0===r?null:r,i=t.store,s=void 0===i?null:i,o=t.localCacheEnabled,u=void 0===o||o;n(this,e),this.nestdb=null,this.store=s,this.preference=new V({store:s}),this.encryption=null!=a?a:H,this.localCacheEnabled=u})),Q=function(){function e(){n(this,e),this.sessionKey=null,this.authToken=null}return a(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),B=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)}))},K=function(){function e(t){var r=t.container;n(this,e),this._container={},this._container=r,this.key=B()}return a(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),z=function(){function e(){n(this,e),this._container={}}return a(e,[{key:"on",value:function(e,t){return new K({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new K({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=k(n.keys());try{for(i.s();!(r=i.n()).done;){var s=r.value,o=n.get(s);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(s))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),W=function(){function e(){n(this,e),this._dispatcher=new z}return a(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),Y=a((function e(){n(this,e)})),J=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(R||(R={}));var X,Z=function(e){i(s,e);var r=p(s);function s(){var e;return n(this,s),(e=r.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=B(),e}return a(s,[{key:"stringifyParams",value:function(e){return"object"!==t(e)||Array.isArray(e)?String(e):e?JSON.stringify(e):""}},{key:"encodeParams",value:function(e){var n=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return n.encodeParams(e)})).join(","):"object"===t(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=J(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=this,t=J(this.params);if(Object.keys(t).some((function(e){return D(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var a,i=t[r];if(D(i)){var s=i;n.append(r,s,null!==(a=s.name)&&void 0!==a?a:"filename")}else n.append(r,e.stringifyParams(i))})),n}return JSON.stringify(t)}}]),s}(Y),$=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this))._iid=e,i._payload=a,i}return a(r,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),r}(Y),ee=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).requestId=e,a}return a(r)}(Y),te=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r)}(Y),ne=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).statLog=e,a}return a(r)}(Y);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(X||(X={}));var re,ae=function(){function e(t){var r=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;n(this,e),this.type=r,this.createdAt=s,this.data=a}return a(e,null,[{key:"payloadify",value:function(e){return J({stat_type:e.type,ts:e.createdAt,data:J(e.data)})}}]),e}(),ie=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._abortControl=new Map,this._iid=t,this._auth=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ee&&a.cancel(e.requestId)})),this._logger=u}return a(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,i=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(i["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(i["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(i["App-Id"]=r,i["Access-Token"]=this._auth.authToken),i}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new ne(new ae({type:X.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p,f,v,m;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.path,r=e.method,a=![R.GET,R.DELETE].includes(r),i=this._sdkState.api,s="".concat(i.host).concat(n).concat(a?"":e.query),o=a?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),t.prev=10,t.next=13,fetch(s,{method:r,body:o,headers:u,signal:l});case 13:return d=t.sent,t.next=16,d.json();case 16:if(p=t.sent,!d.ok&&!d.redirected){t.next=23;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),t.abrupt("return",new $(this._iid,p));case 23:if(!p){t.next=30;break}throw f=new T(p),!e.requireAuth&&f.isSessionKeyExpiredError&&this._dispatcher.dispatch(new te),this._statLogApiResult(e,h,f),f;case 30:throw v=T.requestFailed,this._statLogApiResult(e,h,v),v;case 33:t.next=50;break;case 35:if(t.prev=35,t.t0=t.catch(10),this._statLogApiResult(e,h,t.t0),!(t.t0 instanceof T)){t.next=43;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 43:if("AbortError"!==t.t0.name){t.next=47;break}throw T.requestCanceled;case 47:throw m=T.networkError,this._logger.debug("fail api request",m),m;case 50:case"end":return t.stop()}}),t,this,[[10,35]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=k(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),se=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return n(this,r),(s=t.call(this))._iid=e,s.code=a,s.payload=i,s.requestId=i?i.req_id:o,s}return a(r,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var n=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){n="NOOP"}finally{return new r(e,n,a)}}}]),r}(Y),oe=function(){};e.ConnectionState=void 0,(re=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",re.OPEN="OPEN",re.CLOSED="CLOSED";var ue,ce=function(t){i(s,t);var r=p(s);function s(e,t){var a,i=t.sdkState,o=t.dispatcher,u=t.logger;return n(this,s),(a=r.call(this)).lastActive=0,a._iid=e,a._sdkState=i,a._dispatcher=o,a._logger=u,a}return a(s,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"connect",value:function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&M("string",e)){var n=se.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new te):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",T.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=oe,t._ws.onmessage=oe,t._ws.onerror=oe,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw T.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),s}(z),le=function(e){i(r,e);var t=p(r);function r(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return n(this,r),(a=t.call(this)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:B(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return a(r,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),r}(Y),he=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.all,s=e.custom_types,o=e.ts;return n(this,r),(a=t.call(this)).all=i,a.customTypes=s,a.ts=o,a}return a(r)}(Y),de=a((function e(){var t=this;n(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),pe=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=o,this._logger=u,this.apiClient=new ie(t,{auth:i,sdkState:s,dispatcher:o,logger:u}),this.websocketClient=new ce(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new he(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new T({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(T.connectionClosed)})),a._ackStateMap.clear()}))}return a(e,[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=new de,e.ackRequired){r=null,a=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),n.resolve(a)))};try{r=setTimeout((function(){return a(T.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(null,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve(null)}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Z)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof le)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw T.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(ue||(ue={}));var fe,ve=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.stateType;return n(this,r),(a=t.call(this)).stateType=i,a}return a(r)}(Y),me=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._currentConnectionStateType=ue.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new pe(t,{auth:i,sdkState:s,dispatcher:o,logger:u}),this._auth=i,this._logger=u,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof ve){var t=e.stateType;switch(a._currentConnectionStateType=t,t){case ue.CONNECTED:var n=a._lazyCallQueue;a._lazyCallQueue=[],n.forEach((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.command,r=e.deferred,a=e.timeout,clearTimeout(a),t.prev=2,t.next=5,this.send(n);case 5:i=t.sent,r.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r.reject(t.t0);case 12:case"end":return t.stop()}}),t,this,[[2,9]])})))}));break;case ue.INITIALIZED:case ue.DISCONNECTED:case ue.LOGOUT:var r=a._lazyCallQueue;a._lazyCallQueue=[],r.forEach((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.deferred,r=e.timeout,clearTimeout(r),this._auth&&this._auth.hasSession?n.reject(T.connectionClosed):n.reject(T.connectionRequired);case 3:case"end":return t.stop()}}),t,this)})))}))}}}))}return a(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===ue.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===ue.CONNECTING||this._currentConnectionStateType===ue.RECONNECTING}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof le)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new de,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),T.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof Z)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),r=new de,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 34:throw a=T.connectionRequired,this._logger.debug("fail api request",a),a;case 37:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(T.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),ge="v3",_e="/".concat(ge,"/users"),ye="/".concat(ge,"/storage/file"),ke="/".concat(ge,"/group_channels"),Ee="/".concat(ge,"/sdk/group_channels"),be="/".concat(ge,"/open_channels"),we="/".concat(ge,"/sdk/open_channels"),Ce="/".concat(ge,"/search"),Re="/".concat(ge,"/report"),xe="/".concat(ge,"/emojis"),Te="/".concat(ge,"/emoji_categories"),Ie="/".concat(ge,"/polls"),Se="/".concat(ge,"/scheduled_messages"),Ne="/".concat(ge,"/sdk/statistics"),Me=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.authToken,o=e.expiringSession,u=void 0===o||o;return n(this,r),(a=t.call(this)).path="".concat(_e,"/").concat(i,"/session_key"),a.method=R.POST,a.params={token:s,expiring_session:!!u},a.requireAuth=!1,a}return a(r)}(Z),Ae=function(e){i(r,e);var t=p(r);function r(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?null:o;return n(this,r),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:s?1:0,req_id:u},ackRequired:!0})}return a(r)}(le),Ue=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),i=t.call(this,e,a);var s=a.key;return i.key=s,i}return a(r)}($),Oe=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"LOGI",i)).error=null,s.newKey=i.new_key,s.error=i.error?new T(i.error):null,s}return a(r)}(se),Le=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r)}(Y),De=function(e){return E(void 0,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},Pe=function(){function e(){n(this,e)}return a(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Fe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Pe;return E(void 0,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a1&&void 0!==arguments[1]?arguments[1]:null;return new Ae({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Oe),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Me({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),t.next=3,Fe((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(Ue),i=a.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),t,this,[[0,8]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==ue.CONNECTED){n.next=23;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:if(n.prev=8,n.t0=n.catch(1),!this._isSessionRelatedError(n.t0)){n.next=23;break}if(!t){n.next=23;break}return n.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=n.sent,!this.auth.authToken){n.next=21;break}return n.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),n.next=22;break;case 21:this.close();case 22:return n.abrupt("return");case 23:return n.prev=23,n.next=26,this._refreshSessionKeyByApi(e);case 26:this.complete(),n.next=49;break;case 29:if(n.prev=29,n.t1=n.catch(23),!this._isSessionRelatedError(n.t1)){n.next=48;break}if(!t){n.next=45;break}return n.next=35,this._receiveNewAuthToken();case 35:if(this.auth.authToken=n.sent,!this.auth.authToken){n.next=42;break}return n.next=39,this._refreshSessionKeyByApi(this.auth.authToken);case 39:this.complete(),n.next=43;break;case 42:this.close();case 43:n.next=46;break;case 45:throw n.t1;case 46:n.next=49;break;case 48:throw n.t1;case 49:case"end":return n.stop()}}),n,this,[[1,8],[23,29]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,t=new de;return Ge((function(){return E(e,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),n=null,r=function(){n&&(clearTimeout(n),n=null)},n=setTimeout((function(){a._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){r(),a._isRefreshingAuthToken&&(a._isRefreshingAuthToken=!1,a.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){r(),a._isRefreshingAuthToken=!1,t.reject(e)}));case 6:case"end":return e.stop()}}),e,this)})))})),t.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof T&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"complete",value:function(){var e=this;this.dispatch("refresh"),Ge((function(){return E(e,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._logger.debug("session refreshed"),this.handler.onSessionRefreshed();case 2:case"end":return e.stop()}}),e,this)})))}))}},{key:"error",value:function(e){var t=this;Ge((function(){return E(t,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.handler.onSessionError(e);case 1:case"end":return t.stop()}}),t,this)})))}))}},{key:"close",value:function(){var e=this;this.dispatch("close"),Ge((function(){return E(e,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._logger.debug("session closed"),this.handler.onSessionClosed();case 2:case"end":return e.stop()}}),e,this)})))}))}},{key:"refresh",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.handler){e.next=38;break}if(this._isRefreshingSessionKey){e.next=38;break}if(this._isRefreshingSessionKey=!0,this.auth.authToken){e.next=25;break}return e.prev=4,e.next=7,this._receiveNewAuthToken();case 7:if(!(t=e.sent)){e.next=13;break}this._logger.debug("session refreshing.."),this.auth.authToken=t,e.next=16;break;case 13:return this.close(),this._isRefreshingSessionKey=!1,e.abrupt("return");case 16:e.next=25;break;case 18:throw e.prev=18,e.t0=e.catch(4),n=T.sessionTokenRequestFailed,this._dispatcher.dispatch(new Le),this.error(n),this._isRefreshingSessionKey=!1,n;case 25:return e.prev=25,e.next=28,this._refreshSessionKey(this.auth.authToken);case 28:this._isRefreshingSessionKey=!1,e.next=38;break;case 31:throw e.prev=31,e.t1=e.catch(25),r=T.sessionTokenRefreshFailed,this._dispatcher.dispatch(new Le),this.error(r),this._isRefreshingSessionKey=!1,r;case 38:case"end":return e.stop()}}),e,this,[[4,18],[25,31]])})))}}]),r}(z),Ve=function(){function e(){n(this,e),this.type=ue.NONE,this.name="none"}return a(e,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),je=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.LOGOUT,e.name="logout",e}return a(r,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new We,n);case 6:Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t)})))}}]),r}(Ve),Qe=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.autoReconnect;return n(this,r),(a=t.call(this)).type=ue.DISCONNECTED,a.name="disconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return a(r,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Be,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new ze({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Be,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new je,n);case 3:case"end":return t.stop()}}),t)})))}}]),r}(Ve),Be=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return a(r,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=new de,this._callbacks.push((function(e){return e?r.reject(e):r.resolve()})),Ge((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),t)})))})),t.prev=4,a=e.sdkState.websocket,i=a.reconnectMaxRetry,s=a.reconnectRetryStrategy,t.next=8,Fe((function(t,n){return E(o,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=t,this._resetConnect=n,r.prev=2,r.next=5,e.connect();case 5:r.next=16;break;case 7:if(r.prev=7,r.t0=r.catch(2),!(r.t0 instanceof T)){r.next=15;break}r.t1=r.t0.code,r.next=r.t1===b.CONNECTION_CANCELED?13:15;break;case 13:return t(r.t0),r.abrupt("return");case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[2,7]])})))}),i,s);case 8:return t.next=10,e.changeState(new Ke,n);case 10:Ge((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),t,this)})))})),t.next=24;break;case 13:if(t.prev=13,t.t0=t.catch(4),x(t.t0)){t.next=23;break}if(!(t.t0 instanceof T)){t.next=20;break}if(t.t0.code===b.CONNECTION_CANCELED){t.next=20;break}return t.next=20,e.changeState(new Qe({autoReconnect:!1}),n);case 20:Ge((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._flushCallbacks(t.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return n.stop()}}),n,this)})))})),t.next=24;break;case 23:throw t.t0;case 24:return t.abrupt("return",r.promise);case 25:case"end":return t.stop()}}),t,this,[[4,13]])})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new de,this._halt(T.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var n=Date.now();e.changeState(new ze({authToken:t}),n).then((function(){r.resolve()})).catch((function(e){r.reject(e)}))})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"onReconnect",value:function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new de,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new Qe({autoReconnect:r}),n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new je,n);case 4:case"end":return t.stop()}}),t,this)})))}}]),r}(Ve),Ke=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.CONNECTED,e.name="connected",e}return a(r,[{key:"onReconnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Be,n);case 5:case"end":return t.stop()}}),t)})))}},{key:"onDisconnect",value:function(e,t){var n=t.autoReconnect;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Qe({autoReconnect:n}),r);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new je,n);case 3:case"end":return t.stop()}}),t)})))}}]),r}(Ve),ze=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.authToken;return n(this,r),(a=t.call(this)).type=ue.CONNECTING,a.name="connecting",a._authToken="",a._haltConnect=null,a._callbacks=[],a._authToken=i,a}return a(r,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=new de,this._callbacks.push((function(e){return e?r.reject(e):r.resolve()})),t.prev=3,t.next=6,Fe((function(t){return E(a,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._haltConnect=t,n.prev=1,n.next=4,e.connect(this._authToken);case 4:n.next=15;break;case 6:if(n.prev=6,n.t0=n.catch(1),!(n.t0 instanceof T)){n.next=14;break}n.t1=n.t0.code,n.next=n.t1===b.CONNECTION_CANCELED?12:14;break;case 12:return t(n.t0),n.abrupt("return");case 14:throw n.t0;case 15:case"end":return n.stop()}}),n,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return t.next=8,e.changeState(new Ke,n);case 8:Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),t,this)})))})),t.next=24;break;case 11:if(t.prev=11,t.t0=t.catch(3),x(t.t0)){t.next=23;break}return t.next=16,e.disconnect();case 16:if(!(t.t0 instanceof T)){t.next=20;break}if(t.t0.code===b.CONNECTION_CANCELED){t.next=20;break}return t.next=20,e.changeState(new We,n);case 20:Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(t.t0);case 1:case"end":return e.stop()}}),e,this)})))})),t.next=24;break;case 23:throw t.t0;case 24:return t.abrupt("return",r.promise);case 25:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new de,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(null!=r?r:T.connectionCanceled),t.next=4,e.changeState(new je,n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new je,n);case 4:case"end":return t.stop()}}),t,this)})))}}]),r}(Ve),We=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.INITIALIZED,e.name="initialized",e}return a(r,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new ze({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}}]),r}(Ve),Ye=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return a(r)}(le),Je=function(){function e(t){var r=t.pingDelegate,a=t.sdkState,i=t.logger;n(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=r,this.sdkState=a,this._logger=i}return a(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new Ye;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Xe=new Map,Ze=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==n&&Xe.set(e,n),null!==(t=Xe.get(e))&&void 0!==t?t:""},$e=1048576,et=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e),this.emojiHash=t.emoji_hash||"",this.uploadSizeLimit=t.file_upload_size_limit?t.file_upload_size_limit*$e:Number.MAX_SAFE_INTEGER,this.useReaction=!!t.use_reaction,this.applicationAttributes=t.application_attributes||[],this.premiumFeatureList=t.premium_feature_list||[],this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history")}return a(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/$e,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction}}}]),e}(),tt=function(){function e(t){n(this,e),this._iid="",this._iid=t}return a(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),nt=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadata;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(_e,"/").concat(i,"/metadata"),a.params={metadata:s},a}return a(r)}(Z),rt=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaData=a,i}return a(r)}($),at=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return a(r)}(Z),it=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metadata=a,i}return a(r)}($),st=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadataKey;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(i,"/metadata/").concat(s),a}return a(r)}(Z),ot=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(i,"/metadata"),a}return a(r)}(Z),ut=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},ct=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},lt=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(fe=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",fe.OFFLINE="offline",fe.NON_AVAILABLE="nonavailable";var ht,dt=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,_,y;return n(this,o),(i=r.call(this,t)).userId=null!==(u=null!==(s=a.guest_id)&&void 0!==s?s:a.user_id)&&void 0!==u?u:"",i.nickname=null!==(l=null!==(c=a.nickname)&&void 0!==c?c:a.name)&&void 0!==l?l:"",i.plainProfileUrl=null!==(d=null!==(h=a.profile_url)&&void 0!==h?h:a.image)&&void 0!==d?d:"",i.requireAuth=null!==(p=a.require_auth_for_profile_image)&&void 0!==p&&p,i.metaData=null!==(f=a.metadata)&&void 0!==f?f:{},i.connectionStatus=e.UserOnlineState.NON_AVAILABLE,A(e.UserOnlineState,a.is_online)?i.connectionStatus=a.is_online:M("boolean",a.is_online)&&(i.connectionStatus=a.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),i.isActive=null===(v=a.is_active)||void 0===v||v,i.lastSeenAt=null!==(m=a.last_seen_at)&&void 0!==m?m:null,i.preferredLanguages=a.preferred_languages?g(a.preferred_languages):null,i.friendDiscoveryKey=null!==(_=a.friend_discovery_key)&&void 0!==_?_:null,i.friendName=null!==(y=a.friend_name)&&void 0!==y?y:null,i}return a(o,[{key:"profileUrl",get:function(){return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(Ze(this._iid)):this.plainProfileUrl}},{key:"serialize",value:function(){return ut(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return M("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(this._isValidMetaData(e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new nt({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(rt),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(this._isValidMetaData(e)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new at({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(it),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new st({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((u=!0,(o=e)in(s={})?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ot({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),o}(tt),pt=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userProfile;return n(this,r),(a=t.call(this)).userProfile=i,a}return a(r)}(Y),ft=function(){function e(t,r){var a,i,s,o,u,c,l,h,d,p,f,v,m,g;n(this,e),this._iid=t,this.appInfo=new et(r),this.user=new dt(t,r),this.connectedAt=null!==(a=r.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=r.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=r.pong_timeout)&&void 0!==s?s:5e3,this.reconnectInterval=null!==(u=null===(o=r.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=r.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=r.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(f=null===(p=r.reconnect)||void 0===p?void 0:p.mul)&&void 0!==f?f:2,this.maxUnreadCountOnSuperGroup=null!==(v=r.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!r.profile_image_encryption,this.concurrentCallLimit=null!==(m=r.concurrent_call_limit)&&void 0!==m?m:5,this.backOffDelay=null!==(g=r.back_off_delay)&&void 0!==g?g:100}return a(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=It.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new pt({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},dt.payloadify(e.user)),et.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),vt=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o;return n(this,r),(s=t.call(this,e,a,i)).error=null,s.userProfile=new ft(e,i),s.key=i.key,s.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",s.error=i.error?new T(i):null,s}return a(r,[{key:"applyTo",value:function(e){if(this.error)throw this.error;var t=It.of(e);if(!t)throw T.lostInstance;t.sessionManager.auth.sessionKey=this.key,Ze(e,this.ekey),this.userProfile.apply()}}],[{key:"asError",value:function(e){return new r(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),r}(se),mt=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).enabled=e,a}return a(r)}(Y),gt=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext,u=a.connectionHandlers,c=a.sessionManager,l=a.websocketClient,h=a.dispatcher,d=a.logger,p=a.entryState,f=void 0===p?new We:p;return n(this,r),(i=t.call(this))._currentState=null,i._loginTimer=null,i._unresolvedLogi=null,i._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=s,i.cacheContext=o,i.connectionHandlers=u,i._sessionManager=c,i._websocketClient=l,i._dispatcher=h,i._logger=d,i._currentState=f,i.sdkState.websocket.pingerDisabled||(i._pinger=new Je({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:d})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i._loginTimer&&(clearTimeout(i._loginTimer),i._loginTimer=null),i._dispatcher.dispatch(e.as(vt))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return i._rejectConnectionRequest(T.networkError)})),i._dispatcher.on((function(e){e instanceof vt&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return a(r,[{key:"currentState",get:function(){return this._currentState}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new ve({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e,t=this._unresolvedLogi;if(this._websocketClient.isOpen&&t)if(this._unresolvedLogi=null,t.error)this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new te),this._rejectConnectionRequest(t.error);else{t.applyTo(this._iid);var n=t.userProfile;this._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}}},{key:"_rejectConnectionRequest",value:function(e){var t;null===(t=this._pinger)||void 0===t||t.stop(),this._connectionRequestQueue.length>0&&(this._connectionRequestQueue.forEach((function(t){return t.reject(e)})),this._connectionRequestQueue=[],this._statLogConnection(e))}},{key:"_url",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=this.cacheContext.localCacheEnabled,o=this._sessionManager.auth,u=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"],c=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",l=i.sb_uikit?"u".concat(i.sb_uikit):"",h="JS/c".concat(C.SDK_VERSION,"/").concat(c,"/").concat(l);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(a),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(h,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(u))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(s?1:0,"&include_poll_details=1")}},{key:"_enableStatLog",value:function(e){this._dispatcher.dispatch(new mt(e))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new ne(new ae({type:X.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._url(e),r=new de,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){a._loginTimer=null,a._dispatcher.dispatch(vt.asError(T.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._sessionManager.auth.authToken=e,this._websocketClient.connect(n)),t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(vt.asError(T.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}}]),r}(z),_t=function(){function e(t,r){var a=r.sdkState,i=r.cacheContext,s=r.connectionHandlers,o=r.sessionManager,u=r.websocketClient,c=r.dispatcher,l=r.logger,h=r.disableWebSocketCloseEventHandling,d=void 0!==h&&h;n(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new gt(t,{sdkState:a,cacheContext:i,connectionHandlers:s,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return a(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"===e._sdkState.appState&&(e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect()))})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===ue.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===ue.CONNECTING||e.type===ue.RECONNECTING}},{key:"connect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,t.next=3,n.onConnect(this._context,e);case 3:this._registerEventDispatcher();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"reconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onReconnect(this._context,{});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onReconnect(this._context,{resetReconnectCount:!0});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onDisconnect(this._context,{autoReconnect:!1});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,t.next=3,n.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,this._clearEventDispatcher(),e.next=4,t.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),yt=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.deviceId,s=e.statLogs;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(Ne),a.params={device_id:i,log_entries:s.map((function(e){return ae.payloadify(e)}))},a}return a(r)}(Z);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(ht||(ht={}));var kt,Et=function(){function e(t){var r=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.baseLimit,o=void 0===s?100:s,u=t.maxLimit,c=void 0===u?1e3:u,l=t.minLimit,h=void 0===l?10:l;n(this,e),this.queue=[],this.enabledstate=ht.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=B(),this.cacheContext=r,this.requestQueue=a,this.dispatcher=i,this.baseLimit=o,this.limit=o,this.maxLimit=c,this.minLimit=h}return a(e,[{key:"isEnabled",get:function(){return this.enabledstate===ht.ENABLED}},{key:"_save",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.cacheContext.localCacheEnabled){e.next=3;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return ae.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=22;break}if(this.isFlushing){e.next=22;break}if(this.isFlushing=!0,e.prev=3,!((t=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0)){e.next=12;break}return n=new yt({deviceId:this.deviceId,statLogs:t}),e.next=9,this.requestQueue.send(n);case 9:return this.queue=this.queue.slice(t.length),e.next=12,this._save();case 12:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(3),this.limit=this.limit+20;case 19:return e.prev=19,this.isFlushing=!1,e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[3,16,19,22]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.key=e,!this.cacheContext.localCacheEnabled){t.next=16;break}return t.next=4,this.cacheContext.preference.get(this.key);case 4:if(!(n=t.sent)){t.next=16;break}if(this.deviceId=n.deviceId,this.queue=n.statLogs.map((function(e){return new ae({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=n.generation,this.lastFlushedAt=n.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=16;break}return r=Math.min(Math.floor(18e4*Math.random()),100),t.next=14,De(r);case 14:return t.next=16,this._flush();case 16:this.dispatcher.on((function(e){if(e instanceof ne){var t=e.statLog;a.put(t)}else e instanceof mt&&(a.enabledstate=e.enabled?ht.ENABLED:ht.DISABLED,a.isEnabled?a.queue.length>=a.limit&&a._flush():a.clear())}));case 17:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledstate===ht.DISABLED){t.next=7;break}return this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}]),e}();e.LogLevel=void 0,(kt=e.LogLevel||(e.LogLevel={}))[kt.NONE=0]="NONE",kt[kt.VERBOSE=1]="VERBOSE",kt[kt.DEBUG=2]="DEBUG",kt[kt.INFO=3]="INFO",kt[kt.WARN=4]="WARN",kt[kt.ERROR=5]="ERROR";var bt,wt,Ct,Rt,xt=function(){function t(){n(this,t),this.level=e.LogLevel.WARN}return a(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&M("number",s)&&(this.key=a,this.userIds=i,this.updatedAt=s);var o,u={},c=k(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return a(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?J({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),zt=function(){function e(t){n(this,e),this.key=t.key,this.value=O("string",t.value)?g(t.value):[]}return a(e,null,[{key:"payloadify",value:function(e){var t;return e?J({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),Wt=function(){function e(t){n(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return a(e,null,[{key:"payloadify",value:function(e){var t,n;return e?J({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null}}]),e}(),Yt=function(){function e(t){n(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new Wt(t["og:image"]))}return a(e,null,[{key:"payloadify",value:function(e){return e?J({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Wt.payloadify(e.defaultImage):null}):null}}]),e}(),Jt=function(){function e(t){var r,a;n(this,e),this.name=null,this.volume=0,this.name=null!==(r=t.name)&&void 0!==r?r:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return a(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?J({name:e.name,volume:e.volume}):null}}]),e}();e.ChannelType=void 0,(Ht=e.ChannelType||(e.ChannelType={})).BASE="base",Ht.GROUP="group",Ht.OPEN="open",e.Role=void 0,(Vt=e.Role||(e.Role={})).OPERATOR="operator",Vt.NONE="none",e.ScheduledStatus=void 0,(jt=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",jt.SENT="sent",jt.FAILED="failed",jt.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Qt||(Qt={}));var Xt,Zt=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},$t=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k;n(this,o),(i=r.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._scheduledStatus=null,i.messageId=null!==(u=null!==(s=a.msg_id)&&void 0!==s?s:a.message_id)&&void 0!==u?u:0,i.channelUrl=a.channel_url,i.channelType=A(e.ChannelType,a.channel_type)?a.channel_type:e.ChannelType.GROUP,a.channel&&(a.channel.channel_url&&(i.channelUrl=a.channel.channel_url),a.channel.channel_type&&(i.channelType=a.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof a.parent_message_id?parseInt(a.parent_message_id):a.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=a.data)&&void 0!==l?l:"",i.customType=null!==(h=a.custom_type)&&void 0!==h?h:"",i.mentionType=A(e.MentionType,a.mention_type)?a.mention_type:null;var E=a.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new dt(i._iid,e)})):null;var b=a.mentioned_user_ids;i.mentionedUserIds=null!=b?b:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=a.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=a.thread_info?new qt(i._iid,a.thread_info):null,i.reactions=a.reactions?a.reactions.map((function(e){return new Kt(e)})):[];for(var w=null!==(p=a.metaarray)&&void 0!==p?p:{},C=null!==(f=a.metaarray_key_order)&&void 0!==f?f:Object.keys(w).sort((function(e,t){return e.localeCompare(t)})),R=0;R=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,a;return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Zt(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return dt.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?qt.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return Kt.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return zt.payloadify(e)})),og_tag:Yt.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:Jt.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(a=e.scheduledInfo)||void 0===a?void 0:a.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}}]),o}(tt),en=function(t){i(o,t);var r=p(o);function o(t,a){var i;return n(this,o),(i=r.call(this,t,a)).role=null,i.isBlockedByMe=!1,i.role=A(e.Role,a.role)?a.role:e.Role.NONE,a.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=a.is_blocked_by_me),i}return a(o,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),o}(dt),tn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;if(n(this,o),(i=r.call(this,t,a)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=a.user?new en(i._iid,a.user):a.sender_id,i.reqId=null!==(u=null!==(s=a.req_id)&&void 0!==s?s:a.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=a.is_reply_to_channel)&&void 0!==c&&c,a.request_state&&A(e.SendingStatus,a.request_state)&&(i.sendingStatus=a.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=a.scheduled_status,a.scheduled_status){case Qt.SENT:case Qt.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Qt.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case Qt.FAILED:case Qt.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case Qt.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=a.error_code)&&void 0!==l?l:0,i}return a(o,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&I.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{user:en.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),o}($t),nn=function(){function e(t){var r,a;n(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return a(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?J({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),rn={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},an=function(t){return M("number",t.prevResultSize)&&M("number",t.nextResultSize)&&M("boolean",t.isInclusive)&&M("boolean",t.reverse)&&M("string",t.messageTypeFilter)&&A(e.MessageTypeFilter,t.messageTypeFilter)&&O("string",t.customTypesFilter,!0)&&O("string",t.senderUserIdsFilter,!0)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeReactions)&&M("boolean",t.includeParentMessageInfo)},sn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;if(n(this,o),(i=r.call(this,t,a)).message=null,i.translations={},i.message=null!==(s=a.message)&&void 0!==s?s:"",i.messageType=e.MessageType.ADMIN,i.translations=null!==(u=a.translations)&&void 0!==u?u:{},a.parent_message_info){var h=a.parent_message_info,d=Object.assign(Object.assign({},h),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth});i.parentMessage=vn(t,d)}return i}return a(o,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},rn),t),lt(this.messageId>0&&M("number",e)&&an(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:fn(e.parentMessage)})):null}}]),o}($t),on=function(){function e(t){var r,a;n(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(r=t.type)&&void 0!==r?r:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&M("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return a(e,null,[{key:"payloadify",value:function(e){return e?J({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Xt||(Xt={}));var un,cn=function(e){switch(e){case Xt.OPEN:return Xt.OPEN;case Xt.CLOSED:return Xt.CLOSED}},ln=function(e){return!e||e.text&&M("string",e.text)},hn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l,h,d;return n(this,r),(i=t.call(this,e)).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,i.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,i}return a(r,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(r),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),r}(tt),dn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l,h,d,p,f,v,m,g,_;return n(this,r),(i=t.call(this,e)).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Xt.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(h=cn(a.status))&&void 0!==h?h:Xt.CLOSED,i.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,i.data=null!==(p=a.data)&&void 0!==p?p:null,i.voterCount=null!==(f=a.voter_count)&&void 0!==f?f:-1,i.options=a.options?a.options.map((function(e){return new hn(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(m=a.allow_user_suggestion)&&void 0!==m&&m,i.allowMultipleVotes=null!==(g=a.allow_multiple_votes)&&void 0!==g&&g,i.votedPollOptionIds=null!==(_=a.voted_option_ids)&&void 0!==_?_:[],i}return a(r,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=cn(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,this.options=e.options?e.options.map((function(e){return new hn(c._iid,e)})):this.options,this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(r),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return hn.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),r}(tt),pn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h;if(n(this,o),(i=r.call(this,t,a)).message="",i.messageParams=null,i.translations={},i.translationTargetLanguages=[],i.messageSurvivalSeconds=-1,i.plugins=[],i._poll=null,i.message=a.message,i.messageType=e.MessageType.USER,i.translations=null!==(s=a.translations)&&void 0!==s?s:{},i.translationTargetLanguages=null!==(u=a.target_langs)&&void 0!==u?u:[],0===Object.keys(i.translations).length&&i.translationTargetLanguages.length>0){var d,p=k(i.translationTargetLanguages);try{for(p.s();!(d=p.n()).done;){var f=d.value;i.translations[f]=""}}catch(e){p.e(e)}finally{p.f()}}if(i.messageSurvivalSeconds=null!==(c=a.message_survival_seconds)&&void 0!==c?c:-1,i.plugins=a.plugins?a.plugins.map((function(e){return new on(e)})):[],i._poll=a.poll?new dn(i._iid,a.poll):null,a.parent_message_info){var v=a.parent_message_info,m=Object.assign(Object.assign({},v),{created_at:v.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth});i.parentMessage=vn(t,J(m))}return i}return a(o,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},rn),t),lt(this.messageId>0&&M("number",e)&&an(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return on.payloadify(e)})),poll:dn.payloadify(e._poll),parent_message_info:fn(e.parentMessage)})):null}}]),o}(tn),fn=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return pn.payloadify(t);case e.MessageType.FILE:return mn.payloadify(t);case e.MessageType.ADMIN:return sn.payloadify(t)}return null},vn=function(e,t){switch(t.type){case"MESG":return new pn(e,t);case"FILE":return new mn(e,t);case"ADMM":case"BRDM":return new sn(e,t)}return null},mn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k,E;n(this,o),(i=r.call(this,t,a)).messageParams=null,i.plainUrl="",i.requireAuth=!1,i.name=null,i.size=0,i.type=null,i.thumbnails=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE;var b=null!==(s=a.file)&&void 0!==s?s:null;if(i.plainUrl=(null!==(c=null!==(u=null==b?void 0:b.url)&&void 0!==u?u:a.url)&&void 0!==c?c:"").split("?auth=")[0],i.name=null!==(h=null!==(l=null==b?void 0:b.name)&&void 0!==l?l:a.name)&&void 0!==h?h:"File",i.size=null!==(p=null!==(d=null==b?void 0:b.size)&&void 0!==d?d:a.size)&&void 0!==p?p:0,i.data=null!==(v=null!==(f=null==b?void 0:b.data)&&void 0!==f?f:a.custom)&&void 0!==v?v:"",i.type=b?null!==(m=b.type)&&void 0!==m?m:"":null!==(g=a.type)&&void 0!==g?g:"",i.requireAuth=null!==(_=a.require_auth)&&void 0!==_&&_,i.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new nn(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(i.requireAuth?"?auth=".concat(Ze(i._iid)):"")}))})):[],i.messageSurvivalSeconds=null!==(y=a.message_survival_seconds)&&void 0!==y?y:-1,a.parent_message_info){var w=a.parent_message_info,C=Object.assign(Object.assign({},w),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:w.file,url:null===(k=w.file)||void 0===k?void 0:k.url,require_auth:null===(E=w.file)||void 0===E?void 0:E.require_auth});i.parentMessage=vn(t,C)}return i}return a(o,[{key:"url",get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Ze(this._iid)):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},rn),t),lt(this.messageId>0&&M("number",e)&&an(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:e.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:fn(e.parentMessage)})):null}}]),o}(tn),gn=function(t){switch(t){case e.ChannelType.GROUP:return ke;case e.ChannelType.OPEN:return be;default:return null}},_n=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Re,"/group_channels");case e.ChannelType.OPEN:return"".concat(Re,"/open_channels");default:return null}},yn=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,i=k(n);try{for(i.s();!(a=i.n()).done;){if(a.value===r)return!0}}catch(e){i.e(e)}finally{i.f()}}}return!1},kn=function(e,t,n){var r=yn(e.mentionType,e.mentionedUserIds,n),a=yn(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},En=function(t){i(s,t);var r=p(s);function s(t){var a,i,o;n(this,s);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"FILE",ackRequired:!0,payload:J({channel_url:t.channelUrl,url:t.url,name:null!==(a=t.fileName)&&void 0!==a?a:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return a(s)}(le),bn=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId})))),a.method=R.POST,a.path="".concat(gn(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),a.params=J({message_type:e.MessageType.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:o,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return nn.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return zt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Jt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),a}return a(s)}(Z),wn=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"FILE",i)).message=new mn(e,i);var l=It.of(e).sdkState;return s.isMentioned=yn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),Cn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o;n(this,r),(i=t.call(this,e,a)).message=new mn(e,a);var u=It.of(e).sdkState;return i.isMentioned=yn(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),u.userId),i.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,i}return a(r)}($);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(un||(un={}));var Rn,xn=function(){function e(t,r){var a=this,i=r.sdkState,s=r.dispatcher,o=r.requestQueue,u=r.onlineDetector,c=r.cacheContext;n(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof ve&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return a(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===ue.CONNECTED||this._connectionState===ue.CONNECTING||this._connectionState===ue.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._shouldSendThroughWebSocket){n.next=9;break}return r=new En(Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(wn),s=i.message,n.abrupt("return",s);case 9:return o=new bn(Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),n.next=12,this._requestQueue.send(o);case 12:return u=n.sent,c=u.as(Cn),l=c.message,n.abrupt("return",l);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"_resolveMessageQueue",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this._queueMap.get(e.url))){t.next=57;break}if(n.isResolving){t.next=56;break}n.isResolving=!0,r=[],a=!0,i=k(n.messageQueue),t.prev=7,i.s();case 9:if((s=i.n()).done){t.next=39;break}o=s.value,t.t0=o.state,t.next=t.t0===un.PENDING||t.t0===un.UPLOADING?14:t.t0===un.UPLOADED?17:t.t0===un.FAILED?35:37;break;case 14:return a=!1,r.push(o),t.abrupt("break",37);case 17:if(!a){t.next=33;break}return t.prev=18,o.state=un.SENDING,t.next=22,this._sendFileMessage(e,o);case 22:return u=t.sent,o.deferred.resolve(u),t.next=26,De(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),o.deferred.reject(t.t1);case 31:t.next=34;break;case 33:r.push(o);case 34:return t.abrupt("break",37);case 35:return o.deferred.reject(o.error.code===b.REQUEST_CANCELED?T.fileUploadCanceled:o.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(c=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,!c){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:n.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),t,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p,f,v;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._queueMap.get(e.url),!(r=n.messageQueue.find((function(e){return e.state===un.PENDING})))){t.next=49;break}if(!D(r.params.file)){t.next=45;break}if(!(n.uploadQueue.length<6)){t.next=43;break}return r.state=un.UPLOADING,n.uploadQueue.push(r),t.next=9,this._onlineDetector.isOnline();case 9:if(!t.sent){t.next=37;break}return t.prev=11,a=new Pt({file:r.params.file,channelUrl:e.url,thumbnailSizes:r.params.thumbnailSizes,requestId:r.requestId}),t.next=15,this._requestQueue.send(a);case 15:i=t.sent,s=i.as(Ft),o=s.url,u=s.fileSize,c=void 0===u?r.params.fileSize:u,l=s.thumbnailSizes,h=void 0===l?r.params.thumbnailSizes:l,d=s.requireAuth,p=void 0!==d&&d,r.params.fileUrl=o,r.params.fileSize=c,r.params.thumbnailSizes=h,r.params.requireAuth=p,r.requireAuth=p,r.state=un.UPLOADED,t.next=29;break;case 25:t.prev=25,t.t0=t.catch(11),t.t0.code===b.REQUEST_FAILED?r.error=new T({code:b.NETWORK_ERROR,message:"Failed to upload a file."}):r.error=t.t0,r.state=un.FAILED;case 29:return t.prev=29,(f=n.uploadQueue.findIndex((function(e){return e.requestId===r.requestId})))>=0&&(n.uploadQueue.splice(f,1),this._uploadNextPendingItem(e)),t.next=34,this._resolveMessageQueue(e);case 34:return t.finish(29);case 35:t.next=43;break;case 37:return r.state=un.FAILED,r.error=T.connectionRequired,(v=n.uploadQueue.findIndex((function(e){return e.requestId===r.requestId})))>=0&&(n.uploadQueue.splice(v,1),this._uploadNextPendingItem(e)),t.next=43,this._resolveMessageQueue(e);case 43:t.next=49;break;case 45:return r.params.thumbnailSizes=[],r.state=un.UPLOADED,t.next=49,this._resolveMessageQueue(e);case 49:case"end":return t.stop()}}),t,this,[[11,25,29,35]])})))}},{key:"request",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new de,D(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:un.PENDING,deferred:o,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),s.abrupt("return",o.promise);case 7:case"end":return s.stop()}}),s,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:g(n.messageQueue),i=k(a);try{for(i.s();!(r=i.n()).done;){var s=r.value;if(s)switch(s.state){case un.PENDING:s.state=un.FAILED,s.error=T.requestCanceled,this._resolveMessageQueue(e);break;case un.UPLOADING:this._requestQueue.cancel(s.requestId)}}}catch(e){i.e(e)}finally{i.f()}}}}]),e}(),Tn={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},In=function(t){return M("number",t.prevResultSize)&&M("number",t.nextResultSize)&&M("boolean",t.isInclusive)&&M("boolean",t.reverse)&&M("string",t.messageTypeFilter)&&A(e.MessageTypeFilter,t.messageTypeFilter)&&O("string",t.customTypesFilter,!0)&&O("string",t.senderUserIdsFilter,!0)&&A(e.ReplyType,t.replyType)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeReactions)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)&&M("boolean",t.showSubchannelMessagesOnly)},Sn={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Nn=function(t){return A(e.ReplyType,t.replyType)&&M("boolean",t.includeReactions)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(Rn=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",Rn.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Rn.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Rn.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Rn.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Rn.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Rn.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Rn.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Rn.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Rn.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Rn.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Rn.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Rn.REQUEST_MESSAGE="REQUEST_MESSAGE",Rn.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Rn.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Rn.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Rn.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Rn.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Rn.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Rn.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Rn.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Rn.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Rn.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Rn.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Rn.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Rn.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var Mn,An=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},Un=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.messages,s=e.source;return n(this,r),(a=t.call(this)).messages=i,a.source=s,a}return a(r)}(Y),On=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.messageIds,s=e.source;return n(this,r),(a=t.call(this)).messageIds=i,a.source=s,a}return a(r)}(Y),Ln=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.reqId,s=e.source;return n(this,r),(a=t.call(this)).reqId=i,a.source=s,a}return a(r)}(Y),Dn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.polls,s=e.source;return n(this,r),(a=t.call(this)).polls=i,a.source=s,a}return a(r)}(Y),Pn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.event,s=e.source;return n(this,r),(a=t.call(this)).event=i,a.source=s,a}return a(r)}(Y),Fn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.event,s=e.source;return n(this,r),(a=t.call(this)).event=null,a.source=null,a.event=i,a.source=s,a}return a(r)}(Y),Gn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return a(r)}(Z),qn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=a?vn(e,Object.assign({},a)):null,i}return a(r)}($),Hn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,p=e.isInclusive,f=e.reverse,v=e.messageTypeFilter,m=e.customTypesFilter,g=e.senderUserIdsFilter,_=e.replyType,y=e.includeMetaArray,k=e.includeReactions,E=e.parentMessageId,b=e.includeThreadInfo,w=e.includeParentMessageInfo,C=e.showSubchannelMessagesOnly;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=J({is_sdk:!0,prev_limit:h,next_limit:d,include:p,reverse:f,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:m,sender_ids:g,include_reply_type:_,with_sorted_meta_array:y,include_reactions:k,parent_message_id:E,include_thread_info:b,include_parent_message_info:w,show_subchannel_message_only:C,include_poll_details:!0}),a}return a(r)}(Z),Vn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).messages=a.messages.map((function(t){return vn(e,t)})),i}return a(r)}($),jn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,p=e.includeParentMessageInfo;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:p,include_poll_details:!0},a}return a(r)}(Z),Qn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return vn(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return a(r)}($),Bn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return a(r)}(Z),Kn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=a?vn(e,Object.assign({},a)):null,i}return a(r)}($),zn={},Wn=function(){function t(e,r){var a=r.sdkState,i=r.dispatcher,s=r.requestQueue,o=r.onlineDetector,u=r.cacheContext;n(this,t),this._iid=e,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,this.fileMessageQueue=new xn(e,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),zn[e]=this}return a(t,[{key:"buildMessageFromSerializedData",value:function(t){var n=ct(t);switch(n.messageType){case e.MessageType.USER:return new pn(this._iid,pn.payloadify(n));case e.MessageType.FILE:return new mn(this._iid,mn.payloadify(n));case e.MessageType.ADMIN:return new sn(this._iid,sn.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return J({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){return J({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=ct(e);return new en(this._iid,en.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Gn(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(qn),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Bn(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Kn),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Hn(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},Tn),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Vn),c=u.messages,this._dispatcher.dispatch(new Un({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Hn(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},Tn),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Vn),c=u.messages,this._dispatcher.dispatch(new Un({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,o,u,c,l;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new Hn(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},rn),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Vn),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new Un({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new jn(J(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},Sn),a))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Qn),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,d=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new Un({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new On({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:d});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return zn[e]}}]),t}(),Yn=function(){function t(){n(this,t),this._onPending=oe,this._onFailed=oe,this._onSucceeded=oe}return a(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),Jn=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e)).threadInfo=null,i.targetMessageId=0,i.channelUrl=null,i.channelType=null;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&M("object",s)&&M("number",o)&&M("string",u)&&M("string",c)&&(i.threadInfo=new qt(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return a(r)}(tt),Xn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Zn=function(t){return M("string",t.channelUrl)&&M("string",t.channelType)&&A(e.ChannelType,t.channelType)&&M("number",t.messageId)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)},$n=function(){function e(t,r){var a;n(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=r.limit)&&void 0!==a?a:20}return a(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return M("number",this.limit)&&this.limit>0}}]),e}(),er=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,p=e.messageTimestampTo,f=e.advancedQuery,v=e.targetFields,m=e.nextToken;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Ce,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:p,sort_field:h,advanced_query:f,target_fields:v,after:m},a}return a(r)}(Z),tr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).messages=a.results.map((function(t){return vn(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return a(r)}($);e.MessageSearchOrder=void 0,(Mn=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Mn.TIMESTAMP="ts";var nr,rr,ar,ir=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v;return n(this,o),(i=r.call(this,t,a)).keyword="",i.reverse=!1,i.exactMatch=!1,i.channelUrl="",i.channelCustomType="",i.messageTimestampFrom=null,i.messageTimestampTo=null,i.order=e.MessageSearchOrder.SCORE,i.advancedQuery=!1,i.targetFields=null,i._nextToken="",i.totalCount=-1,i.keyword=a.keyword,i.reverse=null!==(s=a.reverse)&&void 0!==s&&s,i.exactMatch=null!==(u=a.exactMatch)&&void 0!==u&&u,i.channelUrl=null!==(c=a.channelUrl)&&void 0!==c?c:"",i.channelCustomType=null!==(l=a.channelCustomType)&&void 0!==l?l:"",i.messageTimestampFrom=null!==(h=a.messageTimestampFrom)&&void 0!==h?h:null,i.messageTimestampTo=null!==(d=a.messageTimestampTo)&&void 0!==d?d:null,i.order=null!==(p=a.order)&&void 0!==p?p:e.MessageSearchOrder.SCORE,i.advancedQuery=null!==(f=a.advancedQuery)&&void 0!==f&&f,i.targetFields=null!==(v=a.targetFields)&&void 0!==v?v:null,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.keyword)&&this.keyword.length>0&&M("boolean",this.reverse)&&M("boolean",this.exactMatch)&&M("string",this.channelUrl)&&M("string",this.channelCustomType)&&(M("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(M("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&A(e.MessageSearchOrder,this.order)&&M("boolean",this.advancedQuery)&&O("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new er(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(tr),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw T.queryInProgress;case 19:e.next=22;break;case 21:throw T.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),o}($n),sr=function(t){i(o,t);var r=p(o);function o(e,t,a,i){var s;return n(this,o),(s=r.call(this,e,i)).channelUrl=t,s.channelType=a,s}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.channelUrl)&&A(e.ChannelType,this.channelType)}}]),o}($n),or=function(t){i(o,t);var r=p(o);function o(t,a,i,s){var u,c,l,h,d,p,f,v,m,g,_;return n(this,o),(u=r.call(this,t,a,i,s)).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=s.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=s.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(h=s.customTypesFilter)&&void 0!==h?h:null,u.senderUserIdsFilter=null!==(d=s.senderUserIdsFilter)&&void 0!==d?d:null,u.replyType=null!==(p=s.replyType)&&void 0!==p?p:e.ReplyType.NONE,u.includeMetaArray=null!==(f=s.includeMetaArray)&&void 0!==f&&f,u.includeReactions=null!==(v=s.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(m=s.includeParentMessageInfo)&&void 0!==m&&m,u.includeThreadInfo=null!==(g=s.includeThreadInfo)&&void 0!==g&&g,u.showSubchannelMessagesOnly=null!==(_=s.showSubchannelMessagesOnly)&&void 0!==_&&_,u}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.reverse)&&A(e.MessageTypeFilter,this.messageTypeFilter)&&A(e.ReplyType,this.replyType)&&O("string",this.customTypesFilter,!0)&&O("string",this.senderUserIdsFilter,!0)&&M("boolean",this.includeMetaArray)&&M("boolean",this.includeReactions)&&M("boolean",this.includeParentMessageInfo)&&M("boolean",this.includeThreadInfo)&&M("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=Wn.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(g(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw T.queryInProgress;case 16:e.next=19;break;case 18:throw T.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),o}(sr),ur={channelUrl:null,scheduledMessageId:0},cr=function(e){return M("string",e.channelUrl)&&M("number",e.scheduledMessageId)},lr=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="message",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Wn(e,{sdkState:n,dispatcher:a,requestQueue:o,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Xn),e),lt(Zn(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},ur),e),lt(cr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}}]),r}(Dt),hr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return n(this,r),(a=t.call(this)).method=R.POST,a.path=Ie,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return a(r)}(Z),dr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),pr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Ie,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return a(r)}(Z),fr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),vr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Ie,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return a(r)}(Z),mr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pollOption=new hn(e,a),i}return a(r)}($),gr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=J({change_ts:o,token:u}),a}return a(r)}(Z),_r=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new dn(e,t):null}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return a(r)}($),yr={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},kr=function(e){return M("string",e.title)&&(t=e.optionTexts,O("string",t)&&t.every((function(e){return""!==e.trim()})))&&ln(e.data)&&M("boolean",e.allowUserSuggestion,!0)&&M("boolean",e.allowMultipleVotes,!0)&&M("number",e.closeAt,!0);var t},Er={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},br=function(t){return M("string",t.channelUrl)&&A(e.ChannelType,t.channelType)&&M("number",t.pollId)&&M("number",t.pollOptionId)},wr={channelUrl:null,channelType:null,pollId:null},Cr=function(t){return M("string",t.channelUrl)&&""!==t.channelUrl&&A(e.ChannelType,t.channelType)&&M("number",t.pollId)},Rr={},xr=function(){function t(e,r){var a=r.sdkState,i=r.dispatcher,s=r.sessionManager,o=r.requestQueue,u=r.logger;n(this,t),this._iid=e,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Rr[e]=this}return a(t,[{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(Cr(e)).throw(T.invalidParameters),n=new pr(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(fr),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(kr(e)).throw(T.invalidParameters),n=e.data,r=new hr(Object.assign(Object.assign({},e),{data:n})),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(dr),s=i.poll,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(br(e)).throw(T.invalidParameters),n=new vr(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(mr),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new gr(J({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(_r),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Dn({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Rr[e]}}]),t}(),Tr=a((function e(t,r){n(this,e),this.pollId=0,this.messageId=0,this.pollId=r.poll.id,this.messageId=r.poll.message_id,this._iid=t,this._payload=r})),Ir=a((function e(t){n(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Sr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return n(this,r),(a=t.call(this)).method=R.GET,a.path=Ie,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return a(r)}(Z),Nr=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new dn(e,t)})),i.token=a.next,i}return a(r)}($),Mr=function(e){i(r,e);var t=p(r);function r(e,a){return n(this,r),t.call(this,e,a.channelUrl,a.channelType,a)}return a(r,[{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new Sr(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Nr),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(sr),Ar=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Ie,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return a(r)}(Z),Ur=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new dt(e,t)})),i.token=a.next,i}return a(r)}($),Or=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a.channelUrl,a.channelType,a)).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&M("number",this.pollId)&&M("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new Ar(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Ur),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(sr),Lr=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="poll",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new xr(e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},yr),e),lt(kr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},wr),e),lt(Cr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Er),e),lt(br(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}}]),r}(Dt),Dr={profileImage:null,profileUrl:null,nickname:null},Pr=function(e){return D(e.profileImage,!0)&&M("string",e.profileUrl,!0)&&M("string",e.nickname,!0)},Fr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onSessionExpired=oe,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=oe,this.onSessionRefreshed=oe,this.onSessionClosed=oe}))),Gr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onConnected=oe,this.onReconnectStarted=oe,this.onReconnectSucceeded=oe,this.onReconnectFailed=oe,this.onDisconnected=oe}))),qr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onFriendsDiscovered=oe,this.onTotalUnreadMessageCountUpdated=oe}))),Hr="GroupChannel",Vr=100,jr="Message";e.GroupChannelListOrder=void 0,(nr=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",nr.CHRONOLOGICAL="chronological",nr.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",nr.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(rr=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",rr.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",rr.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(ar=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",ar.SCHEDULED_AT="scheduled_at";var Qr,Br=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Kr=function(){function t(){n(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return a(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof tn))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof tn&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Qr||(Qr={}));var zr,Wr=function(e){switch(e){case Qr.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Qr.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Yr={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Jr=function(t){return M("string",t.data,!0)&&M("string",t.customType,!0)&&A(e.MentionType,t.mentionType)&&O("string",t.mentionedUserIds,!0)&&O(dt,t.mentionedUsers,!0)&&M("string",t.mentionedMessageTemplate,!0)&&O(zt,t.metaArrays,!0)&&M("number",t.parentMessageId,!0)&&M("boolean",t.isReplyToChannel)&&A(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&M(Jt,t.appleCriticalAlertOptions,!0)&&M("boolean",t.isPinnedMessage,!0)},Xr=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Zr=Object.assign(Object.assign({},Yr),{message:null,translationTargetLanguages:null,pollId:null}),$r=function(e){var t;return J({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},ea=function(e){return Jr(e)&&M("string",e.message)&&O("string",e.translationTargetLanguages,!0)&&M("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(zr||(zr={}));var ta,na=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},ra=function(e){return e===zr.BLOB||e===zr.FILE},aa=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ia=Object.assign(Object.assign({},Yr),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),sa=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&D(n)&&(e.messageParams.file=n),e.messageParams):J({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=n?n:null===(t=e.messageParams)||void 0===t?void 0:t.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},oa=function(e){return Jr(e)&&(D(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ua=Object.assign(Object.assign({},Zr),{scheduledAt:null}),ca=Object.assign(Object.assign({},Yr),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),la="UnsentMessage",ha={},da=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext;return n(this,r),(i=t.call(this,e))._sdkState=s,i._cacheContext=o,ha[e]=h(i),i}return a(r,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(la)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw T.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof pn?(e.messageParams&&(n.messageParams=Xr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Xr(t)),{scheduledAt:t.scheduledAt})))):e instanceof mn&&(e.messageParams&&(n.messageParams=aa(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},aa(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Wn.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Wn.of(this._iid),r=this._deserialize(e),!e.messageParams){t.next=15;break}if(!(r instanceof pn)){t.next=8;break}a=e.messageParams,r.messageParams=n.buildUserMessageCreateParamsFromSerializedData(a,r),t.next=15;break;case 8:if(!(r instanceof mn)){t.next=15;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!ra(i.fileType)){t.next=14;break}return t.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=t.sent;case 14:r.messageParams=n.buildFileMessageCreateParamsFromSerializedData(i,r);case 15:if(!(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){t.next=28;break}if(!(r instanceof pn)){t.next=21;break}s=e.scheduledInfo.scheduledMessageParams,r.scheduledInfo.scheduledMessageParams=n.buildScheduledUserMessageCreateParamsFromSerializedData(s,r),t.next=28;break;case 21:if(!(r instanceof mn)){t.next=28;break}if(!(o=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof o.fileKey||!ra(o.fileType)){t.next=27;break}return t.next=26,this.collection.getBlob(o.fileKey);case 26:o.file=t.sent;case 27:r.scheduledInfo.scheduledMessageParams=n.buildScheduledFileMessageCreateParamsFromSerializedData(o,r);case 28:return t.abrupt("return",r);case 29:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,a=void 0===r?new Kr:r,i=e.order,s=void 0===i?Qr.CHANNEL_LATEST:i,o=e.sendingStatus,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r,i,o,c,h=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return t=Wr(s),r={"/where":function(e){return!!(s!==Qr.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&a.match(h._deserialize(e))}},n&&(r.channelUrl=n),u&&(r.sendingStatus=u),i={where:r,index:t,backward:l},e.next=8,this.collection.query(i);case 8:return o=e.sent,e.next=11,o.fetch({});case 11:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(h,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Kr;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Qr.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.saveBlobs(e);case 3:return n=e.map((function(e){return r._serialize(e)})),t.next=6,this.collection.upsertMany(n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=k(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof mn)){t.next=17;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!na(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=zr.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!na(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=zr.BLOB;case 17:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}}],[{key:"of",value:function(e){return ha[e]}}]),r}(tt),pa=function(t,n){return function(r,a){if(1===r)t.clear().then((function(){n.clear().then((function(){(function(t){return E(void 0,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.commitSchema([{collectionName:Hr,keyName:"url",index:[Br(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Br(e.GroupChannelListOrder.CHRONOLOGICAL),Br(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:jr,keyName:"messageId",index:[Wr(Qr.CHANNEL_LATEST),Wr(Qr.NEWEST_CHILD_MESSAGE)]},{collectionName:la,keyName:"reqId",index:[Wr(Qr.CHANNEL_LATEST),Wr(Qr.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return n.stop()}}),n)})))})(t).then((function(){return a()})).catch((function(e){return a(e)}))})).catch((function(e){return a(e)}))})).catch((function(e){return a(e)}));else a()}},fa={},va=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext,u=a.unsentMessageCache;return n(this,r),(i=t.call(this,e))._sdkState=s,i._cacheContext=o,i._unsentMessageCache=u,fa[e]=h(i),i}return a(r,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(jr):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Wn.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?Vr:r,i=e.filter,s=void 0===i?new Kr:i,o=e.order,u=void 0===o?Qr.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h,p=e.isPollOnly,f=void 0!==p&&p;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,i,o,c,h=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=Wr(u),i={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case Qr.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new Kr;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Qr.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return n=e.map((function(e){return r._serialize(e)})),t.next=6,this.collection.upsertMany(n);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=k(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:Wr(Qr.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Wr(Qr.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=Wr(Qr.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof mn&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!na(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}}],[{key:"of",value:function(e){return fa[e]}}]),r}(tt),ma=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.call(this))._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(h(e)),e}return a(r,[{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState}},{key:"start",value:function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})}},{key:"stop",value:function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})}}]),r}(z),ga=function(){function e(t){var r=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;n(this,e),this._onlineWorker=function(){var e;return null===(e=r.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=r.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(r.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(r.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,s&&(this.connectionDelegate=s)}return a(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:R.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),_a=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.message;return n(this,r),(a=t.call(this)).message=i,a}return a(r)}(Y),ya={},ka=function(){function t(e,r){var a=this,i=r.localCacheEnabled,s=r.dispatcher,o=r.sdkState,u=r.logger;n(this,t),ya[e]=this,this._iid=e,ya[e]=this,this._localCacheEnabled=i,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=s,this._logger=u,this._sdkState=o,this._localCacheEnabled&&s.on((function(e){if(e instanceof ve)switch(e.stateType){case ue.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case ue.DISCONNECTED:a._isProcessingAutoResend=!1}}))}return a(t,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=k(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=b.ACK_TIMEOUT,this._dispatcher.dispatch(new Un({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=k(n);try{for(r.s();!(a=r.n()).done;)(i=a.value).errorCode&&L(i.errorCode)&&(s=(new Date).getTime(),o=i.createdAt+2592e5,s<=o?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(o).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new Un({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!L(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=da.of(this._iid))){t.next=7;break}return t.next=4,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new _a({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return ya[e]}}]),t}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ta||(ta={}));var Ea,ba=function(){function e(t){n(this,e),this.category=t.cat,this.data=t.data}return a(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new dt(e,r),blockee:new dt(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new dt(e,t)})):[]}}}]),e}(),wa=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.userId;return n(this,r),(i=t.call(this))._iid=e,i.userId=s,i}return a(r)}(Y),Ca=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"USEV",i)).event=new ba(i),s}return a(r)}(se),Ra=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.nickname,o=void 0===s?null:s,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,p=void 0===d?null:d;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i)),a.params=J({nickname:o,profile_url:c,profile_file:h,preferred_languages:p}),a}return a(r)}(Z),xa=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).user=null,i.user=new dt(e,Object.assign({},a)),i}return a(r)}($),Ta=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/apns"),a.params={apns_device_token:s,always_push:!0},a}return a(r)}(Z),Ia=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params={gcm_reg_token:s,always_push:!0},a}return a(r)}(Z),Sa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Na=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Ma=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/apns"),a}return a(r)}(Z),Aa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return a(r)}(Z),Ua=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return a(r)}(Z),Oa=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),(i=r.call(this,t,a)).pushTokens={type:a.type?e.PushTokenType[a.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:a.device_tokens,hasMore:a.has_more,token:a.token},i}return a(s)}($),La=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return a(r)}(Z),Da=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return a(r)}($),Pa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.willAutoAccept;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return a(r)}(Z),Fa=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return a(r)}($),Ga=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),qa=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return a(r)}($),Ha=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return a(r)}(Z),Va=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return a(r)}($),ja=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),Qa=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return a(r)}($),Ba=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return a(r)}(Z),Ka=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return a(r)}($),za=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.blockedUserId;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return a(r)}(Z),Wa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.unblockedUserId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Ya=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),Ja=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return a(r)}($),Xa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.pushTriggerOption;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return a(r)}(Z),Za=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return a(r)}($),$a=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/template"),a}return a(r)}(Z),ei=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).name=a.name,i}return a(r)}($),ti=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.templateName;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return a(r)}(Z),ni=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).name=a.name,i}return a(r)}($),ri=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return a(r)}(Z),ai=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new dt(e,t)})),updatedUsers:a.updated.map((function(t){return new dt(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return a(r)}($),ii=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.discoveries;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return a(r)}(Z),si=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return a(r)}($),oi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.discoveryKeys;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return a(r)}(Z),ui=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.userIds;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return a(r)}(Z),ci=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new dt(e,t)})),i}return a(r)}($),li=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.userIds;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return a(r)}(Z),hi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return a(r)}(Z),di=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,i}return a(r)}($),pi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.allowFriendDiscovery;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return a(r)}(Z),fi=a((function e(t){n(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),vi=a((function e(t){var r,a,i;n(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(r=t.id)&&void 0!==r?r:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(i=t.url)&&void 0!==i?i:"",this.emojis=t.emojis?t.emojis.map((function(e){return new fi(e)})):[]})),mi=a((function e(t){n(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new vi(e)})):[]})),gi=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.call(this)).method=R.GET,e.path=Te,e}return a(r)}(Z),_i=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emojiContainer=new mi(a),i}return a(r)}($),yi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.categoryId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Te,"/").concat(i),a}return a(r)}(Z),ki=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emojiCategory=new vi(a),i}return a(r)}($),Ei=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.key;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(xe,"/").concat(i),a}return a(r)}(Z),bi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emoji=new fi(a),i}return a(r)}($),wi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return n(this,r),(a=t.call(this)).method=R.GET,a.path=_e,a.params=J({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return a(r)}(Z),Ci=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new dt(e,t)})),i.next=a.next,i}return a(r)}($),Ri=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u;return n(this,r),(i=t.call(this,e,a)).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&O("string",this.userIdsFilter,!0)&&M("string",this.metaDataKeyFilter,!0)&&O("string",this.metaDataValuesFilter,!0)&&M("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new wi(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Ci),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}($n),xi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(i,"/block"),a.params=J({limit:s,token:o,user_ids:u}),a}return a(r)}(Z),Ti=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new dt(e,t)})),i.next=a.next,i}return a(r)}($),Ii=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&O("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new xi(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ti),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}($n),Si=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.limit,o=e.token;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return a(r)}(Z),Ni=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).hasMore=a.has_more,i.users=a.users.map((function(t){return new dt(e,t)})),i.next=a.next,i}return a(r)}($),Mi=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Si(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Ni),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}($n),Ai={},Ui=function(){function e(t){var r=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,p=void 0===d?11:d,f=t.transactionApplyDelay,v=void 0===f?200:f,m=t.disableLogger,g=void 0!==m&&m;return n(this,e),Ai[r]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=p,this.transactionApplyDelay=v,this.disableLogger=g,Ai[r]=this),Ai[r]}return a(e,null,[{key:"get",value:function(e){return Ai[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"}(Ea||(Ea={}));var Oi,Li=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.code,s=void 0===i?Ea.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return n(this,r),(a=t.call(this,u)).code=s,Object.setPrototypeOf(h(a),r.prototype),a}return a(r,null,[{key:"storeNotDefined",get:function(){return new r({code:Ea.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new r({code:Ea.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new r({code:Ea.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new r({code:Ea.STORE_IS_FULL,message:"Store is full."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new r({code:Ea.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new r({code:Ea.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new r({code:Ea.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new r({code:Ea.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new r({code:Ea.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new r({code:Ea.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new r({code:Ea.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new r({code:Ea.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new r({code:Ea.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new r({code:Ea.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new r({code:Ea.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new r({code:Ea.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new r({code:Ea.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new r({code:Ea.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new r({code:Ea.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new r({code:Ea.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new r({code:Ea.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new r({code:Ea.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new r({code:Ea.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new r({code:Ea.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),r}(l(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Oi||(Oi={}));var Di,Pi=function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===t(n)&&null!==n){if(r.has(n))throw Li.circularReferenceFound;r.set(n,!0);var a=null;if(Array.isArray(n))a=n.map((function(t){return e(t,r)}));else if(n instanceof RegExp)a=n;else if(n instanceof Date)a=n;else for(var i in a={},n)a[i]=e(n[i],r);return r.delete(n),a}return n},Fi=function(e,n){if(null==n)return 1;if(null==e)return-1;if(t(e)!==t(n))throw Li.compareTypesNotMatch;var r=0;switch(t(e)){case"boolean":case"number":r=e-n;break;case"string":r=e.localeCompare(n)}return r},Gi=function(e,t){for(var n=0,r=0;r>>0)%t},qi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Hi=function e(n,r){if(!r)return!1;if("function"!=typeof n){for(var a in n){if(["/and","&&"].includes(a)){if(n[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(n[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,n[a])(r))return!1}else{var i=a;if("object"===t(n[i])){var s=n[i];for(var o in s)switch(o){case"/eq":case"=":if(r[i]!==s[o])return!1;break;case"/neq":case"!=":if(r[i]===s[o])return!1;break;case"/gt":case">":var u=r[i],c=s[o];if(!(Fi(u,c)>0))return!1;break;case"/gte":case">=":var l=r[i],h=s[o];if(!(Fi(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[i],p=s[o];if(!(Fi(d,p)<0))return!1;break;case"/lte":case"<=":var f=r[i],v=s[o];if(!(Fi(f,v)<=0))return!1;break;case"/in":var m=r[i];if(!s[o].includes(m))return!1;break;case"/nin":var g=r[i];if(s[o].includes(g))return!1;break;case"/contain":var _=r[i],y=s[o];if(!_.includes(y))return!1;break;case"/regex":var k=r[i];if(!s[o].test(k))return!1;break;case"/where":var E=r[i];if(!(0,s[o])(E))return!1}}else if("function"==typeof n[i]){if(!n[i](r[i]))return!1}else if(n[i]!==r[i])return!1}}return!0}return n(r)},Vi=function(){},ji=function(){return Promise.resolve()},Qi=function(e){return e},Bi=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Di||(Di={}));var Ki,zi,Wi,Yi=function(){function e(t){var r=t.initialPrevValue,a=void 0===r?null:r,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?Qi:u,l=t.backward,h=void 0===l?ji:l,d=t.forward,p=void 0===d?ji:d,f=t.complete,v=void 0===f?Vi:f;n(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=h,this._forward=p,this._iterator=o,this._complete=v}return a(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),Ji=function(){function e(t){var r=t.condition,a=void 0===r?{}:r,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;n(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}return a(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,n=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"===t(this.condition[s])){var u=o>0?r:n;for(var c in this.condition[s])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Fi(this._indexer.origin[l].columnValues[i],this.condition[s][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Fi(this._indexer.origin[h].columnValues[i],this.condition[s])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=function(){var a=0;if("function"!=typeof e.condition)for(var i=function(i){var s=e._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),e.condition[s])if("object"===t(e.condition[s]))Object.keys(e.condition[s]).forEach((function(t){if((o>0?n:r).includes(t))for(var u=a;u=0){a=u;break}}));else for(var u=a;u=0){a=u;break}},s=0;s0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Li.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(rs(e,t)).concat(n,".").concat(r)},is=function(){function e(t){var r=t.dbname,a=t.collectionName,i=t.store;n(this,e),this.dbname=r,this.collectionName=a,this.store=i}return a(e,[{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=as(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s},generation:1});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=rs(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Ki||(Ki={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(zi||(zi={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Wi||(Wi={}));var ss=[zi.PENDING,zi.VOLATILE],os={},us=function(){function e(t){var r=t.dbname,a=t.limit,i=void 0===a?256:a;return n(this,e),os[r]||(this.dbname=r,this._items=[],this._limit=i,os[r]=this),os[r]}return a(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Wi.DEFAULT;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,generation:1,state:n===Wi.PERSISTENT?zi.PERSISTENT:zi.VOLATILE},this.put(a)),r.next=9;break;case 8:n===Wi.PERSISTENT&&(a.state=zi.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wi.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Wi.PERSISTENT&&(r.state=zi.PERSISTENT),t!==Wi.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)ss.includes(this._items[t].state)&&ss.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===zi.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],s=k(this._items);try{for(s.s();!(a=s.n()).done;){var o=a.value;o.state===zi.VOLATILE&&r>0?r--:i.push(o)}}catch(e){s.e(e)}finally{s.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==zi.VOLATILE}))}}],[{key:"get",value:function(e){return os[e]}}]),e}(),cs=function(){function e(t){var r=t.dbname,a=t.collectionName,i=t.store;n(this,e),this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=r,this.collectionName=a,this.metadataKey=function(e,t){return"".concat($i(e,t),"/trans.metadata")}(r,a),this.recordsetKey=function(e,t){return"".concat($i(e,t),"/trans.recordset")}(r,a),this._store=i}return a(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,g(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=us.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u1&&void 0!==arguments[1]?arguments[1]:null;this._requests.push({data:e,options:t});var n=us.get(this.dbname);n.put(Object.assign({state:zi.PENDING,generation:this.generation},e))}},{key:"requestMultipleWrite",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=us.get(this.dbname),a=k(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;this._requests.push({data:i,options:n}),r.put(Object.assign({state:zi.PENDING,generation:this.generation},i))}}catch(e){a.e(e)}finally{a.f()}}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:us.get(this.dbname).clearByCondition((function(e){return e.state===zi.PENDING})),this._requests=[];case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h,d,p,f,v=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((t=this._requests).length>0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u,generation:this.generation});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata,generation:1});case 14:for(c=us.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return ns(this.dbname,this.collectionName,t,"".concat(hs(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})))}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=us.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=ls.createFromCacheItem(i),!s.getItemByKey(e)){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Ui.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=us.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(u=o?ls.createFromCacheItem(o):new ls({blockId:a,keyName:this.keyName,items:[],limit:i})).add(t)){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ts(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:us.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),ps={},fs=function(){function e(t){var r=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.fields,u=t.transaction,c=t.store;n(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat($i(e,t),"/index.").concat(n)}(a,i,o.join(">"));return ps[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Ki.COMMIT,this.indexerKey,(function(){return r.commit()})),this._transaction.on(Ki.ERROR,this.indexerKey,(function(){return r.abort()}))),ps[l]}return a(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var n,r,a,i=[],s=k(this.fields);try{for(s.s();!(n=s.n()).done;){var o=n.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=t(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Li.indexTypesNotMatch;i.push(e[o])}}catch(e){s.e(e)}finally{s.f()}return i}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Fi(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=us.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,Wi.PERSISTENT);case 3:if(n=e.sent){e.next=34;break}return r=ts(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=k(a),e.prev=10,i.s();case 12:if((s=i.n()).done){e.next=23;break}if(!(o=s.value).startsWith(r)){e.next=21;break}return e.next=17,t.find(this._store,o,Wi.NO_CACHE);case 17:u=e.sent,c=ls.createFromCacheItem(u),l=k(c.items);try{for(l.s();!(h=l.n()).done;)d=h.value,this._addItem(d)}catch(e){l.e(e)}finally{l.f()}case 21:e.next=12;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(10),i.e(e.t0);case 28:return e.prev=28,i.f(),e.finish(28);case 31:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=36;break;case 34:this._origin=n.value,this._table=Pi(this._origin);case 36:ps[this.indexerKey]=this;case 37:case"end":return e.stop()}}),e,this,[[10,25,28,31]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return us.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete ps[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Pi(this._origin)}},{key:"abort",value:function(){this._table=Pi(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in ps)delete ps[e]}}]),e}(),vs="undefined"!=typeof document&&"undefined"!=typeof navigator;vs&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var ms=vs&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");vs&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),vs&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),vs&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var gs,_s,ys=vs&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),ks=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)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(gs||(gs={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(_s||(_s={}));var Es,bs={},ws=function(){function e(t){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n(this,e),this._state=gs.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],bs[t]&&!a.forceCreate||(this.nodeId=ks(),this.key=t,vs&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&r.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,n=t.nodeId,a=t.requestId,i=t.key,s=t.op,o=t.data;if(n!==r.nodeId&&i===r.key)switch(s){case _s.NEWNODE:r._sendSync();break;case _s.CLAIM_HOST:r._sendSync(),r._hostId=n;break;case _s.SYNC_HOST:if(!r.isInSync){r._activationTimeout&&clearTimeout(r._activationTimeout);var u,c=o.currentItemRequestId,l=k(o.queue);try{var h=function(){var e=u.value,t=r._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&r._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:r.key,op:_s.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}r._currentItem=r._queue.find((function(e){return e.requestId===c})),r._completeSync()}break;case _s.REMOVENODE:r._queue=r._queue.filter((function(e){return e.nodeId!==t.nodeId})),r._currentItem&&r._currentItem.nodeId===t.nodeId&&(r._currentItem=null,r._acquire(r._queue[0]));break;case _s.REQUEST_LOCK:r._requestLock(t);break;case _s.ACQUIRE_LOCK:var d=r._queue.find((function(e){return e.requestId===a}));r._acquire(d);break;case _s.RELEASE_LOCK:r._release(a)}})),window.addEventListener("beforeunload",(function(){r._send(_s.REMOVENODE)}))),bs[t]=this),bs[t]}return a(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==gs.DONE}},{key:"_send",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={nodeId:this.nodeId,requestId:null!==(t=null==r?void 0:r.requestId)&&void 0!==t?t:ks(),key:this.key,op:e,data:null!==(n=r.data)&&void 0!==n?n:null,ts:Date.now()};return vs&&window.postMessage(a,"*"),a}},{key:"_acquire",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(_s.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}}},{key:"_requestLock",value: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(_s.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(_s.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}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=gs.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(_s.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(_s.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(_s.REQUEST_LOCK),e.next=5,this._requestLock(t);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)}}]),e}(),Cs=function(){function e(t){var r=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;n(this,e),this._state=Oi.INIT,this._metadata=null,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(g(u.filter((function(e){return fs.createKey(e)!==r.keyName})))),this._keyHash=o,this._store=c,this._mutex=new ws(function(e,t){return"".concat($i(e,t),".lock")}(a,i)),this._blobContainer=new is({dbname:a,collectionName:i,store:c}),this._transaction=new cs({dbname:a,collectionName:i,store:c})}return a(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Oi.READY}},{key:"init",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=Ui.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new ds({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=g(this.indexes),i=[],s=a.map((function(e){return fs.createKey(e)})),o=r?r.indexes.map((function(e){return fs.createKey(e)})):[],u=k(o);try{for(u.s();!(c=u.n()).done;)l=c.value,s.includes(l)||i.push(fs.parseKey(l))}catch(e){u.e(e)}finally{u.f()}return(h=[]).push.apply(h,g(a.map((function(e){var t=new fs({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),h.push.apply(h,g(i.map((function(e){return new fs({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(h);case 22:return t.next=24,this._transaction.commit();case 24:if(s.sort().join(",")===o.sort().join(",")){t.next=29;break}return d=es(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:d,value:this._metadata,generation:1});case 29:this._state=Oi.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Oi.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=fs.createKey(e),r=k(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===fs.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=es(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata,generation:1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=k(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Li.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=k(this._indexers),t.prev=14,a.s();case 16:if((i=a.n()).done){t.next=22;break}return s=i.value,t.next=20,s.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:o=k(this._indexers),t.prev=35,o.s();case 37:if((u=o.n()).done){t.next=46;break}if(0===(c=u.value).diff(c.getColumnValues(r),c.getColumnValues(e))){t.next=44;break}return t.next=42,c.removeItem(r);case 42:return t.next=44,c.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),o.e(t.t1);case 51:return t.prev=51,o.f(),t.finish(51);case 54:case"end":return t.stop()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=k(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(s=i.value).diff(s.getColumnValues(r),s.getColumnValues(e))){t.next=17;break}return t.next=15,s.removeItem(r);case 15:return t.next=17,s.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=k(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=k(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",Pi(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Li.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.isReady?new Xi({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Li.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Pi(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Li.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Li.collectionKeyNotGiven;case 6:n=k(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(Pi(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Li.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Li.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Pi(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Li.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Li.collectionKeyNotGiven;case 6:n=k(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(Pi(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Li.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Li.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Pi(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Li.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h,d,p,f=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new Ji({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(f,void 0,void 0,regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}if(e.hasNext){if(r=e.nextValue,Hi(a,r)&&t.set){if("function"!=typeof t.set)for(i in t.set)r[i]=t.set[i];else t.set(r);c.push(r)}e.next()}else e.stop();n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,d=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._blobContainer.save(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeBlob",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"removeAllBlobs",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blobContainer.clear();case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"metadataOf",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=es(e,t),r.next=3,n.get(a);case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}}),r)})))}}]),e}(),Rs=function(){function e(t){var r,a,i;n(this,e),this.encryption=null!==(r=t.encryption)&&void 0!==r?r:H,this.itemSizeLimit=null!==(a=t.itemSizeLimit)&&void 0!==a?a:4194304,this.metadataBuffer=null!==(i=t.metadataBuffer)&&void 0!==i?i:256}return a(e,[{key:"_getRawKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return g(Array(e).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=k(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(s=e.sent)&&(t+=JSON.stringify(s).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Li.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setRaw((n=[]).concat.apply(n,g(e.map((function(e){return r._shardify(e)})))));case 2:return t.abrupt("return",e.map((function(e){return e.value})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=9;break}return a=r.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],r=k(e),t.prev=2,i=regeneratorRuntime.mark((function e(){var t,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.value,r=s._getRawKey(t,".0"),e.next=4,s._getRaw(r);case 4:(i=e.sent)&&(o=i.metadata,n.push.apply(n,g(s._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return s._getRawKey(t,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),r.s();case 5:if((a=r.n()).done){t.next=9;break}return t.delegateYield(i(),"t0",7);case 7:t.next=5;break;case 9:t.next=14;break;case 11:t.prev=11,t.t1=t.catch(2),r.e(t.t1);case 14:return t.prev=14,r.f(),t.finish(14);case 17:if(!(n.length>0)){t.next=20;break}return t.next=20,this._removeRaw(n);case 20:return t.abrupt("return",e);case 21:case"end":return t.stop()}}),t,this,[[2,11,14,17]])})))}}]),e}(),xs=4194304,Ts={},Is=function(e){i(r,e);var t=p(r);function r(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,r),e=t.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:xs}));var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return a(r,[{key:"rawData",get:function(){return Ts[this.dbname]},set:function(e){Ts[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ts[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Ts[this.dbname]));case 4:throw Li.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ts[this.dbname]){t.next=6;break}return t.next=3,qi(this.delay);case 3:return t.abrupt("return",Ts[this.dbname][e]?Object.assign({key:e},Ts[this.dbname][e]):null);case 6:throw Li.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ts[this.dbname]){t.next=7;break}return t.next=3,qi(this.delay);case 3:n=k(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,s=a.data,o=a.metadata,Ts[this.dbname][i]=Object.freeze({data:s,metadata:o})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Li.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Ts[this.dbname]){t.next=7;break}return t.next=3,qi(this.delay);case 3:n=k(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Ts[this.dbname][a]&&delete Ts[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Li.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"isAvailable",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 1:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,Ts[this.dbname]={};case 2:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var t=this,n=Object.create(null,{set:{get:function(){return v(s(r.prototype),"set",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.observer[e.key]||"function"!=typeof this.observer[e.key].set){t.next=4;break}if(!(r=this.observer[e.key].set())){t.next=4;break}throw r;case 4:return t.abrupt("return",n.set.call(this,e));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var t=this,n=Object.create(null,{setMany:{get:function(){return v(s(r.prototype),"setMany",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=k(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=11;break}if(i=a.value,!this.observer[i.key]||"function"!=typeof this.observer[i.key].set){t.next=9;break}if(!(s=this.observer[i.key].set())){t.next=9;break}throw s;case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),r.e(t.t0);case 16:return t.prev=16,r.f(),t.finish(16);case 19:return t.abrupt("return",n.setMany.call(this,e));case 20:case"end":return t.stop()}}),t,this,[[1,13,16,19]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,qi(this.delay);case 2:Ts[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),r}(Rs),Ss=104857600,Ns="NestDBStore",Ms=function(e){i(r,e);var t=p(r);function r(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),(e=t.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:Ss})))._storeName=Ns,e._window="undefined"!=typeof window?window:null,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:null,e}return a(r,[{key:"_getObjectStore",value:function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,n){var r=t._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,r){var a=n._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,r){var a=n.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,r){var a=n.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"isAvailable",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=15;break}return e.prev=2,this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,n="undefined"!=typeof document&&"undefined"!=typeof navigator,r=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),a=navigator.userAgent&&navigator.userAgent.includes("Edge/"),e.next=9,new Promise((function(e,s){if(n)if(r){var o=i._indexedDb.open("_testMozilla");o.onerror=function(){return s("Private browsing mode.")},o.onsuccess=function(){return e()}}else a?(t.PointerEvent||t.MSPointerEvent)&&s("Private browsing mode."):e()}));case 9:return e.abrupt("return",!0);case 12:return e.prev=12,e.t0=e.catch(2),e.abrupt("return",!1);case 15:return e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,this,[[2,12]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,n=new Promise((function(e,t){if(r._window&&vs)if(ms){var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Li.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}else ys?r._window.indexedDB||!r._window.PointerEvent&&!r._window.MSPointerEvent||t(Li.storeNotAvailableInPrivateBrowsing):e();else t(Li.storeNotAvailable)})),t.next=4,n;case 4:return t.next=6,new Promise((function(t,n){var a=r._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Ns,{keyPath:"key"})})),a.addEventListener("success",(function(e){return t(e.target.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 6:this._database=t.sent;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,n){var r=t._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),r}(Rs),As=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?6291456:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(i.mutedUsers=o.map((function(t){return new Hs(e,t)}))),i}return a(r)}($),$s=function(e){i(r,e);var t=p(r);function r(e,a,i,s){return n(this,r),t.call(this,e,a,i,s)}return a(r,[{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new Xs(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Zs),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(sr),eo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=R.GET,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=J({limit:o,token:u}),a}return a(r)}(Z),to=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new Hs(e,t.user)}))),i}return a(r)}($),no=function(e){i(r,e);var t=p(r);function r(e,a,i,s){return n(this,r),t.call(this,e,a,i,s)}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new eo(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(to),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(sr);e.ReportCategory=void 0,(Gs=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",Gs.HARASSING="harassing",Gs.SUSPICIOUS="suspicious",Gs.INAPPROPRIATE="inappropriate";var ro,ao=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=R.POST,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return a(r)}(Z),io=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return a(r)}(Z),so=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=R.GET,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return a(r)}(Z),oo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).isMuted=!1,i.startAt=null,i.endAt=null,i.remainingDuration=null,i.description=null;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return a(r)}($),uo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=R.GET,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return a(r)}(Z),co=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=null!=o?o:null,i}return a(r)}($),lo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=t.call(this)).method=R.POST,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return a(r)}(Z),ho=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o;return n(this,r),(i=t.call(this,e,a)).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return a(r)}($),po=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=R.PUT,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return a(r)}(Z),fo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=null!=o?o:null,i}return a(r)}($),vo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).created=null,s.updated=null,s.deleted=null,i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return a(r)}(se),mo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return a(r)}(Z),go=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.ts;return i.ts=null!=s?s:null,i}return a(r)}($),_o=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return a(r)}(Z),yo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.ts;return i.ts=null!=s?s:null,i}return a(r)}($),ko=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=R.GET,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return a(r)}(Z),Eo=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),bo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=R.POST,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return a(r)}(Z),wo=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),Co=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=R.PUT,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return a(r)}(Z),Ro=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),xo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).created=null,s.updated=null,s.deleted=null,i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return a(r)}(se),To=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params=null,a}return a(r)}(Z),Io=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params=null,a}return a(r)}(Z),So=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=R.POST,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return a(r)}(Z),No=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new Hs(e,i.data),s}return a(r)}(se),Mo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Ao=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new Hs(e,i.data),s}return a(r)}(se),Uo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=R.POST,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=J({user_id:o,seconds:u,description:c}),a}return a(r)}(Z),Oo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).memberCount=null,s.joinedMemberCount=null,s.user=new Hs(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return a(r)}(se),Lo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Do=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new Hs(e,i.data),s}return a(r)}(se),Po=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=t.call(this)).method=R.PUT,a.path="".concat(gn(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return a(r)}(Z),Fo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).freeze=i.data.freeze,s}return a(r)}(se),Go=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=R.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return a(r)}(Z),qo=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(a=r.call(this)).method=R.POST,a.path="".concat(Re,"/users/").concat(l),a.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},a}return a(s)}(Z),Ho=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=R.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return a(r)}(Z),Vo=function(t){i(s,t);var r=p(s);function s(t){n(this,s);var a=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"MESG",ackRequired:!0,payload:J({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:a,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return a(s)}(le),jo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"MESG",i)).message=new pn(e,i);var l=It.of(e).sdkState;return s.isMentioned=yn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),Qo=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"MEDI",ackRequired:!0,payload:J({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(a=t.appleCriticalAlertOptions)||void 0===a?void 0:a.serialize(),poll_id:t.pollId})})}return a(s)}(le),Bo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"MEDI",i)).message=new pn(e,i);var p=It.of(e).sdkState;return s.mentionCountChange=kn({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),Ko=function(t){i(s,t);var r=p(s);function s(t){n(this,s);var a=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"FEDI",ackRequired:!0,payload:J({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:a,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return a(s)}(le),zo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"FEDI",i)).message=new mn(e,i);var p=It.of(e).sdkState;return s.mentionCountChange=kn({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),Wo=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return a(r)}(Z),Yo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"DELM",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s}return a(r)}(se),Jo=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return a(r)}(Z),Xo=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).reactionEvent=new Bt(a),i}return a(r)}($),Zo=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return a(r)}(Z),$o=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).reactionEvent=new Bt(Object.assign({},a)),i}return a(r)}($),eu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return a(r)}(Z),tu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new pn(e,a),i}return a(r)}($),nu=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return a.method=R.POST,a.path="".concat(gn(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Mt.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return zt.payloadify(e)})),apple_critical_alert_options:Jt.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},a}return a(s)}(Z),ru=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new pn(e,a),i}return a(r)}($),au=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return a.method=R.POST,a.path="".concat(gn(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Mt.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return nn.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return zt.payloadify(e)})),apple_critical_alert_options:Jt.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},a}return a(s)}(Z),iu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new mn(e,a),i}return a(r)}($),su=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;return n(this,o),(i=r.call(this,t)).url="",i.channelType=e.ChannelType.BASE,i.name="",i.coverUrl="",i.customType="",i.data="",i.isFrozen=!1,i.isEphemeral=!1,i.creator=null,i.createdAt=0,i.url=a.channel_url,i.name=null!==(s=a.name)&&void 0!==s?s:"",i.coverUrl=null!==(u=a.cover_url)&&void 0!==u?u:"",i.customType=null!==(c=a.custom_type)&&void 0!==c?c:"",i.data=null!==(l=a.data)&&void 0!==l?l:"",i.isFrozen=!!M("boolean",a.freeze)&&a.freeze,i.isEphemeral=!!M("boolean",a.is_ephemeral)&&a.is_ephemeral,i.creator=a.created_by?new dt(i._iid,a.created_by):null,i.createdAt=1e3*a.created_at,i._cachedMetaData=new Map,a.metadata&&a.ts&&Object.keys(a.metadata).forEach((function(e){i._cachedMetaData.set(e,{value:a.metadata[e],isRemoved:!1,updatedAt:a.ts})})),i}return a(o,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Js(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new $s(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new no(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new or(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new ao({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new io({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new so({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(oo),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new uo({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(co),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new uo({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(co),s=i.metadata,o=i.ts,this._upsertCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new lo({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(ho),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=It.of(this._iid),a=r.requestQueue,i=new po({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(fo),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new mo({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(go),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new _o({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(yo),s=i.ts,this._removeFromCachedMetaData(g(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new ko({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(Eo),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new ko({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Eo),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new bo({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(wo),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=It.of(this._iid),a=r.requestQueue,i=new Co({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Ro),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new Co({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ro),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new Co({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ro),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new To({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Io({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(M("string",e)&&M("number",t,!0)&&M("string",n,!0)).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new So({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new Mo({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(M("string",e)&&M("number",t,!0)&&M("string",n,!0)).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new Uo({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new Lo({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Po({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Po({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Tn),t),lt(M("number",e)&&In(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Tn),t),lt(M("number",e)&&In(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Sn),t),lt(M("number",e)&&Nn(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Sn),t),lt(M("string",e)&&Nn(r)).throw(T.invalidParameters),a=Wn.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a=It.of(this._iid).sessionManager;return J({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return zt.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?Jt.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:en.payloadify(a.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:t.mentionedUsers})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,s=k(t.translationTargetLanguages);try{for(s.s();!(i=s.n()).done;){a[i.value]=""}}catch(e){s.e(e)}finally{s.f()}}var o=J(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new pn(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a=J(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:t.fileName,size:t.fileSize,type:t.mimeType,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),i=new mn(this._iid,a);return i.messageParams=t,i}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===b.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Zr),e);return lt(ea(t)).throw(T.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=It.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=r,u=Date.now(),c=new Yn;if(!o){o=this._generateRequestId();var l=It.of(this._iid),h=l.dispatcher;De(2).then((function(){var r=n._createPendingUserMessage(t,o,u);h.dispatch(new Un({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}))}var d=new Vo(Object.assign(Object.assign({},t),{channelUrl:this.url,channelType:this.channelType,reqId:o}));return s.send(d).then((function(t){var r=t.as(jo).message;i.dispatch(new Un({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(x(r))throw r;De(2).then((function(){var a=n._createPendingUserMessage(t,o,u),s=It.of(n._iid).cacheContext.localCacheEnabled&&L(r.code);n._markMessageAsFailed(a,r,s),i.dispatch(new Un({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))})),c}},{key:"_autoResendUserMessage",value:function(e){return lt(e instanceof pn).throw(T.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof pn&&!e.scheduledInfo).throw(T.invalidParameters),r=new de,a=null!==(t=e.messageParams)&&void 0!==t?t:$r(e),this._sendUserMessage(a,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Qs),t),lt(M("number",e)&&Bs(r)).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new Qo(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Bo),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,a,i;return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var u,c;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return lt(t instanceof o&&n instanceof pn&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(T.invalidParameters),lt(!n.poll).throw(T.notSupportedError),u=new de,c=null!==(r=n.messageParams)&&void 0!==r?r:Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),s.abrupt("return",u.promise);case 6:case"end":return s.stop()}}),s,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof pn&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new eu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(tu),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=It.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();De(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new nu(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(ru).message;Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(x(r))throw r;De(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},ia),e);return lt(oa(t)).throw(T.invalidParameters),this._sendFileMessage(t)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=It.of(this._iid),i=a.dispatcher,s=Wn.of(this._iid),o=s.fileMessageQueue,u=r,c=Date.now(),l=new Yn;return u||(u=this._generateRequestId(),De(2).then((function(){var r=n._createPendingFileMessage(t,u,c);i.dispatch(new Un({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}))),o.request(this,u,t).then((function(t){i.dispatch(new Un({messages:[t],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(x(r))throw r;De(2).then((function(){var a=n._createPendingFileMessage(t,u,c),s=It.of(n._iid).cacheContext.localCacheEnabled&&L(r.code);n._markMessageAsFailed(a,r,s),i.dispatch(new Un({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){lt(e instanceof mn).throw(T.invalidParameters);var t=It.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=It.of(this._iid).requestQueue,s=new au(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(iu).message;Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(x(i))throw i;De(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){lt(e.every((function(e){return oa(Object.assign(Object.assign({},ia),e))}))).throw(T.invalidParameters);var t,n=new Yn,r=k(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,t){var n;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=Boolean(e.url)||D(t)||D(null===(n=e.messageParams)||void 0===n?void 0:n.file),lt(e instanceof mn&&a&&!e.scheduledInfo).throw(T.invalidParameters),i=new de,s=sa(e,t),this._sendFileMessage(s,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),r.abrupt("return",i.promise);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Ks),t),lt(M("number",e)&&zs(r)).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new Ko(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(zo),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=Wn.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,a;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return lt(t instanceof o&&n instanceof mn&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(T.invalidParameters),s=new de,u=Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:n.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1}),t._sendFileMessage(u).onSucceeded((function(e){return s.resolve(e)})).onFailed((function(e){return s.reject(e)})),i.abrupt("return",s.promise);case 5:case"end":return i.stop()}}),i,this)})))}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(lt(e instanceof $t).throw(T.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=It.of(this._iid),r=n.requestQueue,a=new Wo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&M("string",t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new Jo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Xo),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&M("string",t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new Zo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as($o),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,o,u,c,l,h,d;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=It.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new Qo({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(Bo),d=h.message,o.dispatch(new Un({messages:[d],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",d);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=t.map((function(e){return new zt({key:e})})),n.abrupt("return",this._updateMessageMetaArray(e.messageId,r,"add",!0));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=t.map((function(e){return new zt({key:e})})),n.abrupt("return",this._updateMessageMetaArray(e.messageId,r,"remove",!0));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&t.every((function(e){return e instanceof zt}))).throw(T.invalidParameters),n.abrupt("return",this._updateMessageMetaArray(e.messageId,t,"add",!0));case 2:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(e instanceof $t&&e.messageId>0&&t.every((function(e){return e instanceof zt}))).throw(T.invalidParameters),n.abrupt("return",this._updateMessageMetaArray(e.messageId,t,"remove",!0));case 2:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(A(e.ReportCategory,t)&&M("string",n)).throw(T.invalidParameters),a=It.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Go({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){var i,s,o,u;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return lt(t instanceof dt&&A(e.ReportCategory,n)&&M("string",r)).throw(T.invalidParameters),i=It.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new qo({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){var i,s,o,u;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return lt(t instanceof tn&&A(e.ReportCategory,n)&&M("string",r)).throw(T.invalidParameters),i=It.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Ho({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}}],[{key:"payloadify",value:function(e){return J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:dt.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),o}(tt),ou=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return a(r)}(dt),uu=null,cu=function(){function t(e,r,a){var i=this;n(this,t),this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=r;var s=It.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,d=s.logger,p=s.userEventHandlers;this._onlineDetector=new ga({logger:d,connectionDelegate:{reconnect:function(){var t=It.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){It.of(e).connectionManager.disconnect()}}});var f=new ka(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:d});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:d,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new ma,this._appStateChangeDetector.on("resume",(function(){d.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){d.debug("the page freezes"),i.setBackgroundState()})),c.on((function(t){if(t instanceof ve)t.stateType===ue.CONNECTED&&f.processNonAutoResendRegisteredPendingMessages();else if(t instanceof se){if("USEV"===t.code){var n=t.as(Ca).event;if(n.category===ta.FRIEND_DISCOVERED){var r=ba.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;Ge((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(r)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(t instanceof he){var a=It.of(i._iid).subscribedUnreadMessageCount,s=!1,c=t.ts;if("number"==typeof c&&c>a.ts){if(a.all!==t.all&&(s=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(s=!0),a.customTypes[l]=t.customTypes[l];s=s&&a.ts>0,a.ts=c}s&&Ge((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof pt&&u.localCacheEnabled&&u.preference.set(i._getUserProfileCacheKey(o.userId),ft.payloadify(t.userProfile))}))}return a(t,[{key:"appId",get:function(){return It.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return It.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=It.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return It.of(this._iid).debugMode}},{key:"logLevel",get:function(){return It.of(this._iid).logger.level},set:function(e){It.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return It.of(this._iid).cacheContext.localCacheEnabled}},{key:"ekey",get:function(){return Ze(this._iid)}},{key:"currentUser",get:function(){var e;return null!==(e=It.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=It.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=It.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=It.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Is?n.store:null;throw T.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=It.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"initializeCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=It.of(this._iid),r=n.sdkState,a=n.cacheContext,i=n.connectionManager,s=n.dispatcher,r.userId&&r.userId===e){t.next=23;break}return t.next=4,i.logout();case 4:if(r.userId=e,o="sendbird@".concat(r.appId,"/").concat(e,".db"),!a.localCacheEnabled){t.next=15;break}if(a.nestdb&&a.nestdb.state!==Es.CLOSED&&a.nestdb.name===o){t.next=13;break}return(u=a.nestdb=new Fs({name:"sendbird@".concat(r.appId,"/").concat(e,".db"),version:2,store:a.store})).on("upgrade",pa(u,a.store)),t.next=12,u.open();case 12:s.dispatch(new wa(this._iid,{userId:e}));case 13:t.next=17;break;case 15:return t.next=17,a.store.init(o);case 17:return t.next=19,a.preference.init(this._getPreferenceCacheKey(e));case 19:return t.next=21,a.preference.get(this._getUserProfileCacheKey(e));case 21:(c=t.sent)&&new ft(this._iid,c).apply();case 23:case"end":return t.stop()}}),t,this)})))}},{key:"clearCachedData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),(n=t.cacheContext).localCacheEnabled&&n.nestdb&&n.nestdb.clear(),e.next=4,n.preference.clear();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(lt(O("string",e)).throw(T.invalidParameters),n=va.of(this._iid),r=da.of(this._iid),!n||!r){t.next=6;break}return t.next=6,Promise.all(e.map((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.removeMessagesOfChannel(e);case 2:return t.next=4,r.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),t)})))})));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("string",e)&&M("string",t,!0)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.cacheContext,s=r.connectionManager,o=r.statLogCollector,n.prev=2,n.next=5,this.initializeCache(e);case 5:n.next=12;break;case 7:n.prev=7,n.t0=n.catch(2),u=It.of(this._iid),c=u.logger,i.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available.");case 12:return n.next=14,o.init("sendbird@".concat(a.appId,"/").concat(e,".statlog"));case 14:return this._onlineDetector.start(),this._appStateChangeDetector.start(),n.next=18,s.connect(t);case 18:return n.abrupt("return",this.currentUser);case 19:case"end":return n.stop()}}),n,this,[[2,7]])})))}},{key:"reconnect",value:function(){var e=It.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r}},{key:"disconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=It.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=It.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){lt(e instanceof Fr).throw(T.invalidParameters),It.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){lt(M("string",e)&&t instanceof qr).throw(T.invalidParameters),It.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){It.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){It.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){lt(M("string",e)&&t instanceof Gr).throw(T.invalidParameters),It.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){It.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){It.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ri(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ii(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Mi(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new ir(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Mr(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new Or(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=ct(e);return new dt(this._iid,dt.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Dr),e),lt(Pr(n)).throw(T.invalidParameters),!this.currentUser){t.next=13;break}return r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ra(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(xa),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw T.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(lt(O("string",e)).throw(T.invalidParameters),!this.currentUser){t.next=12;break}return n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Ra({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(xa),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw T.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(lt(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=16;break}return n.prev=2,r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ia({userId:a.userId,token:t}),n.next=7,i.send(s);case 7:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 11:return n.prev=11,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 14:n.next=18;break;case 16:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 18:case"end":return n.stop()}}),n,this,[[2,11]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(lt(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=16;break}return n.prev=2,r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Na({userId:a.userId,token:t}),n.next=7,i.send(s);case 7:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 11:return n.prev=11,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 14:n.next=18;break;case 16:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 18:case"end":return n.stop()}}),n,this,[[2,11]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.currentUser){e.next=5;break}return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Aa({userId:n.userId}),e.next=5,r.send(a);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(lt(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=16;break}return n.prev=2,r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Ta({userId:a.userId,token:t}),n.next=7,i.send(s);case 7:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 11:return n.prev=11,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 14:n.next=18;break;case 16:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 18:case"end":return n.stop()}}),n,this,[[2,11]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(lt(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=16;break}return n.prev=2,r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Sa({userId:a.userId,token:t}),n.next=7,i.send(s);case 7:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 11:return n.prev=11,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 14:n.next=18;break;case 16:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 18:case"end":return n.stop()}}),n,this,[[2,11]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.currentUser){e.next=5;break}return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ma({userId:n.userId}),e.next=5,r.send(a);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new La({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Da),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("boolean",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Pa({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(Fa),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ga({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(qa),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return lt(M("boolean",e)&&M("number",t)&&M("number",n)&&M("number",r)&&M("number",a)&&M("string",i)).throw(T.invalidParameters),o=It.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new Ha({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,d=h.as(Va),p=d.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ja({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Qa),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(M("boolean",e)&&M("number",t)&&M("number",n)).throw(T.invalidParameters),a=It.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Ba({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(Ka),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(M("string",t)&&A(e.PushTokenType,n)).throw(T.invalidParameters),a=It.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new Ua({userId:i.userId,type:n,token:t}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(Oa),l=c.pushTokens,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Ya({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(Ja).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(A(e.PushTriggerOption,t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Xa({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(Za).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new $a({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(ei).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(A(e.PushTemplate,t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new ti({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(ni).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(e instanceof dt||M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new za({userId:r.userId,blockedUserId:e instanceof dt?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(e instanceof dt||M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Wa({userId:r.userId,unblockedUserId:e instanceof dt?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ri({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(ai),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new hi({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(di),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("boolean",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new pi({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ii({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(si),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new oi({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ui({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(ci),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(O("string",e)).throw(T.invalidParameters),n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new li({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new gi,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(_i),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new yi({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(ki),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=new Ei({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(bi),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}}],[{key:"init",value:function(e){var n=e.appId,r=e.appVersion,a=void 0===r?null:r,i=e.modules,s=void 0===i?[]:i,o=e.options,u=void 0===o?new q:o,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,p=e.newInstance,f=void 0!==p&&p,v=e.logLevel,m=e.localCacheEnabled,_=void 0!==m&&m,y=e.localCacheEncryption,k=e.useAsyncStorageStore,E=void 0===k?null:k;if(!uu||f){var b="su-".concat(B()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},C=new Is({encryption:w});l||(C=E?new As({AsyncStorage:E,encryption:w}):new Ms({encryption:w})),new It(b,{appId:n,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:C,encryption:w,logLevel:v,localCacheEnabled:_,debugMode:l});var R=[new lr,new Lr],x=new t(b,u,[].concat(g(s),R));return uu||(uu=x),x}return uu}},{key:"instance",get:function(){return uu}},{key:"version",get:function(){return w}}]),t}();e.MemberState=void 0,(ro=e.MemberState||(e.MemberState={})).NONE="none",ro.JOINED="joined",ro.INVITED="invited",ro.LEFT="left";var lu,hu,du,pu,fu,vu,mu,gu,_u=function(t){i(o,t);var r=p(o);function o(t,a){var i;return n(this,o),(i=r.call(this,t,a)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=A(e.MemberState,a.state)?a.state:null,i.role=A(e.Role,a.role)?a.role:null,a.hasOwnProperty("is_muted")&&(i.isMuted=a.is_muted),a.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=a.is_blocked_by_me),a.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=a.is_blocking_me),i}return a(o,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),o}(Hs),yu=function(t){i(s,t);var r=p(s);function s(t,a){var i,o,u;return n(this,s),(i=r.call(this,t)).channelUrl=null!==(o=a.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=a.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new dt(i._iid,a.user),i.readAt=a.ts,i}return a(s)}(tt);e.PublicChannelFilter=void 0,(lu=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",lu.PUBLIC="public",lu.PRIVATE="private",e.MyMemberStateFilter=void 0,(hu=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",hu.JOINED="joined_only",hu.INVITED="invited_only",hu.INVITED_BY_FRIEND="invited_by_friend",hu.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(du=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",du.SUPER="super",du.NON_SUPER="nonsuper",du.BROADCAST_ONLY="broadcast_only",du.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(pu=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",pu.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(fu=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",fu.UNHIDDEN="unhidden_only",fu.HIDDEN="hidden_only",fu.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",fu.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(vu=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",vu.OPERATOR="operator",vu.NONOPERATOR="nonoperator",e.QueryType=void 0,(mu=e.QueryType||(e.QueryType={})).AND="AND",mu.OR="OR",e.GroupChannelSearchField=void 0,(gu=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",gu.CHANNEL_NAME="channel_name";var ku,Eu=function(){function t(){n(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return a(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.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=g(e).sort(),r=g(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(t.members.every((function(e){return e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),bu=function(t){i(s,t);var r=p(s);function s(e,t){var a,i=t.sdkState,o=t.cacheContext;return n(this,s),(a=r.call(this,e))._channels=new Map,a._sdkState=i,a._cacheContext=o,a}return a(s,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Hr):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Bc.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return g(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAt0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g(this._channels.keys());return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=k(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return s=i.value,n.next=8,this.get(s);case 8:(o=n.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(o._updateUnreadCount(0,0),r.push(o));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}]),s}(tt);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(ku||(ku={}));var wu,Cu=function(){function t(e){n(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return a(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),Ru={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},xu=function(e){return O("string",e.invitedUserIds,!0)&&M("string",e.channelUrl,!0)&&M("string",e.coverUrl,!0)&&(D(e.coverImage)||M("string",e.coverImage)||null===e.coverImage)&&M("boolean",e.isDistinct,!0)&&M("boolean",e.isSuper,!0)&&M("boolean",e.isBroadcast,!0)&&M("boolean",e.isExclusive,!0)&&M("boolean",e.isPublic,!0)&&M("boolean",e.isStrict,!0)&&M("boolean",e.isDiscoverable,!0)&&M("boolean",e.isEphemeral,!0)&&M("string",e.accessCode,!0)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&O("string",e.operatorUserIds,!0)&&M("number",e.messageSurvivalSeconds,!0)},Tu={customTypes:null,includeEmpty:!1,includeFrozen:!0},Iu=function(e){return O("string",e.customTypes,!0)&&M("boolean",e.includeEmpty)&&M("boolean",e.includeFrozen)},Su={myMemberStateFilter:e.MyMemberStateFilter.ALL},Nu=function(t){return A(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(wu=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",wu.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",wu.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",wu.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",wu.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",wu.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",wu.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",wu.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",wu.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var Mu,Au={keys:[]},Uu=function(t){return O(e.UnreadItemKey,t.keys)},Ou={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},Lu=function(t){return O("string",t.channelCustomTypesFilter,!0)&&A(e.SuperChannelFilter,t.superChannelFilter)},Du={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},Pu=function(t){return M("string",t.channelUrl,!0)&&O(e.ScheduledStatus,t.scheduledStatus,!0)&&A(e.MessageTypeFilter,t.messageTypeFilter)};e.GroupChannelEventSource=void 0,(Mu=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",Mu.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Mu.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Mu.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Mu.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Mu.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Mu.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Mu.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Mu.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Mu.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Mu.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Mu.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Mu.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Mu.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Mu.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Mu.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Mu.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Mu.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Mu.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Mu.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Mu.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Mu.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Mu.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Mu.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Mu.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Mu.REQUEST_CHANNEL="REQUEST_CHANNEL",Mu.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Mu.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Mu.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var Fu,Gu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS},qu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channels,s=e.source;return n(this,r),(a=t.call(this)).channels=i,a.source=s,a}return a(r)}(Y),Hu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrls,s=e.source;return n(this,r),(a=t.call(this)).channelUrls=i,a.source=s,a}return a(r)}(Y),Vu=function(){function e(t){var r=this,a=t.groupChannelCache,i=t.messageCache,s=t.unsentMessageCache,o=t.dispatcher;n(this,e),this._observers=new Map,o.on((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,o,u,c,l,h,d,p,f=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof qu)){t.next=26;break}n=e.channels,r=e.source,o=n.filter((function(e){return e instanceof lh})),u=a.filterOffsetChanged(o),c=k(u),t.prev=5,c.s();case 7:if((l=c.n()).done){t.next=13;break}return h=l.value,t.next=11,i.removeUnderOffset(h.url,h.messageOffsetTimestamp);case 11:t.next=7;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(5),c.e(t.t0);case 18:return t.prev=18,c.f(),t.finish(18);case 21:return t.next=23,a.upsert(o);case 23:this._broadcastUpdateEvent(o,r),t.next=38;break;case 26:if(!(e instanceof Hu)){t.next=35;break}return d=e.channelUrls,p=e.source,t.next=30,a.remove(d);case 30:return t.next=32,qe((function(){return E(f,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(d),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,i.removeMessagesOfChannel(r);case 7:return e.next=9,s.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 32:this._broadcastRemoveEvent(d,p),t.next=38;break;case 35:if(!(e instanceof wa)){t.next=38;break}return t.next=38,a.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 38:case"end":return t.stop()}}),t,this,[[5,15,18,21]])})))}))}return a(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),ju=function(){function e(t){var r=this,a=t.cacheContext,i=t.messageCache,s=t.unsentMessageCache,o=t.dispatcher,u=t.logger;n(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=a,this._logger=u,o.on((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,o,u,c,l,h,d,p,f,v,m,g,_,y,k,b,w=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Un)){t.next=14;break}if(n=e.messages,r=e.source,a=n.filter((function(e){return e.messageId>0})),o=n.filter((function(e){return 0===e.messageId})),!(a.length>0)){t.next=8;break}return t.next=7,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(a);case 2:return e.next=4,s.remove(a.map((function(e){return e instanceof tn?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(a,r);case 8:if(!(o.length>0)){t.next=12;break}return t.next=11,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.upsert(o);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(o,r);case 12:t.next=61;break;case 14:if(!(e instanceof On)){t.next=21;break}return u=e.messageIds,c=e.source,t.next=18,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(u);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(u,c),t.next=61;break;case 21:if(!(e instanceof Ln)){t.next=28;break}return l=e.reqId,h=e.source,t.next=25,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.remove([l]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(l,h),t.next=61;break;case 28:if(!(e instanceof Dn)){t.next=41;break}if(d=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){t.next=38;break}return f=d.map((function(e){return e.messageId})),t.next=34,Promise.all(f.map((function(e){return i.get(e)})));case 34:return v=t.sent.filter((function(e){return e})),v.length>0&&d.forEach((function(e){var t=v.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),t.next=38,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(v);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(d,p),t.next=61;break;case 41:if(!(e instanceof Pn)){t.next=52;break}return m=e.event,g=e.source,t.next=45,i.get(m.messageId);case 45:if(!((_=t.sent)&&_.isUserMessage()&&_.poll&&_.poll.applyPollUpdateEvent(m))){t.next=49;break}return t.next=49,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([_]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),t.next=61;break;case 52:if(!(e instanceof Fn)){t.next=61;break}return y=e.event,k=e.source,t.next=56,i.get(y.messageId);case 56:if(!((b=t.sent)&&b.isUserMessage()&&b.poll&&b.poll.applyPollVoteEvent(y))){t.next=60;break}return t.next=60,qe((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([b]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(y,k);case 61:case"end":return t.stop()}}),t,this)})))}))}return a(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Qu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter;n(this,r),a=t.call(this);var c=Object.assign(Object.assign({},Tu),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=J({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s>0?s:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return a(r)}(Z),Bu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new lh(e,t)})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i}return a(r)}($),Ku=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.isInternalCall;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(s?Ee:ke,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return a(r)}(Z),zu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=null,i.channel=new lh(e,a),i}return a(r)}($),Wu=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,p=e.unreadChannelFilter,f=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,m=e.nicknameExactMatchFilter,g=e.channelNameContainsFilter,_=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,I=e.includeMetaData,S=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=J({token:s,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:p,members_nickname_contains:f,members_nickname_startswith:v,members_nickname:m,name_contains:g,channel_urls:_,custom_types:y,custom_type_startswith:k,hidden_mode:E,metadata_order_key:b,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:I}),S&&S.query&&S.fields&&(a.params.search_query=S.query,a.params.search_fields=S.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return a(r)}(Z),Yu=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new lh(e,t)}))),i.ts=null!=u?u:null,i}return a(r)}($),Ju=function(t){i(s,t);var r=p(s);function s(t){var a,i=t.userId,o=t.filter;n(this,s),a=r.call(this);var u=o.myMemberStateFilter;return a.method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/group_channel_count"),a.params={state:null!=u?u:e.MyMemberStateFilter.ALL},a}return a(s)}(Z),Xu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).groupChannelCount=a.group_channel_count,i}return a(r)}($),Zu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.filter;n(this,r),a=t.call(this);var o=s.keys;return a.method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params={item_keys:o},a}return a(r)}(Z),$u=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),i=r.call(this,t,a),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=a[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=a[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=a[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=a[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=a[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=a[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=a[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return a(s)}($),ec=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return a(r)}(Z),tc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).unreadCount=a.unread_count,i}return a(r)}($),nc=function(t){i(s,t);var r=p(s);function s(t){var a,i=t.userId,o=t.filter;n(this,s),a=r.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return a.method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/unread_message_count"),a.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},a}return a(s)}(Z),rc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).unreadCount=a.unread_count,i}return a(r)}($),ac=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(Se,"/count"),a.params={channel_url:i,status:sc(s)},o&&(a.params.message_type=o),a}return a(r)}(Z),ic=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).count=a.count,i}return a(r)}($),sc=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Qt.PENDING);break;case e.ScheduledStatus.SENT:n.push(Qt.IN_QUEUE),n.push(Qt.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Qt.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Qt.FAILED)}})),n}},oc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,_=e.accessCode,y=e.name,k=e.data,E=e.customType,b=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=R.POST,a.path=ke,a.params=J({user_ids:[i].concat(g(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:p,is_public:d,is_discoverable:f,strict:v,is_ephemeral:m,access_code:_,name:y,data:k,custom_type:E,operator_ids:C,message_survival_seconds:b}),a}return a(r)}(Z),uc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new lh(e,a),i.isCreated=a.is_created,i}return a(r)}($),cc=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrls;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return a(r)}(Z),lc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).event=new Cu(i),s}return a(r)}(se),hc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return a(r)}(Z),dc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new lh(e,a),i}return a(r)}($),pc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,p=void 0===d?null:d;return s.memberCount=c,s.joinedMemberCount=h,s.members=Array.isArray(p)?p.map((function(t){return new _u(e,t)})):[new _u(e,i.data)],s}return a(r)}(lc),fc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return a(r)}(Z),vc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return s.memberCount=c,s.joinedMemberCount=h,s.member=new _u(s._iid,i.data),s}return a(r)}(lc),mc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userIds;return(a=t.call(this)).method=R.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return a(r)}(Z),gc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new lh(e,a),i}return a(r)}($),_c=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,p=void 0===d?null:d,f=o.invitees,v=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=h,s.inviter=p?new dt(e,p):null,s.invitees=v.map((function(t){return new _u(e,t)})),s}return a(r)}(lc),yc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return a(r)}(Z),kc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,p=void 0===d?null:d,f=o.invitee,v=void 0===f?null:f;return s.memberCount=c,s.joinedMemberCount=h,s.inviter=p?new dt(e,p):null,s.invitee=v?new _u(e,v):null,s}return a(r)}(lc),Ec=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return a(r)}(le),bc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"READ",i)).readStatus=new yu(e,i),s}return a(r)}(se),wc=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.userId;return n(this,r),a=t.call(this),(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=J({userId:s}),a}return a(r)}(Z),Cc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"DLVR",i)).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return a(r)}(se),Rc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:o,allow_auto_unhide:u},a}return a(r)}(Z),xc=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).messageOffsetTimestamp=null;var s=a.ts_message_offset;return i.messageOffsetTimestamp=null!=s?s:null,i}return a(r)}($),Tc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=i.data.allow_auto_unhide,s.hidePreviousMessages=i.data.hide_previous_messages),s.messageOffsetTimestamp=i.ts_message_offset,s}return a(r)}(se),Ic=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.time;return n(this,r),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}})}return a(r)}(le),Sc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new dt(e,i.data),s}return a(r)}(se),Nc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.time;return n(this,r),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}})}return a(r)}(le),Mc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new dt(e,i.data),s}return a(r)}(se),Ac=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new dt(s._iid,e)})),s}return a(r)}(lc),Uc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MCNT",i)).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return a(r)}(se),Oc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.messageId;return n(this,r),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}})}return a(r)}(le),Lc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"ADMM",i)).message=new sn(e,i);var l=It.of(e).sdkState;return s.isMentioned=yn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),Dc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"AEDI",i)).message=new sn(e,i);var p=It.of(e).sdkState;return s.mentionCountChange=kn({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),Pc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MRCT",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new Bt(i),s}return a(r)}(se),Fc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MTHD",i)).event=new Jn(e,i),s}return a(r)}(se),Gc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"PEDI",i)).event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new Tr(e,i),s.status=cn(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return a(r)}(se),qc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"VOTE",i)).event=null,s.channelUrl=null,s.channelType=null,s.event=new Ir(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return a(r)}(se),Hc=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k,E,b,w,C,R,x,T,I;return n(this,o),(i=r.call(this,t,a)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.nicknameContainsFilter=null,i.nicknameStartsWithFilter=null,i.nicknameExactMatchFilter=null,i.channelNameContainsFilter="",i.myMemberStateFilter=e.MyMemberStateFilter.ALL,i.unreadChannelFilter=e.UnreadChannelFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.publicChannelFilter=e.PublicChannelFilter.ALL,i.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,i.searchFilter={fields:[],query:null},i.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.includeEmpty=null!==(s=a.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(u=a.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=a.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=a.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(h=a.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(d=a.customTypeStartsWithFilter)&&void 0!==d?d:"",i.nicknameContainsFilter=null!==(p=a.nicknameContainsFilter)&&void 0!==p?p:null,i.nicknameStartsWithFilter=null!==(f=a.nicknameStartsWithFilter)&&void 0!==f?f:null,i.nicknameExactMatchFilter=null!==(v=a.nicknameExactMatchFilter)&&void 0!==v?v:null,i.channelNameContainsFilter=null!==(m=a.channelNameContainsFilter)&&void 0!==m?m:"",i.myMemberStateFilter=null!==(g=a.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,i.unreadChannelFilter=null!==(_=a.unreadChannelFilter)&&void 0!==_?_:e.UnreadChannelFilter.ALL,i.superChannelFilter=null!==(y=a.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,i.publicChannelFilter=null!==(k=a.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,i.hiddenChannelFilter=null!==(E=a.hiddenChannelFilter)&&void 0!==E?E:e.HiddenChannelFilter.UNHIDDEN,i.searchFilter=null!==(b=a.searchFilter)&&void 0!==b?b:{fields:[],query:null},i.userIdsFilter=null!==(w=a.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null!==(C=a.metadataKey)&&void 0!==C?C:null,i.metadataValues=null!==(R=a.metadataValues)&&void 0!==R?R:null,i.metadataOrderKeyFilter=null!==(x=a.metadataOrderKeyFilter)&&void 0!==x?x:null,i.metadataValueStartsWith=null!==(T=a.metadataValueStartsWith)&&void 0!==T?T:null,i.order=null!==(I=a.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.includeEmpty)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.channelNameContainsFilter)&&O("string",this.channelUrlsFilter,!0)&&O("string",this.customTypesFilter,!0)&&M("string",this.customTypeStartsWithFilter)&&M("string",this.nicknameContainsFilter,!0)&&M("string",this.nicknameStartsWithFilter,!0)&&M("string",this.nicknameExactMatchFilter,!0)&&A(e.MyMemberStateFilter,this.myMemberStateFilter)&&A(e.SuperChannelFilter,this.superChannelFilter)&&A(e.PublicChannelFilter,this.publicChannelFilter)&&A(e.UnreadChannelFilter,this.unreadChannelFilter)&&A(e.HiddenChannelFilter,this.hiddenChannelFilter)&&O(e.GroupChannelSearchField,this.searchFilter.fields)&&M("string",this.searchFilter.query,!0)&&O("string",this.userIdsFilter.userIds)&&M("boolean",this.userIdsFilter.includeMode)&&A(e.QueryType,this.userIdsFilter.queryType)&&A(e.GroupChannelListOrder,this.order)&&M("string",this.metadataOrderKeyFilter,!0)&&M("string",this.metadataKey,!0)&&O("string",this.metadataValues,!0)&&M("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return ut(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=Bc.of(this._iid),e.next=7,t.getMyGroupChannels(this._token,this,this.limit);case 7:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,e.abrupt("return",r);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}($n),Vc=function(){function e(t){var r=t.top,a=void 0===r?Number.MAX_SAFE_INTEGER:r,i=t.bottom,s=void 0===i?0:i;n(this,e),this.top=a,this.bottom=s}return a(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||F.unreadMentionCount>0)&&(F._updateUnreadCount(0,0),this._dispatcher.dispatch(new qu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==F.unreadMessageCount&&0!==F.unreadMentionCount||(this._dispatcher.dispatch(new qu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new qu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onUnreadMemberStatusUpdated(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return n.abrupt("break",338);case 81:return G=t.as(Cc),q=G.channelUrl,H=G.deliveredStateUpdate,V=void 0===H?{}:H,j=this._groupChannelCache.isCachedInMemory(q),n.next=85,this.getChannel(q,!0);case 85:if(Q=n.sent,j)for(B in V)Q._updateUndeliveredMemberState(B,V[B]);return this._dispatcher.dispatch(new qu({channels:[Q],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Object.keys(V).some((function(e){return e!==dn._sdkState.userId}))&&Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onUndeliveredMemberStatusUpdated(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",338);case 90:if(K=t.as(Pc),z=K.channelUrl,W=K.channelType,Y=K.event,W!==e.ChannelType.GROUP){n.next=100;break}return n.next=94,this.getChannel(z,!0);case 94:return J=n.sent,n.next=97,this.getMessageFromCache(Y.messageId);case 97:(X=n.sent)&&(X.applyReactionEvent(Y),this._dispatcher.dispatch(new Un({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onReactionUpdated(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 100:return n.abrupt("break",338);case 101:if(Z=t.as(Fc),($=Z.event).channelType!==e.ChannelType.GROUP){n.next=111;break}return n.next=105,this.getChannel($.channelUrl,!0);case 105:return ee=n.sent,n.next=108,this.getMessageFromCache($.targetMessageId);case 108:(te=n.sent)&&(te.applyThreadInfoUpdateEvent($),this._dispatcher.dispatch(new Un({messages:[te],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onThreadInfoUpdated(ee,$)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 111:return n.abrupt("break",338);case 112:ne=t.as(Uc),re=ne.groupChannelMemberCounts,ae=[],ie=k(re),n.prev=115,ie.s();case 117:if((se=ie.n()).done){n.next=126;break}return oe=se.value,ue=oe.channelUrl,ce=oe.memberCount,le=oe.joinedMemberCount,he=oe.updatedAt,n.next=122,this.getChannelFromCache(ue);case 122:(de=n.sent)&&de._setLatestMemberCount(ce,le,he)&&ae.push(de);case 124:n.next=117;break;case 126:n.next=131;break;case 128:n.prev=128,n.t2=n.catch(115),ie.e(n.t2);case 131:return n.prev=131,ie.f(),n.finish(131);case 134:return ae.length>0&&(this._dispatcher.dispatch(new qu({channels:ae,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelMemberCountChanged(ae)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",338);case 136:if(pe=t.as(Gc),fe=pe.event,ve=pe.status,me=pe.channelUrl,ge=pe.channelType,me&&ge){n.next=139;break}return n.abrupt("break",338);case 139:return n.next=141,this.getChannel(me,!0);case 141:return _e=n.sent,this._dispatcher.dispatch(new Pn({event:fe,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ge("removed"===ve?function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollDeleted(_e,fe.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollUpdated(_e,fe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}),n.abrupt("break",338);case 145:if(ye=t.as(qc),ke=ye.event,Ee=ye.channelUrl,be=ye.channelType,Ee&&be){n.next=148;break}return n.abrupt("break",338);case 148:return n.next=150,this.getChannel(Ee,!0);case 150:return we=n.sent,this._dispatcher.dispatch(new Fn({event:ke,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollVoted(we,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",338);case 154:if(Ce=t.as(lc),!(Re=Ce.event).isGroupChannelEvent){n.next=326;break}n.t3=Re.category,n.next=n.t3===ku.CHANNEL_JOIN?159:n.t3===ku.CHANNEL_LEAVE?168:n.t3===ku.CHANNEL_OPERATOR_UPDATE?184:n.t3===ku.CHANNEL_INVITE?195:n.t3===ku.CHANNEL_DECLINE_INVITE?205:n.t3===ku.TYPING_START||n.t3===ku.TYPING_END?213:n.t3===ku.USER_CHANNEL_MUTE||n.t3===ku.USER_CHANNEL_UNMUTE?222:n.t3===ku.USER_CHANNEL_BAN?249:n.t3===ku.USER_CHANNEL_UNBAN?262:n.t3===ku.CHANNEL_FREEZE||n.t3===ku.CHANNEL_UNFREEZE?268:n.t3===ku.CHANNEL_HIDE?276:n.t3===ku.CHANNEL_UNHIDE?286:n.t3===ku.CHANNEL_DELETED?293:n.t3===ku.CHANNEL_PROP_CHANGED?299:n.t3===ku.CHANNEL_META_DATA_CHANGED?305:n.t3===ku.CHANNEL_META_COUNTERS_CHANGED?314:n.t3===ku.PINNED_MESSAGE_CHANGED?320:326;break;case 159:return n.next=161,this.getChannel(Re.channelUrl,!0);case 161:return xe=n.sent,Te=t.as(pc),Ie=Te.memberCount,Se=Te.joinedMemberCount,Ne=Te.members,Me=!1,Ne.forEach((function(t){xe.isExclusive||xe.isSuper||xe.isBroadcast?Me=Me||xe._setLatestMemberCount(Ie,Se,Re.ts):(t.state=e.MemberState.JOINED,xe.addMember(t,Re.ts),dn._updateJoinedMemberCount(xe)),t.userId===dn._sdkState.userId&&(xe.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new qu({channels:[xe],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=k(Ne);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(xe,r)}}catch(e){n.e(e)}finally{n.f()}xe.isBroadcast&&Me&&e.onChannelMemberCountChanged([xe])}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 168:if(!(Ae=this._leftChannels.get(Re.channelUrl))){n.next=173;break}n.t4=Ae.channel,n.next=176;break;case 173:return n.next=175,this.getChannel(Re.channelUrl,!0);case 175:n.t4=n.sent;case 176:return Ue=n.t4,Oe=t.as(vc),Le=Oe.memberCount,De=Oe.joinedMemberCount,Pe=Oe.member,Fe=!1,He=It.of(this._iid),Ve=He.appInfo,Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Ue._setLatestMemberCount(Le,De,Re.ts):(Ve.enabledChannelMemberShipHistory?(Ue.members.find((function(e){return e.userId===Pe.userId})).state=e.MemberState.LEFT,Ue.memberCount=Le):Ue.removeMember(Pe),this._updateJoinedMemberCount(Ue)),Pe.userId===this._sdkState.userId?(Ue.myMemberState=e.MemberState.NONE,Ue.invitedAt=0,Ue.joinedAt=0,Ue._updateUnreadCount(0,0),Ue.isPublic?this._dispatcher.dispatch(new qu({channels:[Ue],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Ue),this._dispatcher.dispatch(new Hu({channelUrls:[Ue.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new qu({channels:[Ue],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Ue,Pe),Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 184:return n.next=186,this.getChannel(Re.channelUrl,!0);case 186:je=n.sent,Qe=t.as(Ac),Be=Qe.operators,Ke=Be.map((function(e){return e.userId})),ze=k(je.members);try{for(ze.s();!(We=ze.n()).done;)(Ye=We.value).role=Ke.includes(Ye.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){ze.e(e)}finally{ze.f()}return je.myRole=Ke.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new qu({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Be)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 195:return n.next=197,this.getChannel(Re.channelUrl,!0);case 197:Je=n.sent,Xe=t.as(_c),Ze=Xe.memberCount,$e=Xe.joinedMemberCount,et=Xe.inviter,(tt=Xe.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),nt=k(tt);try{for(nt.s();!(rt=nt.n()).done;)at=rt.value,Je.isExclusive||Je.isSuper||Je.isBroadcast?Je._setLatestMemberCount(Ze,$e,Re.ts):Je.addMember(at,Re.ts),this._sdkState.userId===at.userId&&(Je.hiddenState=e.HiddenState.UNHIDDEN,Je.myMemberState!==e.MemberState.JOINED&&(Je.myMemberState=e.MemberState.INVITED),Je.invitedAt=Re.ts)}catch(e){nt.e(e)}finally{nt.f()}return this._dispatcher.dispatch(new qu({channels:[Je],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Je,et,tt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 205:return n.next=207,this.getChannel(Re.channelUrl,!0);case 207:return it=n.sent,st=t.as(kc),ot=st.memberCount,ut=st.joinedMemberCount,ct=st.inviter,lt=st.invitee,it.isExclusive||it.isSuper||it.isBroadcast?it._setLatestMemberCount(ot,ut,Re.ts):it.removeMember(lt),this._sdkState.userId===lt.userId?(it.invitedAt=0,it.myMemberState=e.MemberState.NONE,it.isPublic?this._dispatcher.dispatch(new qu({channels:[it],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Hu({channelUrls:[it.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new qu({channels:[it],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(it,ct,lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 213:return n.next=215,this.getChannel(Re.channelUrl,!0);case 215:return ht=n.sent,dt=Re.category===ku.TYPING_START,pt=t.as(dt?Sc:Mc),ft=pt.user,ht._updateTypingStatus(ft,dt?Re.ts:0),this._dispatcher.dispatch(new qu({channels:[ht],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 222:return n.next=224,this.getChannel(Re.channelUrl,!0);case 224:vt=n.sent,mt=Re.category===ku.USER_CHANNEL_MUTE,gt=t.as(mt?No:Ao),(_t=gt.user).userId===this._sdkState.userId&&(vt.myMutedState=mt?e.MutedState.MUTED:e.MutedState.UNMUTED),yt=k(vt.members),n.prev=229,yt.s();case 231:if((kt=yt.n()).done){n.next=238;break}if((Et=kt.value).userId!==_t.userId){n.next=236;break}return Et.isMuted=mt,n.abrupt("break",238);case 236:n.next=231;break;case 238:n.next=243;break;case 240:n.prev=240,n.t5=n.catch(229),yt.e(n.t5);case 243:return n.prev=243,yt.f(),n.finish(243);case 246:return this._dispatcher.dispatch(new qu({channels:[vt],source:mt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted(vt,_t):e.onUserUnmuted(vt,_t)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 249:if(!(bt=this._leftChannels.get(Re.channelUrl))){n.next=254;break}n.t6=bt.channel,n.next=257;break;case 254:return n.next=256,this.getChannel(Re.channelUrl,!0);case 256:n.t6=n.sent;case 257:return wt=n.t6,this._markAsLeave(wt),Ct=t.as(Oo),Rt=Ct.user,Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(wt,Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 262:return n.next=264,this.getChannel(Re.channelUrl,!0);case 264:return xt=n.sent,Tt=t.as(Do),St=Tt.user,Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 268:return n.next=270,this.getChannel(Re.channelUrl,!0);case 270:return Nt=n.sent,Mt=t.as(Fo),At=Mt.freeze,Nt.isFrozen=At,this._dispatcher.dispatch(new qu({channels:[Nt],source:At?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){At?e.onChannelFrozen(Nt):e.onChannelUnfrozen(Nt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 276:return n.next=278,this.getChannel(Re.channelUrl,!0);case 278:return Ut=n.sent,Ot=t.as(Tc),Lt=Ot.allowAutoUnhide,Dt=Ot.hidePreviousMessages,Pt=Ot.messageOffsetTimestamp,null!==Lt&&(Ut.hiddenState=Lt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Dt&&Dt&&Ut._updateUnreadCount(0,0),null!==Pt&&(Ut.messageOffsetTimestamp=Pt),this._dispatcher.dispatch(new qu({channels:[Ut],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Ut)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 286:return n.next=288,this.getChannel(Re.channelUrl,!0);case 288:return(Ft=n.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new qu({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 293:return n.next=295,this.getChannel(Re.channelUrl,!0);case 295:return Gt=n.sent,this._dispatcher.dispatch(new Hu({channelUrls:[Re.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Gt.url,Gt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 299:return n.next=301,this.getChannelWithoutCache(Re.channelUrl,!0);case 301:return qt=n.sent,this._dispatcher.dispatch(new qu({channels:[qt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 305:return n.next=307,this.getChannel(Re.channelUrl,!0);case 307:return Ht=n.sent,Vt=t.as(vo),jt=Vt.created,Qt=Vt.updated,Bt=Vt.deleted,jt&&Ht._upsertCachedMetaData(jt,Re.ts),Qt&&Ht._upsertCachedMetaData(Qt,Re.ts),Bt&&Ht._removeFromCachedMetaData(Bt,Re.ts),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){jt&&e.onMetaDataCreated(Ht,jt),Qt&&e.onMetaDataUpdated(Ht,Qt),Bt&&e.onMetaDataDeleted(Ht,Bt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 314:return n.next=316,this.getChannel(Re.channelUrl,!0);case 316:return Kt=n.sent,zt=t.as(xo),Wt=zt.created,Yt=zt.updated,Jt=zt.deleted,Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Wt&&e.onMetaCounterCreated(Kt,Wt),Yt&&e.onMetaCounterUpdated(Kt,Yt),Jt&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",326);case 320:return n.next=322,this.getChannel(Re.channelUrl,!0);case 322:return Xt=n.sent,Zt=t.as(jc),$t=Zt.pinnedMessageIds,en=Zt.latestPinnedMessage,(nn=Zt.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=$t,Xt.lastPinnedMessage=en,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new qu({channels:[Xt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(Xt)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Ge((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",326);case 326:return n.abrupt("break",338);case 327:rn=t.as(Ca),an=rn.event,n.t7=an.category,n.next=n.t7===ta.USER_BLOCK?331:n.t7===ta.USER_UNBLOCK?334:337;break;case 331:return sn=ba.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),n.abrupt("break",337);case 334:return cn=ba.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,hn=cn.blockee,this._groupChannelCache.unblock(ln.userId,hn.userId),n.abrupt("break",337);case 337:return n.abrupt("break",338);case 338:n.next=344;break;case 340:if(n.prev=340,n.t8=n.catch(0),!x(n.t8)){n.next=344;break}throw n.t8;case 344:case"end":return n.stop()}}),n,this,[[0,340],[19,30,33,36],[115,128,131,134],[229,240,243,246]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return lt(M("string",t)).throw(T.invalidParameters),a=new Ku({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(zu),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",o);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Wu(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Yu),u=o.channels,c=o.token,this._dispatcher.dispatch(new qu({channels:u,source:a})),e.abrupt("return",{channels:u,token:c});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Vr;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n});case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Vr;return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Vc({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},Tu),n),lt((M("string",t)||M("number",t))&&Iu(a)).throw(T.invalidParameters),i=new Qu(J({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(Bu),u=o.updatedChannels,c=o.deletedChannelUrls,u.length>0&&this._dispatcher.dispatch(new qu({channels:u,source:r})),c.length>0&&this._dispatcher.dispatch(new Hu({channelUrls:c,source:r})),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Su),e),lt(Nu(n)).throw(T.invalidParameters),r=new Ju({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Xu),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Au),e),lt(Uu(n)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Zu({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,t.abrupt("return",o.as($u));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ec({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(tc),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ou),e),lt(Lu(n)).throw(T.invalidParameters),r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new nc({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(rc),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Du),e),lt(Pu(n)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new ac(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(ic),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=It.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=It.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=It.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),lt(xu(n)).throw(T.invalidParameters),n.isPublic||(n.accessCode=null),r=new oc(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(uc),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),lt(t-this._markAsReadAllLastSentAt>=1e3).throw(T.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new cc({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=k(r);try{for(a.s();!(i=a.n()).done;)(s=i.value)._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),lt(O("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(T.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new cc({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],s=k(a);try{for(s.s();!(o=s.n()).done;)u=o.value,e.includes(u.url)&&(u._updateUnreadMemberState(this._sdkState.userId,n),u._updateUnreadCount(0,0),i.push(u))}catch(e){s.e(e)}finally{s.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Qc[e]}}]),t}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Fu||(Fu={}));var Kc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this))._worker=null,i._state=Fu.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return a(r,[{key:"isIdle",get:function(){return this._state===Fu.IDLE}},{key:"isRunning",get:function(){return this._state===Fu.RUNNING}},{key:"isDone",get:function(){return this._state===Fu.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount=this._limit,s.nextToken=this._metadata.range.top,this._metadata.previousComplete=!s.hasNext,f.debug("message background prev sync progress",s),n.next=17,this.saveMetadata();case 17:n.next=26;break;case 19:if(n.prev=19,n.t0=n.catch(5),f.debug("message background prev sync error",n.t0),!(n.t0 instanceof T&&n.t0.isInvalidTokenError)){n.next=25;break}return n.next=25,this.clearMetadata();case 25:throw n.t0;case 26:n.next=29;break;case 28:s.hasNext=!1;case 29:return n.abrupt("return",s);case 30:case"end":return n.stop()}}),n,this,[[5,19]])})))})),this._nextSync=new Kc(v,(function(t){return E(a,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={hasNext:!0,nextToken:0},n.next=3,this.loadMetadata();case 3:return f.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),n.prev=4,o=Wn.of(this._iid),n.next=8,o.getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(a=this._metadata.range)||void 0===a?void 0:a.bottom)&&void 0!==i?i:t,{prevResultSize:0,nextResultSize:this._limit,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},e.MessageEventSource.SYNC_MESSAGE_BACKGROUND);case 8:return u=n.sent,this.extendRange(u),s.hasNext=u.length>=this._limit,s.nextToken=this._metadata.range.bottom,f.debug("message background next sync progress",s),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),f.debug("message background next sync error",n.t0),n.t0;case 21:return n.abrupt("return",s);case 22:case"end":return n.stop()}}),n,this,[[4,17]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,g(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,g(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={range:new Vc(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!r&&r.previousComplete};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n,r;It.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())}},{key:"pause",value:function(){It.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Yc[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Yc[e]||(Yc[e]={}),Yc[e][n.url]||(Yc[e][n.url]=new t({_iid:e,channel:n})),Yc[e][n.url].ref++,Yc[e][n.url]}},{key:"clear",value:function(e,t){Yc[e]&&Yc[e][t]&&(Yc[e][t].close(),delete Yc[e])}}]),t}(),Xc={},Zc=function(){function t(r){var a=this,i=r._iid,s=r.channel;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=s;var o,u,c=It.of(this._iid),l=c.logger,h=c.sdkState,d=c.dispatcher;this._metadataKey=(o=h.userId,u=s.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new Kc(p,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return l.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=Wn.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&(this._metadata.token=c),l.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),l.debug("message changelog sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=It.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){It.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){It.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Xc[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Xc[e]||(Xc[e]={}),Xc[e][n.url]||(Xc[e][n.url]=new t({_iid:e,channel:n})),Xc[e][n.url].ref++,Xc[e][n.url]}},{key:"clear",value:function(e,t){Xc[e]&&Xc[e][t]&&(Xc[e][t].close(),delete Xc[e])}}]),t}(),$c=function(e){i(r,e);var t=p(r);function r(e){var a,i,s,o,u,c,l;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(gn(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=J({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(i=e.threshold)&&void 0!==i?i:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0}),a}return a(r)}(Z),el=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c;return n(this,r),(i=t.call(this,e,a)).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return vn(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.nextMessages=(null!==(u=a.next_messages)&&void 0!==u?u:[]).map((function(t){return vn(e,t)})),i.nextHasmore=null!==(c=a.next_hasmore)&&void 0!==c&&c,i}return a(r)}($),tl=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},nl=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},rl=function(e,t,n){if(e.length>0){var r=nl(e,t);if(r<0){for(var a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,contains:e[s].isIdentical(t)};a=s+1,s=Math.floor((a+i)/2)}}return{place:al(e[s],t,n)>0?s:s+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},al=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name.localeCompare(n.name)}},il=function(e,t){return t instanceof tn?e.findIndex((function(e){return e instanceof tn&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},sl=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},ol=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},ul={},cl=function(){function e(t){var r=this,a=t._iid,i=t.channel,s=t.hasPollMessage;n(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=a,this._channel=i;var o,u,c=It.of(this._iid),l=c.logger,h=c.sdkState,d=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new Kc(p,(function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=It.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=xr.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof T&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)r.resume();else r.pause()}))}return a(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){It.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){It.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ul[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return ul[t]||(ul[t]={}),ul[t][n.url]||(ul[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),ul[t][n.url].ref++,ul[t][n.url]}}]),e}(),ll=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var hl,dl,pl,fl=function(){function e(){n(this,e)}return a(e,[{key:"_invokeResponse",value:function(e,t,n){var r=this;Ge((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),vl=function(){function t(r,a){var i=this,s=a.channel,o=a.filter,u=a.startingPoint,c=a.limit;n(this,t),this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._iid=r,this._key="mc-".concat(B()),this.filter=null!=o?o:new Kr,this._channel=s,this._syncRange=new Vc({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=u||Date.now()+ll,this._limit=c||Vr;var l=Bc.of(this._iid);l.subscribeGroupChannelEvent(this._key,{onUpdate:function(t,n){var r=nl(t,i._channel);if(r>=0)switch(Ge((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new zc(n),this._channel=t[r],(null===(a=this._handler)||void 0===a?void 0:a.onChannelUpdated)&&this._handler.onChannelUpdated(i,this.channel);case 3:case"end":return e.stop()}}),e,this)})))})),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var a=!1;for(var s in i._messages){if(i._messages[s].createdAt>=i._channel.messageOffsetTimestamp){a=!0;var o=parseInt(s);if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_READ:var c,l=[],h=k(i._messages);try{for(h.s();!(c=h.n()).done;){var d=c.value,p=i._readReceiptMap.get(d.messageId);if(p>0)p!==i._channel.getUnreadMemberCount(d)&&l.push(d)}}catch(e){h.e(e)}finally{h.f()}l.length>0&&i._updateMessagesToView(l,e.MessageEventSource.EVENT_MESSAGE_READ);break;case e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED:var f,v=[],m=k(i._messages);try{for(m.s();!(f=m.n()).done;){var g=f.value,_=i._deliveryReceiptMap.get(g.messageId);if(_>0)_!==i._channel.getUndeliveredMemberCount(g)&&v.push(g)}}catch(e){m.e(e)}finally{m.f()}v.length>0&&i._updateMessagesToView(v,e.MessageEventSource.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(i.channel.url)>=0&&Ge((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new zc(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(r,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))}))}}),l.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=k(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(An(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var h=It.of(this._iid).cacheContext;!this._channel.isSuper&&h.localCacheEnabled&&(this._backgroundSync=Jc.of(this._iid,this._channel),this._backgroundSync.resume()),this._changelogSync=Zc.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=cl.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Kc(this._key,(function(t){return E(i,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL});case 2:if(!((r=n.sent).length>0)){n.next=7;break}return a=Math.min.apply(Math,g(r.map((function(e){return e.createdAt})))),this._syncRange.extends(a),n.abrupt("return",{hasNext:r.length>=this._limit&&this.viewTop0)){n.next=7;break}return a=Math.max.apply(Math,g(r.map((function(e){return e.createdAt})))),this._syncRange.extends(a),n.abrupt("return",{hasNext:!(r.length>=this._limit&&this._hasNext)||this.viewBottom>a,nextToken:this._syncRange.bottom});case 7:return n.abrupt("return",{hasNext:!1,nextToken:0});case 8:case"end":return n.stop()}}),n,this)})))}));var d=It.of(this._iid),p=d.dispatcher,f=d.logger;this._connectionEventContext=p.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)f.debug("check huge gap"),i._checkHugeGap();else i._prevFill.stop(),i._nextFill.stop()}))}return a(t,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return g(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,g(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,g(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),s=[],o=[],u=k(i);try{for(u.s();!(r=u.n()).done;){var c=r.value;if(n===e.MessageEventSource.SYNC_MESSAGE_FILL){if(c.messageId>0){if(il(this._messages,c)<0){il(this._unsentMessages,c)<0&&s.push(c);var l=ol(this._messages,c);this._messages.splice(l,0,c)}this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c))}else if(c instanceof tn){il(this._unsentMessages,c)<0&&il(this._messages,c)<0&&(this._unsentMessages.push(c),s.push(c))}}else if(c.messageId>0){var h=il(this._messages,c);if(h<0){var d=il(this._unsentMessages,c);d<0?s.push(c):(this._unsentMessages.splice(d,1),o.push(c));var p=ol(this._messages,c);this._messages.splice(p,0,c)}else o.push(c),this._messages[h]=c;if(this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c)),c.updatedAt>0){var f=this._updateChildMessagesInView(c);o.push.apply(o,g(f))}}else if(c instanceof tn){var v=il(this._unsentMessages,c);v<0?il(this._messages,c)<0&&(this._unsentMessages.push(c),s.push(c)):(o.push(c),this._unsentMessages[v]=c)}}}catch(e){u.e(e)}finally{u.f()}An(n)&&Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=new Wc(n),s.length>0&&this._handler.onMessagesAdded(t,this.channel,s),o.length>0&&this._handler.onMessagesUpdated(t,this.channel,o);case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=k(e);try{for(i.s();!(n=i.n()).done;){var s=n.value,o=sl(this._messages,s.messageId);if(o>=0){var u=this._messages[o];u&&u.applyPoll(s),a.push(u)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&An(t)&&Ge((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Wc(t),a.length>0&&this._handler.onMessagesUpdated(n,this.channel,a);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=sl(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&An(t)&&Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Wc(t),this._handler.onMessagesUpdated(n,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=sl(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&An(t)&&Ge((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Wc(t),this._handler.onMessagesUpdated(n,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=k(e);try{for(i.s();!(n=i.n()).done;){var s=n.value;if(s.messageId>0){var o=il(this._messages,s);if(o>=0)a.push(s),this._messages[o]=s;else{var u=il(this._unsentMessages,s);if(u>=0){a.push(s),this._unsentMessages.splice(u,1);var c=ol(this._messages,s);this._messages.splice(c,0,s)}}}else if(s instanceof tn){var l=il(this._unsentMessages,s);l>=0&&(a.push(s),this._unsentMessages[l]=s)}}}catch(e){i.e(e)}finally{i.f()}return An(t)&&Ge((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Wc(t),a.length>0&&this._handler.onMessagesUpdated(n,this.channel,a);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=k(e);try{var s=function(){var e=n.value,t=r._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(a.push(r._messages[t].messageId),r._messages.splice(t,1))};for(i.s();!(n=i.n()).done;)s()}catch(e){i.e(e)}finally{i.f()}return An(t)&&a.length>0&&Ge((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new Wc(t),a.length>0&&this._handler.onMessagesDeleted(n,this.channel,a);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,a,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Bc.of(this._iid),!(r>0)){t.next=7;break}return t.next=4,n.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r);case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:if(a=t.t0,!(i>0)){t.next=15;break}return t.next=12,n.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:t.t1=t.sent,t.next=16;break;case 15:t.t1=[];case 16:if(s=t.t1,!(a.length>0&&s.length>0)){t.next=27;break}o=a.map((function(e){return e.messageId})),t.t2=regeneratorRuntime.keys(s);case 20:if((t.t3=t.t2()).done){t.next=27;break}if(u=t.t3.value,!o.includes(s[u].messageId)){t.next=25;break}return s.splice(parseInt(u),1),t.abrupt("break",27);case 25:t.next=20;break;case 27:return t.abrupt("return",[].concat(g(a),g(s)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.MessageEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Wn.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n.getMessagesByTimestamp(this._channel.url,this._channel.channelType,t,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=[];case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this._messages.length>0)){t.next=16;break}return n=this.viewTop,r=this._syncRange.top,a=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s=Bc.of(this._iid),t.next=8,s.getCachedMessageCountBetween(this._channel.url,this.filter,n,r);case 8:return o=t.sent,t.next=11,s.getCachedMessageCountBetween(this._channel.url,this.filter,a,i);case 11:return u=t.sent,t.next=14,Fe((function(){return E(d,void 0,void 0,regeneratorRuntime.mark((function t(){var s,c,l,h,d,p,f,v,m,_,y,k,b,w,C,R,x,T=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=It.of(this._iid),c=s.dispatcher,l=s.requestQueue,h=new $c(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:r,prevCount:o,nextStart:a,nextEnd:i,nextCount:u},this.filter)),t.next=4,l.send(h);case 4:d=t.sent,p=d.as(el),f=p.isHugeGap,v=p.prevMessages,m=void 0===v?[]:v,_=p.prevHasMore,y=p.nextMessages,k=void 0===y?[]:y,b=p.nextHasmore,f?Ge((function(){return E(T,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._handler.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=_,this._hasNext=b,w=this.viewTop,C=this.viewBottom,R=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,w].concat(g(m.map((function(e){return e.createdAt}))))),x=Math.max.apply(Math,[0,C].concat(g(k.map((function(e){return e.createdAt}))))),c.dispatch(new Un({messages:m,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),c.dispatch(new Un({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(R,x),wx&&this._nextFill.start(x));case 7:case"end":return t.stop()}}),t,this)})))}),1);case 14:t.next=21;break;case 16:return c=Math.floor(this._limit/2),t.next=19,this._getRemoteMessages(Date.now(),{prevLimit:c,nextLimit:c,source:e.MessageEventSource.SYNC_MESSAGE_FILL});case 19:(l=t.sent).length>0&&((h=this._syncRange).extends.apply(h,g(l.map((function(e){return e.createdAt})))),l.length0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"initialize",value:function(t){var n=this,r=new fl;this._messages=[],this._unsentMessages=[],this._syncRange=new Vc({}),this._hasNext=!0,this._hasPrevious=!0;var a=Math.floor(this._limit/2);if(t===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:a,nextLimit:a}).then((function(t){return E(n,void 0,void 0,regeneratorRuntime.mark((function n(){var a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=this._filterUnderOffsetMessage(t),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=4,this._loadUnsentMessages();case 4:r._invokeResponse("local",null,a);case 5:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(x(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){n._getRemoteMessages(n._startingPoint,{prevLimit:a,nextLimit:a,reverse:!0}).then((function(t){n._messages=[];var i,s=n._filterUnderOffsetMessage(t);(s.length0)&&((i=n._syncRange).extends.apply(i,g(s.map((function(e){return e.createdAt})))),n._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));r._invokeResponse("remote",null,s)})).catch((function(e){if(x(e))throw e;r._invokeResponse("remote",e,null)}))}));return r}},{key:"loadPrevious",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._hasPrevious){t.next=14;break}return n=this.viewTop,r=[],t.next=5,qe((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(n,{prevLimit:this._limit});case 3:e.t1=e.sent,r=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==r.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(r)){t.next=11;break}return t.next=8,qe((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var t,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getRemoteMessages(n,{prevLimit:this._limit});case 3:e.t1=e.sent,r=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1),this._hasPrevious=r.length>=this._limit,r.length>0&&((i=this._syncRange).extends.apply(i,g(r.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(r,e.MessageEventSource.REQUEST_MESSAGE),t.next=13;break;case 11:this._hasPrevious=r.length>=this._limit,r.length>0&&((a=this._syncRange).extends.apply(a,g(r.map((function(e){return e.createdAt})))),this._addMessagesToView(r,e.MessageEventSource.REQUEST_MESSAGE));case 13:return t.abrupt("return",r);case 14:return t.abrupt("return",[]);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"loadNext",value:function(){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this.viewBottom,a=[],n.next=4,qe((function(){return E(s,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{nextLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 4:if(0!==a.length&&(null===(t=this._backgroundSync)||void 0===t?void 0:t.isWrappingMessages(a))){n.next=10;break}return n.next=7,qe((function(){return E(s,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getRemoteMessages(r,{nextLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1),this._hasNext=a.length>=this._limit,a.length>0&&((i=this._syncRange).extends.apply(i,g(a.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 7:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=12;break;case 10:this._hasNext=a.length>=this._limit,a.length>0&&((i=this._syncRange).extends.apply(i,g(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 12:return n.abrupt("return",a);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Bc.of(this._iid),t.next=3,n.removeFailedMessageFromCache(e);case 3:(r=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(r,1);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"dispose",value:function(){var e,t,n;It.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var r=Bc.of(this._iid);r.unsubscribeGroupChannelEvent(this._key),r.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),t}(),ml={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},gl=function(e){return M("string",e.coverUrl,!0)&&(D(e.coverImage)||M("string",e.coverImage)||null===e.coverImage)&&M("boolean",e.isDistinct,!0)&&M("boolean",e.isPublic,!0)&&M("boolean",e.isDiscoverable,!0)&&M("string",e.accessCode,!0)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&O("string",e.operatorUserIds,!0)&&M("number",e.messageSurvivalSeconds,!0)},_l={hidePreviousMessages:!1,allowAutoUnhide:!0},yl=function(e){return M("boolean",e.hidePreviousMessages)&&M("boolean",e.allowAutoUnhide)},kl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=R.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return a(r)}(Z),El=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new _u(e,t)}))),i}return a(r)}($);e.MutedMemberFilter=void 0,(hl=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",hl.MUTED="muted",hl.UNMUTED="unmuted",e.MemberListOrder=void 0,(dl=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",dl.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(pl=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",pl.JOINED="joined_only",pl.INVITED="invited_only",pl.INVITED_BY_FRIEND="invited_by_friend",pl.INVITED_BY_NON_FRIEND="invited_by_non_friend";var bl,wl,Cl,Rl=function(t){i(o,t);var r=p(o);function o(t,a,i){var s,u,c,l,h;return n(this,o),(s=r.call(this,t,a,e.ChannelType.GROUP,i)).mutedMemberFilter=e.MutedMemberFilter.ALL,s.memberStateFilter=e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null,s.operatorFilter=e.OperatorFilter.ALL,s.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s.mutedMemberFilter=null!==(u=i.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,s.memberStateFilter=null!==(c=i.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null!==(l=i.nicknameStartsWithFilter)&&void 0!==l?l:null,s.order=null!==(h=i.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&A(e.MutedMemberFilter,this.mutedMemberFilter)&&A(e.MemberStateFilter,this.memberStateFilter)&&(M("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&A(e.OperatorFilter,this.operatorFilter)&&A(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new kl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(El),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(sr),xl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return a(r)}(Z),Tl=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),(i=r.call(this,t,a)).channel=new lh(t,a),i.channel.myMemberState=e.MemberState.JOINED,i}return a(s)}($),Il=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,p=e.data,f=e.customType,v=e.operatorUserIds,m=e.messageSurvivalSeconds;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=J({is_distinct:s,is_public:o,is_discoverable:u,name:d,data:p,custom_type:f,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:m}),a}return a(r)}(Z),Sl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new lh(e,a),i}return a(r)}($),Nl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=R.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),Ml=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=R.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/hide"),a}return a(r)}(Z),Al=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return a(r)}(Z),Ul=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).countPreference=a.count_preference,i}return a(r)}($),Ol=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=R.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/reset_user_history"),a}return a(r)}(Z),Ll=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).messageOffsetTimestamp=null;var s=a.ts_message_offset;return i.messageOffsetTimestamp=null!=s?s:null,i}return a(r)}($),Dl=Object.assign(Object.assign({},Vs),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Pl=function(e){return js(e)&&M("number",e.scheduledAt,!0)&&(D(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fl=Object.assign(Object.assign({},Qs),{scheduledAt:null}),Gl=function(e){return Bs(e)&&M("number",e.scheduledAt,!0)},ql=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return a.method=R.PUT,a.path="".concat(gn(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),a.params=J({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Mt.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return nn.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return zt.payloadify(e)})),apple_critical_alert_options:Jt.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),a}return a(s)}(Z),Hl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new mn(e,a),i}return a(r)}($),Vl=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return a.method=R.PUT,a.path="".concat(gn(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),a.params=J({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Mt.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return zt.payloadify(e)})),apple_critical_alert_options:Jt.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),a}return a(s)}(Z),jl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=R.DELETE,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Ql=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=R.POST,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return a(r)}(Z),Bl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return a(r)}(Z),Kl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return a(r)}($),zl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Wl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return a(r)}($),Yl=function(e){return M("string",e.title,!0)&&ln(e.data)&&M("boolean",e.allowUserSuggestion,!0)&&M("boolean",e.allowMultipleVotes,!0)&&M("number",e.closeAt,!0)},Jl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(Ie,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return a(r)}(Z),Xl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),Zl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(Ie,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),$l=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/close"),a}return a(r)}(Z),eh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),th=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(Ie,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return a(r)}(Z),nh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),rh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return n(this,r),(a=t.call(this)).method=R.PUT,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return a(r)}(Z),ah=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new dn(e,a),i}return a(r)}($),ih=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.pollOptionId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return a(r)}(Z),sh=function(t){i(s,t);var r=p(s);function s(t){var a=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return n(this,s),r.call(this,{code:"VOTE",ackRequired:!0,payload:J({req_id:a,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return a(s)}(le),oh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return n(this,r),(a=t.call(this)).method=R.POST,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return a(r)}(Z),uh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return n(this,r),(a=t.call(this)).method=R.DELETE,a.path="".concat(gn(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return a(r)}(Z);e.CountPreference=void 0,(bl=e.CountPreference||(e.CountPreference={})).ALL="all",bl.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",bl.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",bl.OFF="off",e.MutedState=void 0,(wl=e.MutedState||(e.MutedState={})).MUTED="muted",wl.UNMUTED="unmuted",e.HiddenState=void 0,(Cl=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Cl.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Cl.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var ch,lh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,_,y,k,E,b,w,C,R,x;(n(this,o),(i=r.call(this,t,a))._unreadMemberStateMap=new Map,i._undeliveredMemberStateMap=new Map,i._typingStatus=new Map,i._lastMemberCountUpdated=0,i._typingStarted=0,i._typingEnded=0,i.isDistinct=!1,i.isSuper=!1,i.isBroadcast=!1,i.isExclusive=!1,i.isPublic=!1,i.isDiscoverable=!0,i.isAccessCodeRequired=!1,i.isPushEnabled=!1,i.unreadMessageCount=0,i.unreadMentionCount=0,i.members=[],i.memberCount=0,i.joinedMemberCount=0,i.hiddenState=e.HiddenState.UNHIDDEN,i.lastMessage=null,i.messageOffsetTimestamp=0,i.messageSurvivalSeconds=-1,i.myMemberState=e.MemberState.NONE,i.myRole=e.Role.NONE,i.myMutedState=e.MutedState.UNMUTED,i.myLastRead=0,i.myCountPreference=e.CountPreference.ALL,i.myPushTriggerOption=e.PushTriggerOption.DEFAULT,i.inviter=null,i.invitedAt=0,i.joinedAt=0,i.pinnedMessageIds=[],i.lastPinnedMessage=null,i._pinnedMessagesUpdatedAt=0,i.channelType=e.ChannelType.GROUP,i.isDistinct=null!==(s=a.is_distinct)&&void 0!==s&&s,i.isSuper=null!==(u=a.is_super)&&void 0!==u&&u,i.isBroadcast=null!==(c=a.is_broadcast)&&void 0!==c&&c,i.isExclusive=null!==(l=a.is_exclusive)&&void 0!==l&&l,i.isPublic=null!==(h=a.is_public)&&void 0!==h&&h,i.isDiscoverable=null!==(d=a.is_discoverable)&&void 0!==d?d:i.isPublic,i.isAccessCodeRequired=null!==(p=a.is_access_code_required)&&void 0!==p&&p,i.isPushEnabled=null!==(f=a.is_push_enabled)&&void 0!==f&&f,Array.isArray(a.members))&&(x=i.members).push.apply(x,g(a.members.map((function(e){return new _u(i._iid,e)}))));return i.memberCount=null!==(v=a.member_count)&&void 0!==v?v:0,i.joinedMemberCount=null!==(m=a.joined_member_count)&&void 0!==m?m:0,i.hiddenState=A(e.HiddenState,a.hidden_state)?a.hidden_state:e.HiddenState.UNHIDDEN,i.messageOffsetTimestamp=null!==(_=a.ts_message_offset)&&void 0!==_?_:0,i.messageSurvivalSeconds=null!==(y=a.message_survival_seconds)&&void 0!==y?y:-1,i.lastMessage=a.last_message?vn(i._iid,Object.assign({channel_type:i.channelType},a.last_message)):null,a.read_receipt&&Object.keys(a.read_receipt).forEach((function(e){M("number",a.read_receipt[e])&&i._updateUnreadMemberState(e,a.read_receipt[e])})),a.delivery_receipt&&Object.keys(a.delivery_receipt).forEach((function(e){M("number",a.delivery_receipt[e])&&i._updateUndeliveredMemberState(e,a.delivery_receipt[e])})),i.myMemberState=A(e.MemberState,a.member_state)?a.member_state:e.MemberState.NONE,i.myRole=A(e.Role,a.my_role)?a.my_role:e.Role.NONE,A(e.MutedState,a.is_muted)?i.myMutedState=a.is_muted:M("boolean",a.is_muted)?i.myMutedState=a.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:i.myMutedState=e.MutedState.UNMUTED,i.myCountPreference=A(e.CountPreference,a.count_preference)?a.count_preference:e.CountPreference.ALL,i.myPushTriggerOption=A(e.PushTriggerOption,a.push_trigger_option)?a.push_trigger_option:e.PushTriggerOption.ALL,i.myLastRead=null!==(k=a.user_last_read)&&void 0!==k?k:0,i.inviter=a.inviter?new dt(i._iid,a.inviter):null,i.invitedAt=null!==(E=a.invited_at)&&void 0!==E?E:0,i.joinedAt=null!==(b=a.joined_ts)&&void 0!==b?b:0,i._updateUnreadCount(null!==(w=a.unread_message_count)&&void 0!==w?w:0,null!==(C=a.unread_mention_count)&&void 0!==C?C:0),i.pinnedMessageIds=null!==(R=a.pinned_message_ids)&&void 0!==R?R:[],i.lastPinnedMessage=a.latest_pinned_message?vn(i._iid,Object.assign({channel_type:i.channelType},a.latest_pinned_message)):null,i}return a(o,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=k(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=m(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=k(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=m(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof tn&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=It.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=It.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ut(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vl(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rl(this._iid,this.url,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof _u?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof tn&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=It.of(this._iid).sdkState,a=t.createdAt,i=0,s=k(this.members);try{for(s.s();!(n=s.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=It.of(this._iid),a=r.sdkState;if(!a.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=e instanceof tn?e.sender:null,s=[];return this.members.forEach((function(r){(n||r.userId!==a.userId&&r.userId!==(null==i?void 0:i.userId))&&(t._unreadMemberStateMap.get(r.userId)>=e.createdAt&&s.push(r))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=It.of(this._iid),a=r.sdkState;if(!a.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=e instanceof tn?e.sender:null,s=[];return this.members.forEach((function(r){(n||r.userId!==a.userId&&r.userId!==(null==i?void 0:i.userId))&&(t._unreadMemberStateMap.get(r.userId)0&&void 0!==arguments[0]&&arguments[0],n=It.of(this._iid),r=n.sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var a={};return this.members.forEach((function(n){if(t||n.userId!==r.userId){var i=e._unreadMemberStateMap.get(n.userId);a[n.userId]=new yu(e._iid,{channel_url:e.url,channel_type:e.channelType,user:_u.payloadify(n),ts:i})}})),a}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=It.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.requestQueue,a=n.dispatcher,i=new Ku({channelUrl:this.url}),t.next=4,r.send(i);case 4:return s=t.sent,o=s.as(zu),u=o.channel,a.dispatch(new qu({channels:[u],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return v(s(o.prototype),"freeze",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=It.of(this._iid),r.dispatcher.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return v(s(o.prototype),"unfreeze",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=It.of(this._iid),r.dispatcher.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},ml),t),lt(gl(r)).throw(T.invalidParameters),a=It.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new Il(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as(Sl),l=c.channel,i.dispatch(new qu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(e.every((function(e){return e instanceof dt}))).throw(T.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(O("string",t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=new mc({channelUrl:this.url,userIds:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(gc),c=u.channel,a.dispatch(new qu({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("string",t)||null===t).throw(T.invalidParameters),r=It.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new hc({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(dc),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,a.dispatch(new qu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=It.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new fc({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("string",t)||null===t).throw(T.invalidParameters),r=It.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new xl({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Tl),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,a.dispatch(new qu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yc({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Yn,a=It.of(this._iid).dispatcher,i=ka.of(this._iid);return v(s(o.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Bc.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new qu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,a=Object.create(null,{updateUserMessage:{get:function(){return v(s(o.prototype),"updateUserMessage",r)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=It.of(this._iid),s=i.dispatcher,r.next=3,a.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=!1,!o.silent&&this._shouldUpdateLastMessageWith(o)&&(this.lastMessage=o,u=!0),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Bc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)})),s.dispatch(new qu({channels:[this],source:c?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),c&&Bc.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(l)})),s.dispatch(new Un({messages:[o],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Yn,a=It.of(this._iid).dispatcher,i=ka.of(this._iid);return v(s(o.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Bc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new qu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Yn,a=It.of(this._iid).dispatcher,i=ka.of(this._iid);return v(s(o.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Bc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new qu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,a=Object.create(null,{updateFileMessage:{get:function(){return v(s(o.prototype),"updateFileMessage",r)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=It.of(this._iid),s=i.dispatcher,r.next=3,a.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=!1,!o.silent&&this._shouldUpdateLastMessageWith(o)&&(this.lastMessage=o,u=!0),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Bc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)})),s.dispatch(new qu({channels:[this],source:c?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),c&&Bc.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(l)})),s.dispatch(new Un({messages:[o],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Yn,a=It.of(this._iid).dispatcher,i=ka.of(this._iid);return v(s(o.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Bc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new qu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return v(s(o.prototype),"deleteMessage",n)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof tn&&(a=It.of(this._iid),a.dispatcher.dispatch(new Ln({reqId:t.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},_l),t),lt(yl(r)).throw(T.invalidParameters),a=It.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new Rc(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(xc),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Ml({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Nl({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new Ec({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(bc),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Bc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)}))),a.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new wc({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=It.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,(a=(new Date).getTime())-this._typingStarted>=r&&(this._typingStarted=a,this._typingEnded=0,i=new Ic({channelUrl:this.url,time:this._typingStarted}),n.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=It.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,(a=(new Date).getTime())-this._typingEnded>=r&&(this._typingStarted=0,this._typingEnded=a,i=new Nc({channelUrl:this.url,time:this._typingStarted}),n.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},ua),e),lt(function(e){return ea(e)&&M("number",e.scheduledAt,!0)}(e)).throw(T.invalidParameters);var t=new Yn;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Fl),t),lt(Gl(r)).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new Vl(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(ru),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},ca),e),lt(function(e){return Jr(e)&&M("number",e.scheduledAt)&&(D(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(T.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Yn;return De(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);Ge((function(){return E(t,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),D(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},Dl),t),lt(Pl(r)).throw(T.invalidParameters),!D(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new ql(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=It.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(Hl),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new jl({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=It.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ql({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=It.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new zl({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Wl),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(A(e.PushTriggerOption,t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Bl({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Kl),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(A(e.CountPreference,t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Al({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Ul),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=It.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Ol({channelUrl:this.url}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Ll),u=o.messageOffsetTimestamp,this.messageOffsetTimestamp=u,r.dispatch(new qu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("number",e)&&Yl(t)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new Jl(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Xl),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=M("number",e),lt(n).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new Zl({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=M("number",e),lt(n).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new $l({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(eh),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=M("number",e)&&M("string",t)&&""!==t.trim(),lt(r).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new th({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(nh),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=M("number",e)&&M("number",t)&&M("string",n)&&""!==n.trim(),lt(a).throw(T.invalidParameters),i=It.of(this._iid),s=i.requestQueue,o=new rh({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(ah),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=M("number",e)&&M("number",t),lt(r).throw(T.invalidParameters),a=It.of(this._iid),i=a.requestQueue,s=new ih({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=M("number",t)&&O("number",n),lt(a).throw(T.invalidParameters),i=It.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new sh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(qc),h=l.event,o.dispatch(new Fn({event:h,source:e.MessageEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("number",e)).throw(T.invalidParameters),n=xr.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e,!0)),n=xr.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Mr(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new Or(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("number",e)&&e>0).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new oh({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("number",e)&&e>0).throw(T.invalidParameters),n=It.of(this._iid),r=n.requestQueue,a=new uh({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!D(e.file)){t.next=11;break}return n=It.of(this._iid),r=n.requestQueue,a=new Pt({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Ft),o=s.url,u=s.fileSize,c=void 0===u?e.fileSize:u,l=s.thumbnailSizes,h=void 0===l?e.thumbnailSizes:l,d=s.requireAuth,p=void 0!==d&&d,e.fileUrl=o,e.fileSize=c,e.thumbnailSizes=h,e.requireAuth=p;case 11:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return _u.payloadify(e)})),last_message:fn(e.lastMessage),inviter:e.inviter?dt.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:fn(e.lastPinnedMessage)})):null}}]),o}(su),hh={},dh=function(){function t(r){var a=this,i=r._iid,s=r.limit,o=void 0===s?100:s;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=o;var u,c=It.of(this._iid),l=c.sdkState,h=c.dispatcher,d=c.logger;this._metadataKey=(u=l.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new Kc(p,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(d.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,a=Bc.of(this._iid),t.next=9,a.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,s=i.channels,o=i.token,n.hasNext=s.length>=this._limit&&!!o,n.nextToken=o,this._metadata.token=o,(r=this._metadata.range).extends.apply(r,g(s.map((function(e){return e.createdAt})))),this._metadata.completed=!n.hasNext,d.debug("channel background sync progress",n),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),d.debug("channel background sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:n.hasNext=!1,n.nextToken="";case 33:return t.abrupt("return",n);case 34:case"end":return t.stop()}}),t,this,[[5,22]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Vc(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t;It.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")}},{key:"pause",value:function(){It.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete hh[this._iid])}}],[{key:"of",value:function(e){return hh[e]||(hh[e]=new t({_iid:e})),hh[e].ref++,hh[e]}},{key:"clear",value:function(e){hh[e]&&(hh[e].close(),delete hh[e])}}]),t}(),ph={},fh=function(){function t(r){var a=this,i=r._iid;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var s,o=It.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta"));var h=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new Kc(h,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return u.debug("channel changelog sync from",this._metadata.token),t.prev=4,r=Bc.of(this._iid),t.next=8,r.getMyGroupChannelChangeLogs(this._metadata.token,{},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return a=t.sent,i=a.hasMore,s=a.token,n.hasNext=i,n.nextToken=s,this._metadata.token=s,u.debug("channel changelog sync progress",n),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),u.debug("channel changelog sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",n);case 27:case"end":return t.stop()}}),t,this,[[4,19]])})))})),this._connectionEventContext=l.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=It.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=It.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ph[this._iid])}}],[{key:"of",value:function(e){return ph[e]||(ph[e]=new t({_iid:e})),ph[e].ref++,ph[e]}},{key:"clear",value:function(e){ph[e]&&(ph[e].close(),delete ph[e])}}]),t}(),vh=function(){function t(r,a){var i=this,s=a.filter,o=a.order,u=a.limit;n(this,t),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=r,this._key="gcc-".concat(B()),this.filter=null!=s?s:new Eu,this.order=null!=o?o:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=u?u:100;var c=It.of(this._iid),l=c.sdkState;c.cacheContext.localCacheEnabled&&(this._backgroundSync=dh.of(r),this._backgroundSync.resume()),this._changelogSync=fh.of(r),this._changelogSync.resume(),Bc.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return i.filter.match(e,l.userId)})),r=e.filter((function(e){return!i.filter.match(e,l.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)},onRemove:function(e,t){i._removeChannelsFromView(e,t)}})}return a(t,[{key:"hasMore",get:function(){return this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=[],o=[],u=k(t);try{for(u.s();!(r=u.n()).done;){var c=r.value,l=rl(this.channels,c,this.order),h=l.place,d=l.contains;if(d)switch(o.push(c),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:this.channels.splice(h,1);var p=rl(this.channels,c,this.order),f=p.place;this.channels.splice(f,0,c);break;default:this.channels[h]=c}else h===this.channels.length?(i||!this._backgroundSync||this._backgroundSync.completed)&&(s.push(c),this.channels.push(c)):(s.push(c),this.channels.splice(h,0,c))}}catch(e){u.e(e)}finally{u.f()}Gu(n)&&Ge((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new zc(n),s.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(a,s),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(a,o);case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=k(e);try{var s=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)s()}catch(e){i.e(e)}finally{i.f()}return Gu(t)&&a.length>0&&Ge((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new zc(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(r,a);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Bc.of(this._iid),n=this.channels.length>0?tl(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Bc.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"loadMore",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._hasMore){t.next=8;break}return n=[],t.next=4,qe((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:n=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 4:return t.next=6,qe((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getRemoteChannels();case 2:n=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 6:return this._addChannelsToView(n,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.abrupt("return",n);case 8:return t.abrupt("return",[]);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"dispose",value:function(){var e,t;null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Bc.of(this._iid).unsubscribeGroupChannelEvent(this._key)}}]),t}(),mh=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,p=t.customTypesFilter,f=t.customTypeStartsWithFilter,v=t.superChannelFilter,m=t.metadataOrderKeyFilter,g=t.metadataKey,_=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,E=t.includeMetaData;return(a=r.call(this)).method=R.GET,a.path=ke,a.params=J({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:p,custom_type_startswith:f,super_mode:v,metadata_order_key:m,metadata_key:g,metadata_values:_,metadata_value_startswith:y,show_frozen:k,show_metadata:E}),a}return a(s)}(Z),gh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new lh(e,t)}))),i.ts="number"==typeof u?u:null,i}return a(r)}($);e.MembershipFilter=void 0,(ch=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",ch.JOINED="joined";var _h=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k;return n(this,o),(i=r.call(this,t,a)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.channelNameContainsFilter=null,i.membershipFilter=e.MembershipFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,i.includeEmpty=null!==(s=a.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(u=a.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=a.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=a.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(h=a.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(d=a.customTypeStartsWithFilter)&&void 0!==d?d:null,i.channelNameContainsFilter=null!==(p=a.channelNameContainsFilter)&&void 0!==p?p:null,i.membershipFilter=null!==(f=a.membershipFilter)&&void 0!==f?f:e.MembershipFilter.ALL,i.superChannelFilter=null!==(v=a.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,i.metadataKey=null!==(m=a.metadataKey)&&void 0!==m?m:null,i.metadataValues=null!==(g=a.metadataValues)&&void 0!==g?g:null,i.metadataOrderKeyFilter=null!==(_=a.metadataOrderKeyFilter)&&void 0!==_?_:null,i.metadataValueStartsWith=null!==(y=a.metadataValueStartsWith)&&void 0!==y?y:null,i.order=null!==(k=a.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.includeEmpty)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.channelNameContainsFilter,!0)&&O("string",this.channelUrlsFilter,!0)&&O("string",this.customTypesFilter,!0)&&M("string",this.customTypeStartsWithFilter,!0)&&A(e.MembershipFilter,this.membershipFilter)&&A(e.SuperChannelFilter,this.superChannelFilter)&&A(e.PublicGroupChannelListOrder,this.order)&&M("string",this.metadataOrderKeyFilter,!0)&&M("string",this.metadataKey,!0)&&O("string",this.metadataValues,!0)&&M("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=22;break}if(this._isLoading){t.next=19;break}if(n=[],!this._hasNext){t.next=16;break}return this._isLoading=!0,r=It.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new mh(Object.assign(Object.assign({},this),{token:this._token})),t.next=9,a.send(s);case 9:return o=t.sent,u=o.as(gh),c=u.channels,l=u.token,this._token=l,this._hasNext=!!l,i.dispatch(new qu({channels:c,source:e.GroupChannelEventSource.REQUEST_CHANNEL})),this._isLoading=!1,t.abrupt("return",c);case 16:return t.abrupt("return",n);case 19:throw T.queryInProgress;case 20:t.next=23;break;case 22:throw T.invalidParameters;case 23:case"end":return t.stop()}}),t,this)})))}}]),o}($n),yh=a((function e(){n(this,e),this.onUserMuted=oe,this.onUserUnmuted=oe,this.onUserBanned=oe,this.onUserUnbanned=oe,this.onChannelChanged=oe,this.onChannelDeleted=oe,this.onChannelFrozen=oe,this.onChannelUnfrozen=oe,this.onOperatorUpdated=oe,this.onChannelMemberCountChanged=oe,this.onMetaDataCreated=oe,this.onMetaDataUpdated=oe,this.onMetaDataDeleted=oe,this.onMetaCounterCreated=oe,this.onMetaCounterUpdated=oe,this.onMetaCounterDeleted=oe,this.onMessageReceived=oe,this.onMessageUpdated=oe,this.onMessageDeleted=oe,this.onMentionReceived=oe,this.onReactionUpdated=oe,this.onThreadInfoUpdated=oe})),kh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).onUserJoined=oe,e.onUserLeft=oe,e.onUserReceivedInvitation=oe,e.onUserDeclinedInvitation=oe,e.onChannelHidden=oe,e.onUnreadMemberStatusUpdated=oe,e.onUndeliveredMemberStatusUpdated=oe,e.onTypingStatusUpdated=oe,e.onPollUpdated=oe,e.onPollVoted=oe,e.onPollDeleted=oe,e.onPinnedMessageUpdated=oe,e}return a(r)}(yh),Eh=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(kh),bh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=R.GET,a.path="".concat(Se),a.params=J({limit:s,reverse:u,channel_url:c,order:o,status:h}),i&&(a.params.token=i),l&&(a.params.message_type=l),a}return a(r)}(Z),wh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return vn(e,t)})),i}return a(r)}($),Ch=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h;return n(this,o),(i=r.call(this,t,a)).channelUrl=null,i.order=null,i.reverse=!1,i.scheduledStatus=null,i.messageTypeFilter=e.MessageTypeFilter.ALL,i.channelUrl=null!==(s=a.channelUrl)&&void 0!==s?s:null,i.order=null!==(u=a.order)&&void 0!==u?u:null,i.reverse=null!==(c=a.reverse)&&void 0!==c&&c,i.scheduledStatus=null!==(l=a.scheduledStatus)&&void 0!==l?l:null,i.messageTypeFilter=null!==(h=a.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.channelUrl,!0)&&(A(e.ScheduledMessageListOrder,this.order)||null===this.order)&&M("boolean",this.reverse)&&(O(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&A(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new bh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(wh),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}($n),Rh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="groupChannel",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Bc(e,{sdkState:n,cacheContext:l,dispatcher:a,sessionManager:i,requestQueue:o,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new vh(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Hc(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _h(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ch(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){lt(M("string",e)&&t instanceof Eh).throw(T.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){lt(M("string",e)).throw(T.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Tu),t),lt(M("string",e)&&Iu(r)).throw(T.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Tu),t),lt(M("number",e)&&Iu(r)).throw(T.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Su),e),lt(Nu(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),lt(xu(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),lt(xu(n)).throw(T.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},Ru),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:lt(O("string",e)).throw(T.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}]),r}(Dt),xh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return a(r,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null!==(t=this._channels.get(e))&&void 0!==t?t:null);case 1:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.forEach((function(e){if(n._channels.has(e.url)){var t=n._channels.get(e.url);Object.assign(t,e)}else n._channels.set(e.url,e)}));case 1:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),r}(tt),Th={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Ih=function(e){return O("string",e.operatorUserIds,!0)&&(M("string",e.coverUrlOrImage)||D(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&(M("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)},Sh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.isInternalCall;return n(this,r),(a=t.call(this)).method=R.GET,a.path="".concat(s?we:be,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),Nh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=null,i.channel=new Kh(e,a),i}return a(r)}($),Mh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=R.POST,a.path=be,a.params=J({channel_url:i,cover_url:M("string",s)?s:null,cover_file:D(s)?s:null,name:o,data:u,custom_type:c,operators:l}),a}return a(r)}(Z),Ah=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return a(r)}(le),Uh=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u;return n(this,r),s=t.call(this,e,"SYEV",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new dt(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return a(r)}(lc),Oh=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return a(r)}(le),Lh=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u;return n(this,r),s=t.call(this,e,"EXIT",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new dt(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return a(r)}(lc),Dh={},Ph=function(){function t(e,r){var a=this,i=r.sdkState,s=r.dispatcher,o=r.requestQueue;return n(this,t),Dh[e]||(this._iid=e,this._sdkState=i,this._requestQueue=o,this._dispatcher=s,this._openChannelCache=new xh(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof se)a._handleEvent(e);else if(e instanceof ve&&e.stateType===ue.CONNECTED){var t,n=k(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),Dh[e]=this),Dh[e]}return a(t,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=ct(e);return new Kh(this._iid,Kh.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=k(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h,d,p,f,v,m,g,_,y,b,w,C,R,T,I,S,N,M,A,U,O,L,D,P,F,G,q,H,V,j,Q,B,K,z,W,Y,J,X,Z,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,he,de,pe,fe,ve,me,ge,_e,ye,ke,Ee,be,we=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?24:"MRCT"===n.t0?31:"MTHD"===n.t0?38:"MCNT"===n.t0?45:"SYEV"===n.t0?72:149;break;case 4:if(r=null,"MESG"===t.code?r=t.as(jo):"FILE"===t.code?r=t.as(wn):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(Lc)),!r){n.next=13;break}if(i=(a=r).message,s=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:o=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(o.url)&&(r.onMessageReceived(o,i),s&&r.onMentionReceived(o,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",149);case 14:if(u=null,"MEDI"===t.code?u=t.as(Bo):"FEDI"===t.code?u=t.as(zo):"AEDI"===t.code&&(u=t.as(Dc)),!u){n.next=23;break}if(l=(c=u).message,h=c.mentionCountChange,l.channelType!==e.ChannelType.OPEN){n.next=23;break}return n.next=21,this.getChannel(l.channelUrl,!0);case 21:d=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&(r.onMessageUpdated(d,l),h>0&&r.onMentionReceived(d,l))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return n.abrupt("break",149);case 24:if(p=t.as(Yo),f=p.channelUrl,v=p.channelType,m=p.messageId,v!==e.ChannelType.OPEN){n.next=30;break}return n.next=28,this.getChannel(f,!0);case 28:g=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onMessageDeleted(g,m)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return n.abrupt("break",149);case 31:if(_=t.as(Pc),y=_.channelUrl,b=_.channelType,w=_.event,b!==e.ChannelType.OPEN){n.next=37;break}return n.next=35,this.getChannel(y,!0);case 35:C=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(C.url)&&r.onReactionUpdated(C,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return n.abrupt("break",149);case 38:if(R=t.as(Fc),(T=R.event).channelType!==e.ChannelType.OPEN){n.next=44;break}return n.next=42,this.getChannel(T.channelUrl,!0);case 42:I=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(I.url)&&r.onThreadInfoUpdated(I,T)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return n.abrupt("break",149);case 45:S=t.as(Uc),N=S.openChannelMemberCounts,M=[],A=k(N),n.prev=48,A.s();case 50:if((U=A.n()).done){n.next=59;break}return O=U.value,L=O.channelUrl,D=O.participantCount,P=O.updatedAt,n.next=55,this.getChannelFromCache(L);case 55:(F=n.sent)&&F._updateParticipantCount(D,P)&&M.push(F);case 57:n.next=50;break;case 59:n.next=64;break;case 61:n.prev=61,n.t1=n.catch(48),A.e(n.t1);case 64:return n.prev=64,A.f(),n.finish(64);case 67:if(!(M.length>0)){n.next=71;break}return n.next=70,this.upsertChannelsToCache(M);case 70:Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelMemberCountChanged(M)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 71:return n.abrupt("break",149);case 72:if(G=t.as(lc),!(q=G.event).isOpenChannelEvent){n.next=148;break}n.t2=q.category,n.next=n.t2===ku.CHANNEL_ENTER?77:n.t2===ku.CHANNEL_EXIT?84:n.t2===ku.CHANNEL_OPERATOR_UPDATE?91:n.t2===ku.USER_CHANNEL_MUTE||n.t2===ku.USER_CHANNEL_UNMUTE?99:n.t2===ku.USER_CHANNEL_BAN||n.t2===ku.USER_CHANNEL_UNBAN?106:n.t2===ku.CHANNEL_FREEZE||n.t2===ku.CHANNEL_UNFREEZE?113:n.t2===ku.CHANNEL_DELETED?121:n.t2===ku.CHANNEL_PROP_CHANGED?128:n.t2===ku.CHANNEL_META_DATA_CHANGED?133:n.t2===ku.CHANNEL_META_COUNTERS_CHANGED?142:148;break;case 77:return n.next=79,this.getChannel(q.channelUrl,!0);case 79:return H=n.sent,V=t.as(Uh),j=V.participantCount,Q=V.user,B=H._updateParticipantCount(j,q.ts),Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered(H,Q),B&&e.onChannelParticipantCountChanged(H)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 84:return n.next=86,this.getChannel(q.channelUrl,!0);case 86:return K=n.sent,z=t.as(Lh),W=z.participantCount,Y=z.user,J=K._updateParticipantCount(W,q.ts),Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(K,Y),J&&e.onChannelParticipantCountChanged(K)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 91:return n.next=93,this.getChannel(q.channelUrl,!0);case 93:return X=n.sent,Z=t.as(Ac),$=Z.operators,X.operators=$,this.upsertChannelsToCache([X]),Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(X,$)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 99:return n.next=101,this.getChannel(q.channelUrl,!0);case 101:return ee=n.sent,te=q.category===ku.USER_CHANNEL_MUTE,ne=t.as(te?No:Ao),re=ne.user,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){te?e.onUserMuted(ee,re):e.onUserUnmuted(ee,re)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 106:return n.next=108,this.getChannel(q.channelUrl,!0);case 108:return ae=n.sent,ie=q.category===ku.USER_CHANNEL_BAN,se=t.as(ie?Oo:Do),oe=se.user,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ie?e.onUserBanned(ae,oe):e.onUserUnbanned(ae,oe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 113:return n.next=115,this.getChannel(q.channelUrl,!0);case 115:return ue=n.sent,ce=t.as(Fo),le=ce.freeze,ue.isFrozen=le,this.upsertChannelsToCache([ue]),Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){le?e.onChannelFrozen(ue):e.onChannelUnfrozen(ue)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 121:return n.next=123,this.getChannel(q.channelUrl,!0);case 123:return he=n.sent,n.next=126,this.removeChannelsFromCache([he.url]);case 126:return Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(he.url,he.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 128:return n.next=130,this.getChannelWithoutCache(q.channelUrl,!0);case 130:return de=n.sent,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(de)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 133:return n.next=135,this.getChannel(q.channelUrl,!0);case 135:return pe=n.sent,fe=t.as(vo),ve=fe.created,me=fe.updated,ge=fe.deleted,ve&&pe._upsertCachedMetaData(ve,q.ts),me&&pe._upsertCachedMetaData(me,q.ts),ge&&pe._removeFromCachedMetaData(ge,q.ts),Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve&&e.onMetaDataCreated(pe,ve),me&&e.onMetaDataUpdated(pe,me),ge&&e.onMetaDataDeleted(pe,ge)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 142:return n.next=144,this.getChannel(q.channelUrl,!0);case 144:return _e=n.sent,ye=t.as(xo),ke=ye.created,Ee=ye.updated,be=ye.deleted,Ge((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ke&&e.onMetaCounterCreated(_e,ke),Ee&&e.onMetaCounterUpdated(_e,Ee),be&&e.onMetaCounterDeleted(_e,be)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 148:return n.abrupt("break",149);case 149:n.next=155;break;case 151:if(n.prev=151,n.t3=n.catch(0),!x(n.t3)){n.next=155;break}throw n.t3;case 155:case"end":return n.stop()}}),n,this,[[0,151],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",n);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return lt(M("string",e)).throw(T.invalidParameters),r=new Sh({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Nh),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",s);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Th),e),lt(Ih(n)).throw(T.invalidParameters),r=new Mh(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Nh),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Dh[e]}}]),t}(),Fh={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Gh=function(e){return O("string",e.operatorUserIds,!0)&&(M("string",e.coverUrlOrImage)||D(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)},qh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.token,o=e.limit;return(a=t.call(this)).method=R.GET,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return a(r)}(Z),Hh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new ou(e,t)})),i}return a(r)}($),Vh=function(t){i(o,t);var r=p(o);function o(t,a,i){return n(this,o),r.call(this,t,a,e.ChannelType.OPEN,i)}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new qh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Hh),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(sr),jh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=R.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i)),a.params=J({cover_url:M("string",s)?s:null,cover_file:D(s)?s:null,name:o,data:u,custom_type:c,operators:l}),a}return a(r)}(Z),Qh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new Kh(e,a),i}return a(r)}($),Bh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=R.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),Kh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s;return n(this,o),(i=r.call(this,t,a))._lastParticipantCountUpdated=0,i.participantCount=0,i.operators=[],i.channelType=e.ChannelType.OPEN,i.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,i.operators=Array.isArray(a.operators)?a.operators.map((function(e){return new dt(t,e)})):[],i}return a(o,[{key:"serialize",value:function(){return ut(this)}},{key:"isOperator",value:function(e){return e instanceof dt?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Vh(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Ph.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Ah({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Uh),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),Ph.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Oh({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Lh),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),Ph.of(this._iid).setExitedToCache(this),Wn.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Fh),e),lt(Gh(n)).throw(T.invalidParameters),r=It.of(this._iid),a=r.requestQueue,i=new jh(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Qh),u=o.channel,c=Ph.of(this._iid),t.next=11,c.upsertChannelsToCache([u]);case 11:return t.abrupt("return",u);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},Fh),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=It.of(this._iid),n=t.requestQueue,r=new Bh({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=Ph.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return lt(!e.isPinnedMessage).throw(T.notSupportedError),v(s(o.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return lt(!e.isPinnedMessage).throw(T.notSupportedError),v(s(o.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},su.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return dt.payloadify(e)}))})):null}}]),o}(su),zh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).onUserEntered=oe,e.onUserExited=oe,e.onChannelParticipantCountChanged=oe,e}return a(r)}(yh),Wh=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(zh),Yh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=R.GET,a.path=be,a.params=J({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return a(r)}(Z),Jh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new Kh(e,t)}))),i.ts="number"==typeof u?u:null,i}return a(r)}($),Xh=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l;return n(this,r),(i=t.call(this,e,a)).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.nameKeyword,!0)&&M("string",this.urlKeyword,!0)&&O("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=It.of(this._iid),n=t.requestQueue,r=new Yh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Jh),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=Ph.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw T.queryInProgress;case 21:e.next=24;break;case 23:throw T.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),r}($n),Zh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="openChannel",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ph(e,{sdkState:n,dispatcher:a,requestQueue:o})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Xh(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},Th)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}]),r}(Dt);return e.AdminMessage=sn,e.AppleCriticalAlertOptions=Jt,e.ApplicationUserListQuery=Ri,e.BannedUserListQuery=no,e.BaseChannel=su,e.BaseMessage=$t,e.BlockedUserListQuery=Ii,e.ConnectionHandler=Gr,e.Emoji=fi,e.EmojiCategory=vi,e.EmojiContainer=mi,e.FileMessage=mn,e.FriendListQuery=Mi,e.GroupChannel=lh,e.GroupChannelCollection=vh,e.GroupChannelEventContext=zc,e.GroupChannelFilter=Eu,e.GroupChannelHandler=Eh,e.GroupChannelListQuery=Hc,e.GroupChannelModule=Rh,e.Member=_u,e.MemberListQuery=Rl,e.MemoryStore=Is,e.MessageCollection=vl,e.MessageCollectionInitHandler=fl,e.MessageEventContext=Wc,e.MessageFilter=Kr,e.MessageMetaArray=zt,e.MessageModule=lr,e.MessageRequestHandler=Yn,e.MessageSearchQuery=ir,e.MutedUserListQuery=$s,e.OGImage=Wt,e.OGMetaData=Yt,e.OpenChannel=Kh,e.OpenChannelHandler=Wh,e.OpenChannelListQuery=Xh,e.OpenChannelModule=Zh,e.OperatorListQuery=Js,e.Participant=ou,e.ParticipantListQuery=Vh,e.Plugin=on,e.PreviousMessageListQuery=or,e.PublicGroupChannelListQuery=_h,e.Reaction=Kt,e.ReactionEvent=Bt,e.ReadStatus=yu,e.RestrictedUser=Hs,e.RestrictionInfo=qs,e.ScheduledMessageListQuery=Ch,e.SendbirdChat=cu,e.SendbirdChatOptions=q,e.SendbirdError=T,e.Sender=en,e.SessionHandler=Fr,e.ThreadInfo=qt,e.ThreadInfoUpdateEvent=Jn,e.Thumbnail=nn,e.User=dt,e.UserEventHandler=qr,e.UserMessage=pn,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); + ***************************************************************************** */function E(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}var b,w="4.3.1",C=function(){function e(){n(this,e)}return a(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED"}(b||(b={}));var x,R=function(e){return!(e instanceof T&&!e.shouldThrowOutside)},T=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.code,s=void 0===i?0:i,o=e.message;return n(this,r),(a=t.call(this,o)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=s,Object.setPrototypeOf(h(a),r.prototype),a}return a(r,[{key:"isInvalidTokenError",get:function(){return this.code===b.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===b.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===b.SESSION_KEY_EXPIRED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new r({code:b.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new r({code:b.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new r({code:b.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new r({code:b.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new r({code:b.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new r({code:b.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new r({code:b.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new r({code:b.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new r({code:b.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new r({code:b.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new r({code:b.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new r({code:b.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new r({code:b.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new r({code:b.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new r({code:b.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new r({code:b.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new r({code:b.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new r({code:b.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new r({code:b.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}}]),r}(l(Error)),I=[b.CONNECTION_REQUIRED,b.NETWORK_ERROR,b.ACK_TIMEOUT,b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.FILE_UPLOAD_CANCEL_FAILED,b.REQUEST_CANCELED,b.INTERNAL_SERVER_ERROR,b.RATE_LIMIT_EXCEEDED,b.UNKNOWN_SERVER_ERROR],S=[b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.CONNECTION_REQUIRED],N=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},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},M=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!r||null!=n)||("string"!=typeof e?"object"===t(e)?A(e,n):U(e,n):t(n)===e)},A=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!n||null!=t)||Object.values(e).includes(t)},U=function(e,t){return t instanceof e},O=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!(!n||null!=t)||Array.isArray(t)&&t.every((function(t){return M(e,t)}))},D=function(e){return e>0&&S.indexOf(e)>=0},L=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t&&null===e)return!0;var n=M("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},P=1e4,F=1e3,G=1e4,q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.useMemberInfoInMessage,a=void 0===r||r,i=t.typingIndicatorInvalidateTime,s=void 0===i?P:i,o=t.typingIndicatorThrottle,u=void 0===o?F:o,c=t.websocketResponseTimeout,l=void 0===c?G:c,h=t.sessionTokenRefreshTimeout,d=void 0===h?60:h;n(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=P,this._typingIndicatorThrottle=F,this._websocketResponseTimeout=G,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=s,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=d}return a(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){M("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){M("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){M("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){M("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){M("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),H={encrypt:function(e){return e},decrypt:function(e){return e}},j=function(){function e(t){var r=t.store;n(this,e),this._preference=new Map,this._store=r}return a(e,[{key:"_savePreferenceKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:g(this._preference.keys()),generation:1});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._keysAddress=e,n.next=3,this._store.get(e);case 3:if(n.t1=t=n.sent,n.t0=null!==n.t1,!n.t0){n.next=7;break}n.t0=void 0!==t;case 7:if(!n.t0){n.next=11;break}n.t2=t,n.next=12;break;case 11:n.t2=[];case 12:r=n.t2,a=k(r),n.prev=14,a.s();case 16:if((i=a.n()).done){n.next=24;break}return s=i.value,n.next=20,this._store.get(s);case 20:(o=n.sent)&&this._preference.set(s,o);case 22:n.next=16;break;case 24:n.next=29;break;case 26:n.prev=26,n.t3=n.catch(14),a.e(n.t3);case 29:return n.prev=29,a.f(),n.finish(29);case 32:case"end":return n.stop()}}),n,this,[[14,26,29,32]])})))}},{key:"get",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null!==(t=this._preference.get(e))&&void 0!==t?t:null);case 1:case"end":return n.stop()}}),n,this)})))}},{key:"set",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=!this._preference.has(e),n.next=3,this._store.set({key:e,value:t,generation:1});case 3:if(this._preference.set(e,t),!r){n.next=7;break}return n.next=7,this._savePreferenceKeys();case 7:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.remove(e);case 2:return this._preference.delete(e),t.next=5,this._savePreferenceKeys();case 5:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.removeMany(g(this._preference.keys()));case 2:return this._preference.clear(),e.next=5,this._savePreferenceKeys();case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),V=a((function e(t){var r=t.encryption,a=void 0===r?null:r,i=t.store,s=void 0===i?null:i,o=t.localCacheEnabled,u=void 0===o||o;n(this,e),this.nestdb=null,this.store=s,this.preference=new j({store:s}),this.encryption=null!=a?a:H,this.localCacheEnabled=u})),Q=function(){function e(){n(this,e),this.sessionKey=null,this.authToken=null}return a(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),B=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)}))},K=function(){function e(t){var r=t.container;n(this,e),this._container={},this._container=r,this.key=B()}return a(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),z=function(){function e(){n(this,e),this._container={}}return a(e,[{key:"on",value:function(e,t){return new K({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new K({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],i=k(n.keys());try{for(i.s();!(r=i.n()).done;){var s=r.value,o=n.get(s);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(s))}}catch(e){i.e(e)}finally{i.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),W=function(){function e(){n(this,e),this._dispatcher=new z}return a(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),Y=a((function e(){n(this,e)})),J=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(x||(x={}));var X,Z=function(e){i(s,e);var r=p(s);function s(){var e;return n(this,s),(e=r.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=B(),e}return a(s,[{key:"stringifyParams",value:function(e){return"object"!==t(e)||Array.isArray(e)?String(e):e?JSON.stringify(e):""}},{key:"encodeParams",value:function(e){var n=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return n.encodeParams(e)})).join(","):"object"===t(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=J(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=this,t=J(this.params);if(Object.keys(t).some((function(e){return L(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var a,i=t[r];if(L(i)){var s=i;n.append(r,s,null!==(a=s.name)&&void 0!==a?a:"filename")}else n.append(r,e.stringifyParams(i))})),n}return JSON.stringify(t)}}]),s}(Y),$=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this))._iid=e,i._payload=a,i}return a(r,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),r}(Y),ee=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).requestId=e,a}return a(r)}(Y),te=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r)}(Y),ne=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).statLog=e,a}return a(r)}(Y);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(X||(X={}));var re,ae=function(){function e(t){var r=t.type,a=t.data,i=t.ts,s=void 0===i?Date.now():i;n(this,e),this.type=r,this.createdAt=s,this.data=a}return a(e,null,[{key:"payloadify",value:function(e){return J({stat_type:e.type,ts:e.createdAt,data:J(e.data)})}}]),e}(),ie=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._abortControl=new Map,this._iid=t,this._auth=i,this._sdkState=s,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ee&&a.cancel(e.requestId)})),this._logger=u}return a(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,i=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(i["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(i["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(i["App-Id"]=r,i["Access-Token"]=this._auth.authToken),i}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new ne(new ae({type:X.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p,f,v,m;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.path,r=e.method,a=![x.GET,x.DELETE].includes(r),i=this._sdkState.api,s="".concat(i.host).concat(n).concat(a?"":e.query),o=a?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),t.prev=10,t.next=13,fetch(s,{method:r,body:o,headers:u,signal:l});case 13:return d=t.sent,t.next=16,d.json();case 16:if(p=t.sent,!d.ok&&!d.redirected){t.next=23;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),t.abrupt("return",new $(this._iid,p));case 23:if(!p){t.next=30;break}throw f=new T(p),!e.requireAuth&&f.isSessionKeyExpiredError&&this._dispatcher.dispatch(new te),this._statLogApiResult(e,h,f),f;case 30:throw v=T.requestFailed,this._statLogApiResult(e,h,v),v;case 33:t.next=50;break;case 35:if(t.prev=35,t.t0=t.catch(10),this._statLogApiResult(e,h,t.t0),!(t.t0 instanceof T)){t.next=43;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 43:if("AbortError"!==t.t0.name){t.next=47;break}throw T.requestCanceled;case 47:throw m=T.networkError,this._logger.debug("fail api request",m),m;case 50:case"end":return t.stop()}}),t,this,[[10,35]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=k(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),se=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return n(this,r),(s=t.call(this))._iid=e,s.code=a,s.payload=i,s.requestId=i?i.req_id:o,s}return a(r,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var n=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){n="NOOP"}finally{return new r(e,n,a)}}}]),r}(Y),oe=function(){};e.ConnectionState=void 0,(re=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",re.OPEN="OPEN",re.CLOSED="CLOSED";var ue,ce=function(t){i(s,t);var r=p(s);function s(e,t){var a,i=t.sdkState,o=t.dispatcher,u=t.logger;return n(this,s),(a=r.call(this)).lastActive=0,a._iid=e,a._sdkState=i,a._dispatcher=o,a._logger=u,a}return a(s,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"connect",value:function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&M("string",e)){var n=se.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new te):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",T.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=oe,t._ws.onmessage=oe,t._ws.onerror=oe,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw T.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),s}(z),le=function(e){i(r,e);var t=p(r);function r(e){var a,i,s=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return n(this,r),(a=t.call(this)).code=s,a.payload=c,a.requestId=null!==(i=a.payload.req_id)&&void 0!==i?i:B(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return a(r,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),r}(Y),he=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.all,s=e.custom_types,o=e.ts;return n(this,r),(a=t.call(this)).all=i,a.customTypes=s,a.ts=o,a}return a(r)}(Y),de=a((function e(){var t=this;n(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),pe=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=o,this._logger=u,this.apiClient=new ie(t,{auth:i,sdkState:s,dispatcher:o,logger:u}),this.websocketClient=new ce(t,{sdkState:s,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new he(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new T({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(T.connectionClosed)})),a._ackStateMap.clear()}))}return a(e,[{key:"_sendApiRequest",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=new de,e.ackRequired){r=null,a=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),r&&(clearTimeout(r),r=null),t?(i._logger.debug("fail websocket request",t),n.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),n.resolve(a)))};try{r=setTimeout((function(){return a(T.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return a(null,e)},reject:function(e){return a(e)}}),this.websocketClient.send(e)}catch(e){a(e)}}else try{this.websocketClient.send(e),n.resolve(null)}catch(e){n.reject(e)}return t.abrupt("return",n.promise);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Z)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof le)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw T.invalidParameters;case 11:case"end":return t.stop()}}),t,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(ue||(ue={}));var fe,ve=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.stateType;return n(this,r),(a=t.call(this)).stateType=i,a}return a(r)}(Y),me=function(){function e(t,r){var a=this,i=r.auth,s=r.sdkState,o=r.dispatcher,u=r.logger;n(this,e),this._currentConnectionStateType=ue.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new pe(t,{auth:i,sdkState:s,dispatcher:o,logger:u}),this._auth=i,this._logger=u,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof ve){var t=e.stateType;switch(a._currentConnectionStateType=t,t){case ue.CONNECTED:var n=a._lazyCallQueue;a._lazyCallQueue=[],n.forEach((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.command,r=e.deferred,a=e.timeout,clearTimeout(a),t.prev=2,t.next=5,this.send(n);case 5:i=t.sent,r.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r.reject(t.t0);case 12:case"end":return t.stop()}}),t,this,[[2,9]])})))}));break;case ue.INITIALIZED:case ue.DISCONNECTED:case ue.LOGOUT:var r=a._lazyCallQueue;a._lazyCallQueue=[],r.forEach((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.deferred,r=e.timeout,clearTimeout(r),this._auth&&this._auth.hasSession?n.reject(T.connectionClosed):n.reject(T.connectionRequired);case 3:case"end":return t.stop()}}),t,this)})))}))}}}))}return a(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===ue.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===ue.CONNECTING||this._currentConnectionStateType===ue.RECONNECTING}},{key:"send",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof le)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),n=new de,this._lazyCallQueue.push({command:e,deferred:n,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",n.promise);case 15:throw this._logger.debug("fail websocket request"),T.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof Z)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),r=new de,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 34:throw a=T.connectionRequired,this._logger.debug("fail api request",a),a;case 37:case"end":return t.stop()}}),t,this)})))}},{key:"forceSend",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(T.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),ge="sendbird@devicetokens",_e=function(){function e(t){var r=t.type,a=t.token;n(this,e),this.type=r,this.token=a}return a(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),ye="v3",ke="/".concat(ye,"/users"),Ee="/".concat(ye,"/storage/file"),be="/".concat(ye,"/group_channels"),we="/".concat(ye,"/sdk/group_channels"),Ce="/".concat(ye,"/open_channels"),xe="/".concat(ye,"/sdk/open_channels"),Re="/".concat(ye,"/search"),Te="/".concat(ye,"/report"),Ie="/".concat(ye,"/emojis"),Se="/".concat(ye,"/emoji_categories"),Ne="/".concat(ye,"/polls"),Me="/".concat(ye,"/scheduled_messages"),Ae="/".concat(ye,"/sdk/statistics"),Ue=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.authToken,o=e.expiringSession,u=void 0===o||o;return n(this,r),(a=t.call(this)).path="".concat(ke,"/").concat(i,"/session_key"),a.method=x.POST,a.params={token:s,expiring_session:!!u},a.requireAuth=!1,a}return a(r)}(Z),Oe=function(e){i(r,e);var t=p(r);function r(e){var a=e.authToken,i=e.expiringSession,s=void 0===i||i,o=e.requestId,u=void 0===o?null:o;return n(this,r),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:s?1:0,req_id:u},ackRequired:!0})}return a(r)}(le),De=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),i=t.call(this,e,a);var s=a.key;return i.key=s,i}return a(r)}($),Le=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"LOGI",i)).error=null,s.newKey=i.new_key,s.error=i.error?new T(i.error):null,s}return a(r)}(se),Pe=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r)}(Y),Fe=function(e){return E(void 0,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),t)})))},Ge=function(){function e(){n(this,e)}return a(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),qe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Ge;return E(void 0,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=0,i=null,s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},o=function(){a=0};case 4:if(!(-1===t||a1&&void 0!==arguments[1]?arguments[1]:null;return new Oe({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(n);case 3:if(r=t.sent,a=r.as(Le),i=a.newKey,!(s=a.error)){t.next=7;break}throw s;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ue({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),t.next=3,qe((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(n);case 3:r=t.sent,a=r.as(De),i=a.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),t,this,[[0,8]])})))}),3);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_refreshSessionKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._currentConnectionStateType!==ue.CONNECTED){n.next=25;break}return n.prev=1,n.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),n.abrupt("return");case 8:if(n.prev=8,n.t0=n.catch(1),!this._isSessionRelatedError(n.t0)){n.next=25;break}if(!t){n.next=25;break}return n.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=n.sent,!this.auth.authToken){n.next=21;break}return n.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),n.next=24;break;case 21:return n.next=23,this.clear();case 23:this.close();case 24:return n.abrupt("return");case 25:return n.prev=25,n.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),n.next=53;break;case 31:if(n.prev=31,n.t1=n.catch(25),!this._isSessionRelatedError(n.t1)){n.next=52;break}if(!t){n.next=49;break}return n.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=n.sent,!this.auth.authToken){n.next=44;break}return n.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),n.next=47;break;case 44:return n.next=46,this.clear();case 46:this.close();case 47:n.next=50;break;case 49:throw n.t1;case 50:n.next=53;break;case 52:throw n.t1;case 53:case"end":return n.stop()}}),n,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,t=new de;return He((function(){return E(e,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),n=null,r=function(){n&&(clearTimeout(n),n=null)},n=setTimeout((function(){a._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){r(),a._isRefreshingAuthToken&&(a._isRefreshingAuthToken=!1,a.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){r(),a._isRefreshingAuthToken=!1,t.reject(e)}));case 6:case"end":return e.stop()}}),e,this)})))})),t.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof T&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.auth.sessionKey=e.key,Ve.set(this,e.ekey),n=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=16;break}return t.next=6,n.get(ge);case 6:if((r=t.sent)&&!(r.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokens=this._deviceTokens.filter((function(t){return t.type!==e}))}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return t=this._cacheContext.preference,e.next=4,t.set(ge,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),Ve.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=7,this.saveDeviceToken();case 7:case"end":return e.stop()}}),e,this)})))}}]),r}(z),Be=function(){function e(){n(this,e),this.type=ue.NONE,this.name="none"}return a(e,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,t){return t.resetReconnectCount,E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,t){return t.error,t.autoReconnect,E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),Ke=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.LOGOUT,e.name="logout",e}return a(r,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=e.sdkState.userId,t.next=4,e.logout();case 4:return t.next=6,e.changeState(new Xe,n);case 6:He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(r)}));case 1:case"end":return t.stop()}}),t)})))}));case 7:case"end":return t.stop()}}),t)})))}}]),r}(Be),ze=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.autoReconnect;return n(this,r),(a=t.call(this)).type=ue.DISCONNECTED,a.name="disconnected",a._autoReconnect=!1,a._autoReconnect=i,a}return a(r,[{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new We,n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.disconnect();case 3:return n.next=5,e.changeState(new Je({authToken:t}),r);case 5:case"end":return n.stop()}}),n)})))}},{key:"onReconnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new We,n);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ke,n);case 3:case"end":return t.stop()}}),t)})))}}]),r}(Be),We=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return a(r,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=new de,this._callbacks.push((function(e){return e?r.reject(e):r.resolve()})),He((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),t)})))})),t.prev=4,a=e.sdkState.websocket,i=a.reconnectMaxRetry,s=a.reconnectRetryStrategy,t.next=8,qe((function(t,n){return E(o,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return this._haltConnect=t,this._resetConnect=n,r.prev=2,r.next=5,e.connect();case 5:r.next=17;break;case 7:if(r.prev=7,r.t0=r.catch(2),e.clearLoginTimer(),!(r.t0 instanceof T)){r.next=16;break}r.t1=r.t0.code,r.next=r.t1===b.CONNECTION_CANCELED?14:16;break;case 14:return t(r.t0),r.abrupt("return");case 16:throw r.t0;case 17:case"end":return r.stop()}}),r,this,[[2,7]])})))}),i,s);case 8:return t.next=10,e.changeState(new Ye,n);case 10:He((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),t,this)})))})),t.next=24;break;case 13:if(t.prev=13,t.t0=t.catch(4),R(t.t0)){t.next=23;break}if(!(t.t0 instanceof T)){t.next=20;break}if(t.t0.code===b.CONNECTION_CANCELED){t.next=20;break}return t.next=20,e.changeState(new ze({autoReconnect:!1}),n);case 20:He((function(){return E(o,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:this._flushCallbacks(t.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return n.stop()}}),n,this)})))})),t.next=24;break;case 23:throw t.t0;case 24:return t.abrupt("return",r.promise);case 25:case"end":return t.stop()}}),t,this,[[4,13]])})))}},{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new de,this._halt(T.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var n=Date.now();e.changeState(new Je({authToken:t}),n).then((function(){r.resolve()})).catch((function(e){r.reject(e)}))})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"onReconnect",value:function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new de,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new ze({autoReconnect:r}),n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new Ke,n);case 4:case"end":return t.stop()}}),t,this)})))}}]),r}(Be),Ye=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.CONNECTED,e.name="connected",e}return a(r,[{key:"onReconnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new We,n);case 5:case"end":return t.stop()}}),t)})))}},{key:"onDisconnect",value:function(e,t){var n=t.autoReconnect;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new ze({autoReconnect:n}),r);case 3:case"end":return t.stop()}}),t)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),t.next=3,e.changeState(new Ke,n);case 3:case"end":return t.stop()}}),t)})))}}]),r}(Be),Je=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.authToken;return n(this,r),(a=t.call(this)).type=ue.CONNECTING,a.name="connecting",a._authToken="",a._haltConnect=null,a._callbacks=[],a._authToken=i,a}return a(r,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),r=new de,this._callbacks.push((function(e){return e?r.reject(e):r.resolve()})),t.prev=3,t.next=6,qe((function(t){return E(a,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._haltConnect=t,n.prev=1,n.next=4,e.connect(this._authToken);case 4:n.next=16;break;case 6:if(n.prev=6,n.t0=n.catch(1),e.clearLoginTimer(),!(n.t0 instanceof T)){n.next=15;break}n.t1=n.t0.code,n.next=n.t1===b.CONNECTION_CANCELED?13:15;break;case 13:return t(n.t0),n.abrupt("return");case 15:throw n.t0;case 16:case"end":return n.stop()}}),n,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return t.next=8,e.changeState(new Ye,n);case 8:He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),t,this)})))})),t.next=24;break;case 11:if(t.prev=11,t.t0=t.catch(3),R(t.t0)){t.next=23;break}return t.next=16,e.disconnect();case 16:if(!(t.t0 instanceof T)){t.next=20;break}if(t.t0.code===b.CONNECTION_CANCELED){t.next=20;break}return t.next=20,e.changeState(new Xe,n);case 20:He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(t.t0);case 1:case"end":return e.stop()}}),e,this)})))})),t.next=24;break;case 23:throw t.t0;case 24:return t.abrupt("return",r.promise);case 25:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new de,this._callbacks.push((function(e){return e?t.reject(e):t.resolve()})),e.abrupt("return",t.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,t){var n=t.error,r=void 0===n?null:n;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(null!=r?r:T.connectionCanceled),t.next=4,e.changeState(new Ke,n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"onLogout",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),this._halt(T.connectionCanceled),t.next=4,e.changeState(new Ke,n);case 4:case"end":return t.stop()}}),t,this)})))}}]),r}(Be),Xe=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).type=ue.INITIALIZED,e.name="initialized",e}return a(r,[{key:"onConnect",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),n.next=3,e.changeState(new Je({authToken:t}),r);case 3:case"end":return n.stop()}}),n)})))}}]),r}(Be),Ze=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return a(r)}(le),$e=function(){function e(t){var r=t.pingDelegate,a=t.sdkState,i=t.logger;n(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=r,this.sdkState=a,this._logger=i}return a(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new Ze;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),et=1048576,tt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e),this.emojiHash=t.emoji_hash||"",this.uploadSizeLimit=t.file_upload_size_limit?t.file_upload_size_limit*et:Number.MAX_SAFE_INTEGER,this.useReaction=!!t.use_reaction,this.applicationAttributes=t.application_attributes||[],this.premiumFeatureList=t.premium_feature_list||[],this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history")}return a(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/et,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction}}}]),e}(),nt=function(){function e(t){n(this,e),this._iid="",this._iid=t}return a(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),rt=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadata;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(ke,"/").concat(i,"/metadata"),a.params={metadata:s},a}return a(r)}(Z),at=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaData=a,i}return a(r)}($),it=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadata,o=e.upsert;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(i,"/metadata"),a.params={metadata:s,upsert:o},a}return a(r)}(Z),st=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metadata=a,i}return a(r)}($),ot=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.metadataKey;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(i,"/metadata/").concat(s),a}return a(r)}(Z),ut=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(i,"/metadata"),a}return a(r)}(Z),ct=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},lt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},ht=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(fe=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",fe.OFFLINE="offline",fe.NON_AVAILABLE="nonavailable";var dt,pt=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,_,y;return n(this,o),(i=r.call(this,t)).userId=null!==(u=null!==(s=a.guest_id)&&void 0!==s?s:a.user_id)&&void 0!==u?u:"",i.nickname=null!==(l=null!==(c=a.nickname)&&void 0!==c?c:a.name)&&void 0!==l?l:"",i.plainProfileUrl=null!==(d=null!==(h=a.profile_url)&&void 0!==h?h:a.image)&&void 0!==d?d:"",i.requireAuth=null!==(p=a.require_auth_for_profile_image)&&void 0!==p&&p,i.metaData=null!==(f=a.metadata)&&void 0!==f?f:{},i.connectionStatus=e.UserOnlineState.NON_AVAILABLE,A(e.UserOnlineState,a.is_online)?i.connectionStatus=a.is_online:M("boolean",a.is_online)&&(i.connectionStatus=a.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),i.isActive=null===(v=a.is_active)||void 0===v||v,i.lastSeenAt=null!==(m=a.last_seen_at)&&void 0!==m?m:null,i.preferredLanguages=a.preferred_languages?g(a.preferred_languages):null,i.friendDiscoveryKey=null!==(_=a.friend_discovery_key)&&void 0!==_?_:null,i.friendName=null!==(y=a.friend_name)&&void 0!==y?y:null,i}return a(o,[{key:"profileUrl",get:function(){var e=St.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return ct(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return M("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(this._isValidMetaData(e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new rt({userId:r.userId,metadata:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(at),u=o.metaData,this._applyMetaData(u),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(this._isValidMetaData(e)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new it({userId:a.userId,metadata:e,upsert:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(st),c=u.metadata,this._applyMetaData(c),n.abrupt("return",this.metaData);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ot({userId:r.userId,metadataKey:e}),t.next=5,a.send(i);case 5:return this._applyMetaData((u=!0,(o=e)in(s={})?Object.defineProperty(s,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):s[o]=u,s),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var s,o,u}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ut({userId:n.userId}),e.next=4,r.send(a);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),o}(nt),ft=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userProfile;return n(this,r),(a=t.call(this)).userProfile=i,a}return a(r)}(Y),vt=function(){function e(t,r){var a,i,s,o,u,c,l,h,d,p,f,v,m,g;n(this,e),this._iid=t,this.appInfo=new tt(r),this.user=new pt(t,r),this.connectedAt=null!==(a=r.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=r.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(s=r.pong_timeout)&&void 0!==s?s:5e3,this.reconnectInterval=null!==(u=null===(o=r.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=r.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=r.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(f=null===(p=r.reconnect)||void 0===p?void 0:p.mul)&&void 0!==f?f:2,this.maxUnreadCountOnSuperGroup=null!==(v=r.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!r.profile_image_encryption,this.concurrentCallLimit=null!==(m=r.concurrent_call_limit)&&void 0!==m?m:5,this.backOffDelay=null!==(g=r.back_off_delay)&&void 0!==g?g:100}return a(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=St.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ft({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},pt.payloadify(e.user)),tt.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),mt=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o;return n(this,r),(s=t.call(this,e,a,i)).error=null,s.userProfile=new vt(e,i),s.deviceTokenLastDeletedAt=i.device_token_last_deleted_at,s.key=i.key,s.ekey=null!==(o=i.ekey)&&void 0!==o?o:"",s.error=i.error?new T(i):null,s}return a(r,[{key:"applyTo",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(n=St.of(e))){t.next=9;break}return r=n.sessionManager,t.next=6,r.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw T.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),t,this)})))}}],[{key:"asError",value:function(e){return new r(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),r}(se),gt=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).enabled=e,a}return a(r)}(Y),_t=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext,u=a.connectionHandlers,c=a.sessionManager,l=a.websocketClient,h=a.dispatcher,d=a.logger,p=a.entryState,f=void 0===p?new Xe:p;return n(this,r),(i=t.call(this))._currentState=null,i._loginTimer=null,i._unresolvedLogi=null,i._stateUpdatedAt=0,i._connectingAt=0,i._connectionRequestQueue=[],i._iid=e,i.sdkState=s,i.cacheContext=o,i.connectionHandlers=u,i._sessionManager=c,i._websocketClient=l,i._dispatcher=h,i._logger=d,i._currentState=f,i.sdkState.websocket.pingerDisabled||(i._pinger=new $e({pingDelegate:{send:function(e){return i._websocketClient.send(e)},error:function(e){return i._websocketClient.error(e)}},sdkState:i.sdkState,logger:d})),i._websocketClient.on("open",(function(){i._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)i.clearLoginTimer(),i._dispatcher.dispatch(e.as(mt))})).on("ping-refresh",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=i._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return i._rejectConnectionRequest(T.networkError)})),i._dispatcher.on((function(e){e instanceof mt&&(i._unresolvedLogi=e,i._tryResolveConnectionRequest())})),i}return a(r,[{key:"currentState",get:function(){return this._currentState}},{key:"changeState",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>=this._stateUpdatedAt)){n.next=8;break}return this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new ve({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),n.next=7,this._currentState.run(this);case 7:return n.abrupt("return",!0);case 8:return n.abrupt("return",!1);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._unresolvedLogi,!this._websocketClient.isOpen||!n){t.next=18;break}if(this._unresolvedLogi=null,n.error){t.next=15;break}return t.next=6,n.applyTo(this._iid);case 6:r=n.userProfile,this._enableStatLog(r.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(n.error.isSessionKeyExpiredError||n.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new te),this._rejectConnectionRequest(n.error);case 18:case"end":return t.stop()}}),t,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0&&(this._connectionRequestQueue.forEach((function(t){return t.reject(e)})),this._connectionRequestQueue=[],this._statLogConnection(e))}},{key:"_url",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.sdkState,n=t.appId,r=t.appVersion,a=t.userId,i=t.extensions,s=this.cacheContext.localCacheEnabled,o=this._sessionManager.auth,u=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"],c=["gcm","huawei","apns"],l=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",h=i.sb_uikit?"u".concat(i.sb_uikit):"",d="JS/c".concat(C.SDK_VERSION,"/").concat(l,"/").concat(h);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(a),"&access_token=").concat(encodeURIComponent(e)),"&active=1&device_token_types=").concat(encodeURIComponent(c.join(",")),"&SB-User-Agent=").concat(d,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(u))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(s?1:0,"&include_poll_details=1")}},{key:"_enableStatLog",value:function(e){this._dispatcher.dispatch(new gt(e))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new ne(new ae({type:X.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._url(e),r=new de,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){a._loginTimer=null,a._dispatcher.dispatch(mt.asError(T.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._sessionManager.auth.authToken=e,this._websocketClient.connect(n)),t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(mt.asError(T.connectionRenew))}},{key:"disconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),r}(z),yt=function(){function e(t,r){var a=r.sdkState,i=r.cacheContext,s=r.connectionHandlers,o=r.sessionManager,u=r.websocketClient,c=r.dispatcher,l=r.logger,h=r.disableWebSocketCloseEventHandling,d=void 0!==h&&h;n(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new _t(t,{sdkState:a,cacheContext:i,connectionHandlers:s,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return a(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"===e._sdkState.appState&&(e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect()))})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===ue.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===ue.CONNECTING||e.type===ue.RECONNECTING}},{key:"connect",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,t.next=3,n.onConnect(this._context,e);case 3:this._registerEventDispatcher();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"reconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onReconnect(this._context,{});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onReconnect(this._context,{resetReconnectCount:!0});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,e.next=3,t.onDisconnect(this._context,{autoReconnect:!1});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._context.currentState,t.next=3,n.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"logout",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._context.currentState,this._clearEventDispatcher(),e.next=4,t.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),kt=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.deviceId,s=e.statLogs;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(Ae),a.params={device_id:i,log_entries:s.map((function(e){return ae.payloadify(e)}))},a}return a(r)}(Z);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(dt||(dt={}));var Et,bt=function(){function e(t){var r=t.cacheContext,a=t.requestQueue,i=t.dispatcher,s=t.baseLimit,o=void 0===s?100:s,u=t.maxLimit,c=void 0===u?1e3:u,l=t.minLimit,h=void 0===l?10:l;n(this,e),this.queue=[],this.enabledstate=dt.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=B(),this.cacheContext=r,this.requestQueue=a,this.dispatcher=i,this.baseLimit=o,this.limit=o,this.maxLimit=c,this.minLimit=h}return a(e,[{key:"isEnabled",get:function(){return this.enabledstate===dt.ENABLED}},{key:"_save",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.cacheContext.localCacheEnabled){e.next=3;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return ae.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=22;break}if(this.isFlushing){e.next=22;break}if(this.isFlushing=!0,e.prev=3,!((t=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0)){e.next=12;break}return n=new kt({deviceId:this.deviceId,statLogs:t}),e.next=9,this.requestQueue.send(n);case 9:return this.queue=this.queue.slice(t.length),e.next=12,this._save();case 12:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(3),this.limit=this.limit+20;case 19:return e.prev=19,this.isFlushing=!1,e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[3,16,19,22]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.key=e,!this.cacheContext.localCacheEnabled){t.next=16;break}return t.next=4,this.cacheContext.preference.get(this.key);case 4:if(!(n=t.sent)){t.next=16;break}if(this.deviceId=n.deviceId,this.queue=n.statLogs.map((function(e){return new ae({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=n.generation,this.lastFlushedAt=n.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=16;break}return r=Math.min(Math.floor(18e4*Math.random()),100),t.next=14,Fe(r);case 14:return t.next=16,this._flush();case 16:this.dispatcher.on((function(e){if(e instanceof ne){var t=e.statLog;a.put(t)}else e instanceof gt&&(a.enabledstate=e.enabled?dt.ENABLED:dt.DISABLED,a.isEnabled?a.queue.length>=a.limit&&a._flush():a.clear())}));case 17:case"end":return t.stop()}}),t,this)})))}},{key:"put",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledstate===dt.DISABLED){t.next=7;break}return this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}}]),e}();e.LogLevel=void 0,(Et=e.LogLevel||(e.LogLevel={}))[Et.NONE=0]="NONE",Et[Et.VERBOSE=1]="VERBOSE",Et[Et.DEBUG=2]="DEBUG",Et[Et.INFO=3]="INFO",Et[Et.WARN=4]="WARN",Et[Et.ERROR=5]="ERROR";var wt,Ct,xt,Rt,Tt=function(){function t(){n(this,t),this.level=e.LogLevel.WARN}return a(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&M("number",s)&&(this.key=a,this.userIds=i,this.updatedAt=s);var o,u={},c=k(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return a(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?J({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),Wt=function(){function e(t){n(this,e),this.key=t.key,this.value=O("string",t.value)?g(t.value):[]}return a(e,null,[{key:"payloadify",value:function(e){var t;return e?J({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),Yt=function(){function e(t){n(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return a(e,null,[{key:"payloadify",value:function(e){var t,n;return e?J({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null}}]),e}(),Jt=function(){function e(t){n(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new Yt(t["og:image"]))}return a(e,null,[{key:"payloadify",value:function(e){return e?J({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Yt.payloadify(e.defaultImage):null}):null}}]),e}(),Xt=function(){function e(t){var r,a;n(this,e),this.name=null,this.volume=0,this.name=null!==(r=t.name)&&void 0!==r?r:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return a(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?J({name:e.name,volume:e.volume}):null}}]),e}();e.ChannelType=void 0,(jt=e.ChannelType||(e.ChannelType={})).BASE="base",jt.GROUP="group",jt.OPEN="open",e.Role=void 0,(Vt=e.Role||(e.Role={})).OPERATOR="operator",Vt.NONE="none",e.ScheduledStatus=void 0,(Qt=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Qt.SENT="sent",Qt.FAILED="failed",Qt.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Bt||(Bt={}));var Zt,$t=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},en=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k;n(this,o),(i=r.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._scheduledStatus=null,i.messageId=null!==(u=null!==(s=a.msg_id)&&void 0!==s?s:a.message_id)&&void 0!==u?u:0,i.channelUrl=a.channel_url,i.channelType=A(e.ChannelType,a.channel_type)?a.channel_type:e.ChannelType.GROUP,a.channel&&(a.channel.channel_url&&(i.channelUrl=a.channel.channel_url),a.channel.channel_type&&(i.channelType=a.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof a.parent_message_id?parseInt(a.parent_message_id):a.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=a.data)&&void 0!==l?l:"",i.customType=null!==(h=a.custom_type)&&void 0!==h?h:"",i.mentionType=A(e.MentionType,a.mention_type)?a.mention_type:null;var E=a.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new pt(i._iid,e)})):null;var b=a.mentioned_user_ids;i.mentionedUserIds=null!=b?b:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=a.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=a.thread_info?new Ht(i._iid,a.thread_info):null,i.reactions=a.reactions?a.reactions.map((function(e){return new zt(e)})):[];for(var w=null!==(p=a.metaarray)&&void 0!==p?p:{},C=null!==(f=a.metaarray_key_order)&&void 0!==f?f:Object.keys(w).sort((function(e,t){return e.localeCompare(t)})),x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,a;return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:$t(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return pt.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?Ht.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return zt.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Wt.payloadify(e)})),og_tag:Jt.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:Xt.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(a=e.scheduledInfo)||void 0===a?void 0:a.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}}]),o}(nt),tn=function(t){i(o,t);var r=p(o);function o(t,a){var i;return n(this,o),(i=r.call(this,t,a)).role=null,i.isBlockedByMe=!1,i.role=A(e.Role,a.role)?a.role:e.Role.NONE,a.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=a.is_blocked_by_me),i}return a(o,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),o}(pt),nn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;if(n(this,o),(i=r.call(this,t,a)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=a.user?new tn(i._iid,a.user):a.sender_id,i.reqId=null!==(u=null!==(s=a.req_id)&&void 0!==s?s:a.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=a.is_reply_to_channel)&&void 0!==c&&c,a.request_state&&A(e.SendingStatus,a.request_state)&&(i.sendingStatus=a.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=a.scheduled_status,a.scheduled_status){case Bt.SENT:case Bt.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case Bt.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case Bt.FAILED:case Bt.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case Bt.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=a.error_code)&&void 0!==l?l:0,i}return a(o,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&I.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{user:tn.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),o}(en),rn=function(){function e(t){var r,a;n(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return a(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?J({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),an={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},sn=function(t){return M("number",t.prevResultSize)&&M("number",t.nextResultSize)&&M("boolean",t.isInclusive)&&M("boolean",t.reverse)&&M("string",t.messageTypeFilter)&&A(e.MessageTypeFilter,t.messageTypeFilter)&&O("string",t.customTypesFilter,!0)&&O("string",t.senderUserIdsFilter,!0)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeReactions)&&M("boolean",t.includeParentMessageInfo)},on=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;if(n(this,o),(i=r.call(this,t,a)).message=null,i.translations={},i.message=null!==(s=a.message)&&void 0!==s?s:"",i.messageType=e.MessageType.ADMIN,i.translations=null!==(u=a.translations)&&void 0!==u?u:{},a.parent_message_info){var h=a.parent_message_info,d=Object.assign(Object.assign({},h),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth});i.parentMessage=mn(t,d)}return i}return a(o,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},an),t),ht(this.messageId>0&&M("number",e)&&sn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:vn(e.parentMessage)})):null}}]),o}(en),un=function(){function e(t){var r,a;n(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(r=t.type)&&void 0!==r?r:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&M("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return a(e,null,[{key:"payloadify",value:function(e){return e?J({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Zt||(Zt={}));var cn,ln=function(e){switch(e){case Zt.OPEN:return Zt.OPEN;case Zt.CLOSED:return Zt.CLOSED}},hn=function(e){return!e||e.text&&M("string",e.text)},dn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l,h,d;return n(this,r),(i=t.call(this,e)).pollId=0,i.id=0,i.text=null,i.voteCount=0,i.createdBy=null,i.createdAt=0,i.updatedAt=0,i._lastVotedAt=0,i.pollId=null!==(s=a.poll_id)&&void 0!==s?s:0,i.id=null!==(o=a.id)&&void 0!==o?o:0,i.text=null!==(u=a.text)&&void 0!==u?u:null,i.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,i.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,i.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,i.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,i}return a(r,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(r),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),r}(nt),pn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l,h,d,p,f,v,m,g,_;return n(this,r),(i=t.call(this,e)).id=0,i.title=null,i.createdAt=0,i.updatedAt=0,i.closeAt=-1,i.status=Zt.CLOSED,i.messageId=0,i.data=null,i.voterCount=-1,i.options=[],i.createdBy=null,i.allowUserSuggestion=!1,i.allowMultipleVotes=!1,i.votedPollOptionIds=[],i.id=null!==(s=a.id)&&void 0!==s?s:0,i.title=null!==(o=a.title)&&void 0!==o?o:null,i.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,i.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,i.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,i.status=null!==(h=ln(a.status))&&void 0!==h?h:Zt.CLOSED,i.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,i.data=null!==(p=a.data)&&void 0!==p?p:null,i.voterCount=null!==(f=a.voter_count)&&void 0!==f?f:-1,i.options=a.options?a.options.map((function(e){return new dn(i._iid,e)})):[],i.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,i.allowUserSuggestion=null!==(m=a.allow_user_suggestion)&&void 0!==m&&m,i.allowMultipleVotes=null!==(g=a.allow_multiple_votes)&&void 0!==g&&g,i.votedPollOptionIds=null!==(_=a.voted_option_ids)&&void 0!==_?_:[],i}return a(r,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,i,s,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=ln(e.status))&&void 0!==a?a:this.status,this.data=null!==(i=e.data)&&void 0!==i?i:this.data,this.voterCount=null!==(s=e.voter_count)&&void 0!==s?s:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new dn(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var i=t[r];a>i._lastVotedAt&&(i.voteCount=e.vote_count,i._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(r),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return dn.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),r}(nt),fn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h;if(n(this,o),(i=r.call(this,t,a)).message="",i.messageParams=null,i.translations={},i.translationTargetLanguages=[],i.messageSurvivalSeconds=-1,i.plugins=[],i._poll=null,i.message=a.message,i.messageType=e.MessageType.USER,i.translations=null!==(s=a.translations)&&void 0!==s?s:{},i.translationTargetLanguages=null!==(u=a.target_langs)&&void 0!==u?u:[],0===Object.keys(i.translations).length&&i.translationTargetLanguages.length>0){var d,p=k(i.translationTargetLanguages);try{for(p.s();!(d=p.n()).done;){var f=d.value;i.translations[f]=""}}catch(e){p.e(e)}finally{p.f()}}if(i.messageSurvivalSeconds=null!==(c=a.message_survival_seconds)&&void 0!==c?c:-1,i.plugins=a.plugins?a.plugins.map((function(e){return new un(e)})):[],i._poll=a.poll?new pn(i._iid,a.poll):null,a.parent_message_info){var v=a.parent_message_info,m=Object.assign(Object.assign({},v),{created_at:v.ts,message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth});i.parentMessage=mn(t,J(m))}return i}return a(o,[{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},an),t),ht(this.messageId>0&&M("number",e)&&sn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return un.payloadify(e)})),poll:pn.payloadify(e._poll),parent_message_info:vn(e.parentMessage)})):null}}]),o}(nn),vn=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return fn.payloadify(t);case e.MessageType.FILE:return gn.payloadify(t);case e.MessageType.ADMIN:return on.payloadify(t)}return null},mn=function(e,t){switch(t.type){case"MESG":return new fn(e,t);case"FILE":return new gn(e,t);case"ADMM":case"BRDM":return new on(e,t)}return null},gn=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k,E;n(this,o),(i=r.call(this,t,a)).messageParams=null,i.plainUrl="",i.requireAuth=!1,i.name=null,i.size=0,i.type=null,i.thumbnails=[],i.messageSurvivalSeconds=-1,i.messageType=e.MessageType.FILE;var b=null!==(s=a.file)&&void 0!==s?s:null;i.plainUrl=(null!==(c=null!==(u=null==b?void 0:b.url)&&void 0!==u?u:a.url)&&void 0!==c?c:"").split("?auth=")[0],i.name=null!==(h=null!==(l=null==b?void 0:b.name)&&void 0!==l?l:a.name)&&void 0!==h?h:"File",i.size=null!==(p=null!==(d=null==b?void 0:b.size)&&void 0!==d?d:a.size)&&void 0!==p?p:0,i.data=null!==(v=null!==(f=null==b?void 0:b.data)&&void 0!==f?f:a.custom)&&void 0!==v?v:"",i.type=b?null!==(m=b.type)&&void 0!==m?m:"":null!==(g=a.type)&&void 0!==g?g:"";var w=St.of(i._iid).sessionManager;if(i.requireAuth=null!==(_=a.require_auth)&&void 0!==_&&_,i.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new rn(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(i.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],i.messageSurvivalSeconds=null!==(y=a.message_survival_seconds)&&void 0!==y?y:-1,a.parent_message_info){var C=a.parent_message_info,x=Object.assign(Object.assign({},C),{message_id:i.parentMessageId,channel_url:i.channelUrl,channel_type:i.channelType,file:C.file,url:null===(k=C.file)||void 0===k?void 0:k.url,require_auth:null===(E=C.file)||void 0===E?void 0:E.require_auth});i.parentMessage=mn(t,x)}return i}return a(o,[{key:"url",get:function(){var e=St.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},an),t),ht(this.messageId>0&&M("number",e)&&sn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getThreadedMessagesByTimestamp(this,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:e.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:vn(e.parentMessage)})):null}}]),o}(nn),_n=function(t){switch(t){case e.ChannelType.GROUP:return be;case e.ChannelType.OPEN:return Ce;default:return null}},yn=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Te,"/group_channels");case e.ChannelType.OPEN:return"".concat(Te,"/open_channels");default:return null}},kn=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,i=k(n);try{for(i.s();!(a=i.n()).done;){if(a.value===r)return!0}}catch(e){i.e(e)}finally{i.f()}}}return!1},En=function(e,t,n){var r=kn(e.mentionType,e.mentionedUserIds,n),a=kn(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},bn=function(t){i(s,t);var r=p(s);function s(t){var a,i,o;n(this,s);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"FILE",ackRequired:!0,payload:J({channel_url:t.channelUrl,url:t.url,name:null!==(a=t.fileName)&&void 0!==a?a:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return a(s)}(le),wn=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId})))),a.method=x.POST,a.path="".concat(_n(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),a.params=J({message_type:e.MessageType.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:o,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return rn.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Wt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Xt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),a}return a(s)}(Z),Cn=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"FILE",i)).message=new gn(e,i);var l=St.of(e).sdkState;return s.isMentioned=kn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),xn=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o;n(this,r),(i=t.call(this,e,a)).message=new gn(e,a);var u=St.of(e).sdkState;return i.isMentioned=kn(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),u.userId),i.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,i}return a(r)}($);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(cn||(cn={}));var Rn,Tn=function(){function e(t,r){var a=this,i=r.sdkState,s=r.dispatcher,o=r.requestQueue,u=r.onlineDetector,c=r.cacheContext;n(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=i,this._requestQueue=o,this._cacheContext=c,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof ve&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return a(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===ue.CONNECTED||this._connectionState===ue.CONNECTING||this._connectionState===ue.RECONNECTING}},{key:"_sendFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._shouldSendThroughWebSocket){n.next=9;break}return r=new bn(Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Cn),s=i.message,n.abrupt("return",s);case 9:return o=new wn(Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),n.next=12,this._requestQueue.send(o);case 12:return u=n.sent,c=u.as(xn),l=c.message,n.abrupt("return",l);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"_resolveMessageQueue",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=this._queueMap.get(e.url))){t.next=57;break}if(n.isResolving){t.next=56;break}n.isResolving=!0,r=[],a=!0,i=k(n.messageQueue),t.prev=7,i.s();case 9:if((s=i.n()).done){t.next=39;break}o=s.value,t.t0=o.state,t.next=t.t0===cn.PENDING||t.t0===cn.UPLOADING?14:t.t0===cn.UPLOADED?17:t.t0===cn.FAILED?35:37;break;case 14:return a=!1,r.push(o),t.abrupt("break",37);case 17:if(!a){t.next=33;break}return t.prev=18,o.state=cn.SENDING,t.next=22,this._sendFileMessage(e,o);case 22:return u=t.sent,o.deferred.resolve(u),t.next=26,Fe(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),o.deferred.reject(t.t1);case 31:t.next=34;break;case 33:r.push(o);case 34:return t.abrupt("break",37);case 35:return o.deferred.reject(o.error.code===b.REQUEST_CANCELED?T.fileUploadCanceled:o.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(c=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,!c){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:n.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),t,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p,f,v;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._queueMap.get(e.url),!(r=n.messageQueue.find((function(e){return e.state===cn.PENDING})))){t.next=49;break}if(!L(r.params.file)){t.next=45;break}if(!(n.uploadQueue.length<6)){t.next=43;break}return r.state=cn.UPLOADING,n.uploadQueue.push(r),t.next=9,this._onlineDetector.isOnline();case 9:if(!t.sent){t.next=37;break}return t.prev=11,a=new Ft({file:r.params.file,channelUrl:e.url,thumbnailSizes:r.params.thumbnailSizes,requestId:r.requestId}),t.next=15,this._requestQueue.send(a);case 15:i=t.sent,s=i.as(Gt),o=s.url,u=s.fileSize,c=void 0===u?r.params.fileSize:u,l=s.thumbnailSizes,h=void 0===l?r.params.thumbnailSizes:l,d=s.requireAuth,p=void 0!==d&&d,r.params.fileUrl=o,r.params.fileSize=c,r.params.thumbnailSizes=h,r.params.requireAuth=p,r.requireAuth=p,r.state=cn.UPLOADED,t.next=29;break;case 25:t.prev=25,t.t0=t.catch(11),t.t0.code===b.REQUEST_FAILED?r.error=new T({code:b.NETWORK_ERROR,message:"Failed to upload a file."}):r.error=t.t0,r.state=cn.FAILED;case 29:return t.prev=29,(f=n.uploadQueue.findIndex((function(e){return e.requestId===r.requestId})))>=0&&(n.uploadQueue.splice(f,1),this._uploadNextPendingItem(e)),t.next=34,this._resolveMessageQueue(e);case 34:return t.finish(29);case 35:t.next=43;break;case 37:return r.state=cn.FAILED,r.error=T.connectionRequired,(v=n.uploadQueue.findIndex((function(e){return e.requestId===r.requestId})))>=0&&(n.uploadQueue.splice(v,1),this._uploadNextPendingItem(e)),t.next=43,this._resolveMessageQueue(e);case 43:t.next=49;break;case 45:return r.params.thumbnailSizes=[],r.state=cn.UPLOADED,t.next=49,this._resolveMessageQueue(e);case 49:case"end":return t.stop()}}),t,this,[[11,25,29,35]])})))}},{key:"request",value:function(e,t,n){var r,a,i;return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=new de,L(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:cn.PENDING,deferred:o,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),s.abrupt("return",o.promise);case 7:case"end":return s.stop()}}),s,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:g(n.messageQueue),i=k(a);try{for(i.s();!(r=i.n()).done;){var s=r.value;if(s)switch(s.state){case cn.PENDING:s.state=cn.FAILED,s.error=T.requestCanceled,this._resolveMessageQueue(e);break;case cn.UPLOADING:this._requestQueue.cancel(s.requestId)}}}catch(e){i.e(e)}finally{i.f()}}}}]),e}(),In={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Sn=function(t){return M("number",t.prevResultSize)&&M("number",t.nextResultSize)&&M("boolean",t.isInclusive)&&M("boolean",t.reverse)&&M("string",t.messageTypeFilter)&&A(e.MessageTypeFilter,t.messageTypeFilter)&&O("string",t.customTypesFilter,!0)&&O("string",t.senderUserIdsFilter,!0)&&A(e.ReplyType,t.replyType)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeReactions)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)&&M("boolean",t.showSubchannelMessagesOnly)},Nn={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Mn=function(t){return A(e.ReplyType,t.replyType)&&M("boolean",t.includeReactions)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(Rn=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",Rn.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Rn.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Rn.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Rn.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Rn.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Rn.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Rn.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Rn.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Rn.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Rn.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Rn.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Rn.REQUEST_MESSAGE="REQUEST_MESSAGE",Rn.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Rn.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Rn.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Rn.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Rn.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Rn.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Rn.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Rn.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Rn.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Rn.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Rn.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Rn.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Rn.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var An,Un=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},On=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.messages,s=e.source;return n(this,r),(a=t.call(this)).messages=i,a.source=s,a}return a(r)}(Y),Dn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.messageIds,s=e.source;return n(this,r),(a=t.call(this)).messageIds=i,a.source=s,a}return a(r)}(Y),Ln=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.reqId,s=e.source;return n(this,r),(a=t.call(this)).reqId=i,a.source=s,a}return a(r)}(Y),Pn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.polls,s=e.source;return n(this,r),(a=t.call(this)).polls=i,a.source=s,a}return a(r)}(Y),Fn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.event,s=e.source;return n(this,r),(a=t.call(this)).event=i,a.source=s,a}return a(r)}(Y),Gn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.event,s=e.source;return n(this,r),(a=t.call(this)).event=null,a.source=null,a.event=i,a.source=s,a}return a(r)}(Y),qn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return a(r)}(Z),Hn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=a?mn(e,Object.assign({},a)):null,i}return a(r)}($),jn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,p=e.isInclusive,f=e.reverse,v=e.messageTypeFilter,m=e.customTypesFilter,g=e.senderUserIdsFilter,_=e.replyType,y=e.includeMetaArray,k=e.includeReactions,E=e.parentMessageId,b=e.includeThreadInfo,w=e.includeParentMessageInfo,C=e.showSubchannelMessagesOnly;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages"),a.params=J({is_sdk:!0,prev_limit:h,next_limit:d,include:p,reverse:f,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:m,sender_ids:g,include_reply_type:_,with_sorted_meta_array:y,include_reactions:k,parent_message_id:E,include_thread_info:b,include_parent_message_info:w,show_subchannel_message_only:C,include_poll_details:!0}),a}return a(r)}(Z),Vn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).messages=a.messages.map((function(t){return mn(e,t)})),i}return a(r)}($),Qn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,p=e.includeParentMessageInfo;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:p,include_poll_details:!0},a}return a(r)}(Z),Bn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return mn(e,t)})),i.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),i.hasMore=a.has_more,i.nextToken=a.next,i}return a(r)}($),Kn=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.scheduledMessageId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),a.params={},a}return a(r)}(Z),zn=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=a?mn(e,Object.assign({},a)):null,i}return a(r)}($),Wn={},Yn=function(){function t(e,r){var a=r.sdkState,i=r.dispatcher,s=r.requestQueue,o=r.onlineDetector,u=r.cacheContext;n(this,t),this._iid=e,this._sdkState=a,this._requestQueue=s,this._dispatcher=i,this._cacheContext=u,this.fileMessageQueue=new Tn(e,{sdkState:a,dispatcher:i,requestQueue:s,onlineDetector:o,cacheContext:u}),Wn[e]=this}return a(t,[{key:"buildMessageFromSerializedData",value:function(t){var n=lt(t);switch(n.messageType){case e.MessageType.USER:return new fn(this._iid,fn.payloadify(n));case e.MessageType.FILE:return new gn(this._iid,gn.payloadify(n));case e.MessageType.ADMIN:return new on(this._iid,on.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return J({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){return J({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=lt(e);return new tn(this._iid,tn.payloadify(t))}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new qn(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(Hn),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Kn(e),t.next=3,this._requestQueue.send(n);case 3:return r=t.sent,a=r.as(zn),i=a.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesByMessageId",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new jn(Object.assign(Object.assign({channelType:n,channelUrl:t,token:String(r)},In),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Vn),c=u.messages,this._dispatcher.dispatch(new On({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new jn(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:r},In),a)),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Vn),c=u.messages,this._dispatcher.dispatch(new On({messages:c,source:i})),e.abrupt("return",c);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,o,u,c,l;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=new jn(Object.assign(Object.assign(Object.assign({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},an),r),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),i.next=3,this._requestQueue.send(s);case 3:return o=i.sent,u=o.as(Vn),c=u.messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new On({messages:l,source:a})),i.abrupt("return",{parentMessage:c[0],threadedMessages:l});case 9:case"end":return i.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(t,n,r,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var s,o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new Qn(J(Object.assign(Object.assign({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null},Nn),a))),e.next=3,this._requestQueue.send(s);case 3:return o=e.sent,u=o.as(Bn),c=u.updatedMessages,l=u.deletedMessagesInfo,h=u.hasMore,d=u.nextToken,p=l.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new On({messages:c,source:i})),p.length>0&&this._dispatcher.dispatch(new Dn({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:c,deletedMessageIds:p,hasMore:h,token:d});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Wn[e]}}]),t}(),Jn=function(){function t(){n(this,t),this._onPending=oe,this._onFailed=oe,this._onSucceeded=oe}return a(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),Xn=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e)).threadInfo=null,i.targetMessageId=0,i.channelUrl=null,i.channelType=null;var s=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return s&&M("object",s)&&M("number",o)&&M("string",u)&&M("string",c)&&(i.threadInfo=new Ht(e,s),i.targetMessageId=o,i.channelUrl=u,i.channelType=c),i}return a(r)}(nt),Zn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},$n=function(t){return M("string",t.channelUrl)&&M("string",t.channelType)&&A(e.ChannelType,t.channelType)&&M("number",t.messageId)&&M("boolean",t.includeMetaArray)&&M("boolean",t.includeParentMessageInfo)&&M("boolean",t.includeThreadInfo)},er=function(){function e(t,r){var a;n(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=r.limit)&&void 0!==a?a:20}return a(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return M("number",this.limit)&&this.limit>0}}]),e}(),tr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelCustomType,s=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,p=e.messageTimestampTo,f=e.advancedQuery,v=e.targetFields,m=e.nextToken;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Re,"/messages"),a.params={custom_type:i,query:s,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:p,sort_field:h,advanced_query:f,target_fields:v,after:m},a}return a(r)}(Z),nr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).messages=a.results.map((function(t){return mn(e,t)})),i.hasNext=a.has_next,i.nextToken=a.end_cursor,i.totalCount=a.total_count,i}return a(r)}($);e.MessageSearchOrder=void 0,(An=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",An.TIMESTAMP="ts";var rr,ar,ir,sr=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v;return n(this,o),(i=r.call(this,t,a)).keyword="",i.reverse=!1,i.exactMatch=!1,i.channelUrl="",i.channelCustomType="",i.messageTimestampFrom=null,i.messageTimestampTo=null,i.order=e.MessageSearchOrder.SCORE,i.advancedQuery=!1,i.targetFields=null,i._nextToken="",i.totalCount=-1,i.keyword=a.keyword,i.reverse=null!==(s=a.reverse)&&void 0!==s&&s,i.exactMatch=null!==(u=a.exactMatch)&&void 0!==u&&u,i.channelUrl=null!==(c=a.channelUrl)&&void 0!==c?c:"",i.channelCustomType=null!==(l=a.channelCustomType)&&void 0!==l?l:"",i.messageTimestampFrom=null!==(h=a.messageTimestampFrom)&&void 0!==h?h:null,i.messageTimestampTo=null!==(d=a.messageTimestampTo)&&void 0!==d?d:null,i.order=null!==(p=a.order)&&void 0!==p?p:e.MessageSearchOrder.SCORE,i.advancedQuery=null!==(f=a.advancedQuery)&&void 0!==f&&f,i.targetFields=null!==(v=a.targetFields)&&void 0!==v?v:null,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.keyword)&&this.keyword.length>0&&M("boolean",this.reverse)&&M("boolean",this.exactMatch)&&M("string",this.channelUrl)&&M("string",this.channelCustomType)&&(M("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(M("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&A(e.MessageSearchOrder,this.order)&&M("boolean",this.advancedQuery)&&O("string",this.targetFields,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new tr(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(nr),s=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,e.abrupt("return",s);case 15:return e.abrupt("return",[]);case 18:throw T.queryInProgress;case 19:e.next=22;break;case 21:throw T.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),o}(er),or=function(t){i(o,t);var r=p(o);function o(e,t,a,i){var s;return n(this,o),(s=r.call(this,e,i)).channelUrl=t,s.channelType=a,s}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.channelUrl)&&A(e.ChannelType,this.channelType)}}]),o}(er),ur=function(t){i(o,t);var r=p(o);function o(t,a,i,s){var u,c,l,h,d,p,f,v,m,g,_;return n(this,o),(u=r.call(this,t,a,i,s)).reverse=!1,u.messageTypeFilter=e.MessageTypeFilter.ALL,u.customTypesFilter=null,u.senderUserIdsFilter=null,u.replyType=e.ReplyType.NONE,u.includeMetaArray=!1,u.includeReactions=!1,u.includeParentMessageInfo=!1,u.includeThreadInfo=!1,u.showSubchannelMessagesOnly=!1,u._edge=Number.MAX_SAFE_INTEGER,u.reverse=null!==(c=s.reverse)&&void 0!==c&&c,u.messageTypeFilter=null!==(l=s.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,u.customTypesFilter=null!==(h=s.customTypesFilter)&&void 0!==h?h:null,u.senderUserIdsFilter=null!==(d=s.senderUserIdsFilter)&&void 0!==d?d:null,u.replyType=null!==(p=s.replyType)&&void 0!==p?p:e.ReplyType.NONE,u.includeMetaArray=null!==(f=s.includeMetaArray)&&void 0!==f&&f,u.includeReactions=null!==(v=s.includeReactions)&&void 0!==v&&v,u.includeParentMessageInfo=null!==(m=s.includeParentMessageInfo)&&void 0!==m&&m,u.includeThreadInfo=null!==(g=s.includeThreadInfo)&&void 0!==g&&g,u.showSubchannelMessagesOnly=null!==(_=s.showSubchannelMessagesOnly)&&void 0!==_&&_,u}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.reverse)&&A(e.MessageTypeFilter,this.messageTypeFilter)&&A(e.ReplyType,this.replyType)&&O("string",this.customTypesFilter,!0)&&O("string",this.senderUserIdsFilter,!0)&&M("boolean",this.includeMetaArray)&&M("boolean",this.includeReactions)&&M("boolean",this.includeParentMessageInfo)&&M("boolean",this.includeThreadInfo)&&M("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,t=Yn.of(this._iid),e.next=7,t.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return n=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(g(n.map((function(e){return e.createdAt}))))),this._hasNext=n.length>=this.limit,this._isLoading=!1,e.abrupt("return",n);case 12:return e.abrupt("return",[]);case 15:throw T.queryInProgress;case 16:e.next=19;break;case 18:throw T.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),o}(or),cr={channelUrl:null,scheduledMessageId:0},lr=function(e){return M("string",e.channelUrl)&&M("number",e.scheduledMessageId)},hr=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="message",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Yn(e,{sdkState:n,dispatcher:a,requestQueue:o,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Zn),e),ht($n(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},cr),e),ht(lr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(n));case 3:case"end":return t.stop()}}),t,this)})))}}]),r}(Pt),dr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.title,s=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return n(this,r),(a=t.call(this)).method=x.POST,a.path=Ne,a.params={title:i,options:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return a(r)}(Z),pr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),fr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return a(r)}(Z),vr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),mr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:i,channel_type:s},a}return a(r)}(Z),gr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pollOption=new dn(e,a),i}return a(r)}($),_r=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.timestamp,u=e.token;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/polls/changelogs"),a.params=J({change_ts:o,token:u}),a}return a(r)}(Z),yr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new pn(e,t):null}(e,t)})),i.deletedPollIds=a.deleted.map((function(e){return e})),i.hasMore=a.has_more,i.nextToken=a.next,i}return a(r)}($),kr={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Er=function(e){return M("string",e.title)&&(t=e.optionTexts,O("string",t)&&t.every((function(e){return""!==e.trim()})))&&hn(e.data)&&M("boolean",e.allowUserSuggestion,!0)&&M("boolean",e.allowMultipleVotes,!0)&&M("number",e.closeAt,!0);var t},br={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},wr=function(t){return M("string",t.channelUrl)&&A(e.ChannelType,t.channelType)&&M("number",t.pollId)&&M("number",t.pollOptionId)},Cr={channelUrl:null,channelType:null,pollId:null},xr=function(t){return M("string",t.channelUrl)&&""!==t.channelUrl&&A(e.ChannelType,t.channelType)&&M("number",t.pollId)},Rr={},Tr=function(){function t(e,r){var a=r.sdkState,i=r.dispatcher,s=r.sessionManager,o=r.requestQueue,u=r.logger;n(this,t),this._iid=e,this._sdkState=a,this._sessionManager=s,this._requestQueue=o,this._dispatcher=i,this._logger=u,Rr[e]=this}return a(t,[{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(xr(e)).throw(T.invalidParameters),n=new fr(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(vr),i=a.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"create",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(Er(e)).throw(T.invalidParameters),n=e.data,r=new dr(Object.assign(Object.assign({},e),{data:n})),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(pr),s=i.poll,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(wr(e)).throw(T.invalidParameters),n=new mr(Object.assign({},e)),t.next=4,this._requestQueue.send(n);case 4:return r=t.sent,a=r.as(gr),i=a.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogs",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new _r(J({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(yr),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Pn({polls:u,source:a})),e.abrupt("return",{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Rr[e]}}]),t}(),Ir=a((function e(t,r){n(this,e),this.pollId=0,this.messageId=0,this.pollId=r.poll.id,this.messageId=r.poll.message_id,this._iid=t,this._payload=r})),Sr=a((function e(t){n(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Nr=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.token,u=e.limit;return n(this,r),(a=t.call(this)).method=x.GET,a.path=Ne,a.params={channel_url:i,channel_type:s,token:o,limit:u},a}return a(r)}(Z),Mr=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).polls=(null!==(s=a.polls)&&void 0!==s?s:[]).map((function(t){return new pn(e,t)})),i.token=a.next,i}return a(r)}($),Ar=function(e){i(r,e);var t=p(r);function r(e,a){return n(this,r),t.call(this,e,a.channelUrl,a.channelType,a)}return a(r,[{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Nr(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Mr),s=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(or),Ur=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:i,channel_type:s,token:c,limit:l},a}return a(r)}(Z),Or=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).voters=(null!==(s=a.voters)&&void 0!==s?s:[]).map((function(t){return new pt(e,t)})),i.token=a.next,i}return a(r)}($),Dr=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a.channelUrl,a.channelType,a)).pollId=a.pollId,i.pollOptionId=a.pollOptionId,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&M("number",this.pollId)&&M("number",this.pollOptionId)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Ur(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Or),s=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(or),Lr=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="poll",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Tr(e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},kr),e),ht(Er(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.create(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Cr),e),ht(xr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.get(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getOption",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},br),e),ht(wr(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getOption(n));case 3:case"end":return t.stop()}}),t,this)})))}}]),r}(Pt),Pr={profileImage:null,profileUrl:null,nickname:null},Fr=function(e){return L(e.profileImage,!0)&&M("string",e.profileUrl,!0)&&M("string",e.nickname,!0)},Gr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onSessionExpired=oe,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=oe,this.onSessionRefreshed=oe,this.onSessionClosed=oe}))),qr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onConnected=oe,this.onReconnectStarted=oe,this.onReconnectSucceeded=oe,this.onReconnectFailed=oe,this.onDisconnected=oe}))),Hr=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(a((function e(){n(this,e),this.onFriendsDiscovered=oe,this.onTotalUnreadMessageCountUpdated=oe}))),jr="GroupChannel",Vr=100,Qr="Message";e.GroupChannelListOrder=void 0,(rr=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",rr.CHRONOLOGICAL="chronological",rr.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",rr.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(ar=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",ar.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",ar.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(ir=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",ir.SCHEDULED_AT="scheduled_at";var Br,Kr=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"]}},zr=function(){function t(){n(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return a(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof nn))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof nn&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Br||(Br={}));var Wr,Yr=function(e){switch(e){case Br.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Br.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Jr={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Xr=function(t){return M("string",t.data,!0)&&M("string",t.customType,!0)&&A(e.MentionType,t.mentionType)&&O("string",t.mentionedUserIds,!0)&&O(pt,t.mentionedUsers,!0)&&M("string",t.mentionedMessageTemplate,!0)&&O(Wt,t.metaArrays,!0)&&M("number",t.parentMessageId,!0)&&M("boolean",t.isReplyToChannel)&&A(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&M(Xt,t.appleCriticalAlertOptions,!0)&&M("boolean",t.isPinnedMessage,!0)},Zr=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},$r=Object.assign(Object.assign({},Jr),{message:null,translationTargetLanguages:null,pollId:null}),ea=function(e){var t;return J({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},ta=function(e){return Xr(e)&&M("string",e.message)&&O("string",e.translationTargetLanguages,!0)&&M("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Wr||(Wr={}));var na=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},ra=function(e){return e===Wr.BLOB||e===Wr.FILE},aa=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ia=Object.assign(Object.assign({},Jr),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),sa=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&L(n)&&(e.messageParams.file=n),e.messageParams):J({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=n?n:null===(t=e.messageParams)||void 0===t?void 0:t.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:e.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},oa=function(e){return Xr(e)&&(L(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ua="undefined"!=typeof document&&"undefined"!=typeof navigator;ua&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var ca=ua&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");ua&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),ua&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),ua&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var la,ha,da=ua&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),pa=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)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(la||(la={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(ha||(ha={}));var fa,va={},ma=function(){function e(t){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n(this,e),this._state=la.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],va[t]&&!a.forceCreate||(this.nodeId=pa(),this.key=t,ua&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&r.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,n=t.nodeId,a=t.requestId,i=t.key,s=t.op,o=t.data;if(n!==r.nodeId&&i===r.key)switch(s){case ha.NEWNODE:r._sendSync();break;case ha.CLAIM_HOST:r._sendSync(),r._hostId=n;break;case ha.SYNC_HOST:if(!r.isInSync){r._activationTimeout&&clearTimeout(r._activationTimeout);var u,c=o.currentItemRequestId,l=k(o.queue);try{var h=function(){var e=u.value,t=r._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&r._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:r.key,op:ha.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}r._currentItem=r._queue.find((function(e){return e.requestId===c})),r._completeSync()}break;case ha.REMOVENODE:r._queue=r._queue.filter((function(e){return e.nodeId!==t.nodeId})),r._currentItem&&r._currentItem.nodeId===t.nodeId&&(r._currentItem=null,r._acquire(r._queue[0]));break;case ha.REQUEST_LOCK:r._requestLock(t);break;case ha.ACQUIRE_LOCK:var d=r._queue.find((function(e){return e.requestId===a}));r._acquire(d);break;case ha.RELEASE_LOCK:r._release(a)}})),window.addEventListener("beforeunload",(function(){r._send(ha.REMOVENODE)}))),va[t]=this),va[t]}return a(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==la.DONE}},{key:"_send",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={nodeId:this.nodeId,requestId:null!==(t=null==r?void 0:r.requestId)&&void 0!==t?t:pa(),key:this.key,op:e,data:null!==(n=r.data)&&void 0!==n?n:null,ts:Date.now()};return ua&&window.postMessage(a,"*"),a}},{key:"_acquire",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(ha.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}}},{key:"_requestLock",value: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(ha.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var i in t._queue)if(t._queue[i].ts>r.ts){t._queue.splice(parseInt(i),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(ha.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}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){t._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=la.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(ha.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(ha.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return t=this._send(ha.REQUEST_LOCK),e.next=5,this._requestLock(t);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)}}]),e}(),ga=Object.assign(Object.assign({},$r),{scheduledAt:null}),_a=Object.assign(Object.assign({},Jr),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),ya="UnsentMessage",ka={},Ea=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext;return n(this,r),(i=t.call(this,e))._sdkState=s,i._cacheContext=o,ka[e]=h(i),i._mutex=new ma("unsendmessagecache.lock"),i}return a(r,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(ya)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw T.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof fn?(e.messageParams&&(n.messageParams=Zr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Zr(t)),{scheduledAt:t.scheduledAt})))):e instanceof gn&&(e.messageParams&&(n.messageParams=aa(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},aa(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Yn.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Yn.of(this._iid),r=this._deserialize(e),!e.messageParams){t.next=15;break}if(!(r instanceof fn)){t.next=8;break}a=e.messageParams,r.messageParams=n.buildUserMessageCreateParamsFromSerializedData(a,r),t.next=15;break;case 8:if(!(r instanceof gn)){t.next=15;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!ra(i.fileType)){t.next=14;break}return t.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=t.sent;case 14:r.messageParams=n.buildFileMessageCreateParamsFromSerializedData(i,r);case 15:if(!(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){t.next=28;break}if(!(r instanceof fn)){t.next=21;break}s=e.scheduledInfo.scheduledMessageParams,r.scheduledInfo.scheduledMessageParams=n.buildScheduledUserMessageCreateParamsFromSerializedData(s,r),t.next=28;break;case 21:if(!(r instanceof gn)){t.next=28;break}if(!(o=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof o.fileKey||!ra(o.fileType)){t.next=27;break}return t.next=26,this.collection.getBlob(o.fileKey);case 26:o.file=t.sent;case 27:r.scheduledInfo.scheduledMessageParams=n.buildScheduledFileMessageCreateParamsFromSerializedData(o,r);case 28:return t.abrupt("return",r);case 29:case"end":return t.stop()}}),t,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(n));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,a=void 0===r?new zr:r,i=e.order,s=void 0===i?Br.CHANNEL_LATEST:i,o=e.sendingStatus,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r,i,o,c,h=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return t=Yr(s),r={"/where":function(e){return!!(s!==Br.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&a.match(h._deserialize(e))}},n&&(r.channelUrl=n),u&&(r.sendingStatus=u),i={where:r,index:t,backward:l},e.next=8,this.collection.query(i);case 8:return o=e.sent,e.next=11,o.fetch({});case 11:return c=e.sent,e.abrupt("return",Promise.all(c.map((function(e){return E(h,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new zr;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({filter:t,order:Br.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof gn)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return n=this._serialize(e),t.next=10,this.collection.upsertOne(n);case 10:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=k(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove(a);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof gn)){t.next=17;break}if(!e.messageParams){t.next=9;break}if(!(n=e.messageParams).file||!na(n.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(n.file,e.reqId);case 6:r=t.sent,n.fileKey=r,n.fileType=Wr.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(a=e.scheduledInfo.scheduledMessageParams).file||!na(a.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(a.file,e.reqId);case 14:i=t.sent,a.fileKey=i,a.fileType=Wr.BLOB;case 17:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return ka[e]}}]),r}(nt),ba=function(t,n){return function(r,a){if(1===r)t.clear().then((function(){n.clear().then((function(){(function(t){return E(void 0,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.commitSchema([{collectionName:jr,keyName:"url",index:[Kr(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Kr(e.GroupChannelListOrder.CHRONOLOGICAL),Kr(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Qr,keyName:"messageId",index:[Yr(Br.CHANNEL_LATEST),Yr(Br.NEWEST_CHILD_MESSAGE)]},{collectionName:ya,keyName:"reqId",index:[Yr(Br.CHANNEL_LATEST),Yr(Br.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return n.stop()}}),n)})))})(t).then((function(){return a()})).catch((function(e){return a(e)}))})).catch((function(e){return a(e)}))})).catch((function(e){return a(e)}));else a()}},wa={},Ca=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.sdkState,o=a.cacheContext,u=a.unsentMessageCache;return n(this,r),(i=t.call(this,e))._sdkState=s,i._cacheContext=o,i._unsentMessageCache=u,wa[e]=h(i),i}return a(r,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Qr):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Yn.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(n=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(n));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"fetch",value:function(e){var t=e.channelUrl,n=e.token,r=e.limit,a=void 0===r?Vr:r,i=e.filter,s=void 0===i?new zr:i,o=e.order,u=void 0===o?Br.CHANNEL_LATEST:o,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h,p=e.isPollOnly,f=void 0!==p&&p;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var r,i,o,c,h=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return r=Yr(u),i={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case Br.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new zr;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:Br.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return n=e.map((function(e){return r._serialize(e)})),t.next=6,this.collection.upsertMany(n);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChildMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!((null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),t,this)})))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}n=k(e),t.prev=2,n.s();case 4:if((r=n.n()).done){t.next=10;break}return a=r.value,t.next=8,this.collection.remove("".concat(a));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),n.e(t.t0);case 15:return t.prev=15,n.f(),t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:Yr(Br.CHANNEL_LATEST)});case 3:return n=this._cacheContext.preference,t.next=6,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,n.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"removeUnderOffset",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Yr(Br.CHANNEL_LATEST)});case 3:case"end":return n.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.localCacheEnabled){r.next=6;break}return a=Yr(Br.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var r=s._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:a}),r.next=5,i.count();case 5:return r.abrupt("return",r.sent);case 6:return r.abrupt("return",0);case 7:case"end":return r.stop()}}),r,this)})))}},{key:"saveBlobs",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(e.map((function(e){return E(n,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof gn&&e.messageParams)){t.next=7;break}if(!(n=e.messageParams).file||!na(n.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(n.file,e.reqId);case 5:r=t.sent,n.fileKey=r;case 7:case"end":return t.stop()}}),t,this)})))})));case 2:case"end":return t.stop()}}),t)})))}}],[{key:"of",value:function(e){return wa[e]}}]),r}(nt),xa=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.call(this))._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(h(e)),e}return a(r,[{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState}},{key:"start",value:function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})}},{key:"stop",value:function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})}}]),r}(z),Ra=function(){function e(t){var r=this,a=t.logger,i=t.connectionDelegate,s=void 0===i?null:i;n(this,e),this._onlineWorker=function(){var e;return null===(e=r.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=r.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(r.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(r.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,s&&(this.connectionDelegate=s)}return a(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:x.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),Ta=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.message;return n(this,r),(a=t.call(this)).message=i,a}return a(r)}(Y),Ia={},Sa=function(){function t(e,r){var a=this,i=r.localCacheEnabled,s=r.dispatcher,o=r.sdkState,u=r.logger;n(this,t),Ia[e]=this,this._iid=e,Ia[e]=this,this._localCacheEnabled=i,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=s,this._logger=u,this._sdkState=o,this._localCacheEnabled&&s.on((function(e){if(e instanceof ve)switch(e.stateType){case ue.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case ue.DISCONNECTED:a._isProcessingAutoResend=!1}}))}return a(t,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=k(n);try{for(r.s();!(a=r.n()).done;)0===(i=a.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=b.ACK_TIMEOUT,this._dispatcher.dispatch(new On({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:n=t.sent,r=k(n);try{for(r.s();!(a=r.n()).done;)(i=a.value).errorCode&&D(i.errorCode)&&(s=(new Date).getTime(),o=i.createdAt+2592e5,s<=o?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(o).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new On({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return t.stop()}}),t,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!D(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=Ea.of(this._iid))){t.next=7;break}return t.next=4,n.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),t=this._autoResendQueue[0],this._dispatcher.dispatch(new Ta({message:t})),this._logger.debug("processing auto-resend for message request id: ",t.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Ia[e]}}]),t}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(fa||(fa={}));var Na,Ma=function(){function e(t){n(this,e),this.category=t.cat,this.data=t.data}return a(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new pt(e,r),blockee:new pt(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new pt(e,t)})):[]}}}]),e}(),Aa=function(e){i(r,e);var t=p(r);function r(e,a){var i,s=a.userId;return n(this,r),(i=t.call(this))._iid=e,i.userId=s,i}return a(r)}(Y),Ua=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"USEV",i)).event=new Ma(i),s}return a(r)}(se),Oa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.nickname,o=void 0===s?null:s,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,p=void 0===d?null:d;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i)),a.params=J({nickname:o,profile_url:c,profile_file:h,preferred_languages:p}),a}return a(r)}(Z),Da=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).user=null,i.user=new pt(e,Object.assign({},a)),i}return a(r)}($),La=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/apns"),a.params={apns_device_token:s,always_push:!0},a}return a(r)}(Z),Pa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/gcm"),a.params={gcm_reg_token:s,always_push:!0},a}return a(r)}(Z),Fa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/apns/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Ga=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/gcm/").concat(encodeURIComponent(s)),a}return a(r)}(Z),qa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/apns"),a}return a(r)}(Z),Ha=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/gcm"),a}return a(r)}(Z),ja=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.type,o=e.token,u=e.ts;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/").concat(encodeURIComponent(s),"/device_tokens"),a.params={created_ts:u,token:o},a}return a(r)}(Z),Va=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),(i=r.call(this,t,a)).pushTokens={type:a.type?e.PushTokenType[a.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:a.device_tokens,hasMore:a.has_more,token:a.token},i}return a(s)}($),Qa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a}return a(r)}(Z),Ba=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return a(r)}($),Ka=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.willAutoAccept;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/channel_invitation_preference"),a.params={auto_accept:s},a}return a(r)}(Z),za=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).autoAccept=a.auto_accept,i}return a(r)}($),Wa=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),Ya=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return a(r)}($),Ja=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={do_not_disturb:s,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return a(r)}(Z),Xa=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},i}return a(r)}($),Za=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),$a=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return a(r)}($),ei=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.snoozeOn,o=e.startTs,u=e.endTs;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={snooze_enabled:s,snooze_start_ts:o,snooze_end_ts:u},a}return a(r)}(Z),ti=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(i.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(i.snoozePeriod.endTs=a.snooze_end_ts),i}return a(r)}($),ni=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.blockedUserId;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/block"),a.params={target_id:s},a}return a(r)}(Z),ri=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.unblockedUserId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/block/").concat(encodeURIComponent(s)),a}return a(r)}(Z),ai=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a}return a(r)}(Z),ii=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return a(r)}($),si=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.pushTriggerOption;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference"),a.params={push_trigger_option:s},a}return a(r)}(Z),oi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i}return a(r)}($),ui=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/template"),a}return a(r)}(Z),ci=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).name=a.name,i}return a(r)}($),li=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.templateName;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push/template"),a.params={name:s},a}return a(r)}(Z),hi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).name=a.name,i}return a(r)}($),di=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.token;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friends/changelogs"),a.params={token:s},a}return a(r)}(Z),pi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new pt(e,t)})),updatedUsers:a.updated.map((function(t){return new pt(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},i}return a(r)}($),fi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.discoveries;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discoveries:s.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return a(r)}(Z),vi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,i}return a(r)}($),mi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.discoveryKeys;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friend_discoveries"),a.params={friend_discovery_keys:s},a}return a(r)}(Z),gi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.userIds;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return a(r)}(Z),_i=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new pt(e,t)})),i}return a(r)}($),yi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.userIds;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friends"),a.params={user_ids:s},a}return a(r)}(Z),ki=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(i,"/allow_friend_discovery"),a.params={},a}return a(r)}(Z),Ei=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,i}return a(r)}($),bi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.allowFriendDiscovery;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(i,"/allow_friend_discovery"),a.params={allow_friend_discovery:s},a}return a(r)}(Z),wi=a((function e(t){n(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),Ci=a((function e(t){var r,a,i;n(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(r=t.id)&&void 0!==r?r:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(i=t.url)&&void 0!==i?i:"",this.emojis=t.emojis?t.emojis.map((function(e){return new wi(e)})):[]})),xi=a((function e(t){n(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Ci(e)})):[]})),Ri=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.call(this)).method=x.GET,e.path=Se,e}return a(r)}(Z),Ti=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emojiContainer=new xi(a),i}return a(r)}($),Ii=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.categoryId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Se,"/").concat(i),a}return a(r)}(Z),Si=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emojiCategory=new Ci(a),i}return a(r)}($),Ni=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.key;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Ie,"/").concat(i),a}return a(r)}(Z),Mi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).emoji=new wi(a),i}return a(r)}($),Ai=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.limit,s=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return n(this,r),(a=t.call(this)).method=x.GET,a.path=ke,a.params=J({limit:i,token:s,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return a(r)}(Z),Ui=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new pt(e,t)})),i.next=a.next,i}return a(r)}($),Oi=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u;return n(this,r),(i=t.call(this,e,a)).userIdsFilter=null,i.metaDataKeyFilter=null,i.metaDataValuesFilter=null,i.nicknameStartsWithFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i.metaDataKeyFilter=null!==(o=a.metaDataKeyFilter)&&void 0!==o?o:null,i.metaDataValuesFilter=null!==(u=a.metaDataValuesFilter)&&void 0!==u?u:null,i.nicknameStartsWithFilter=a.nicknameStartsWithFilter||null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&O("string",this.userIdsFilter,!0)&&M("string",this.metaDataKeyFilter,!0)&&O("string",this.metaDataValuesFilter,!0)&&M("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Ai(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Ui),s=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(er),Di=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.limit,o=e.token,u=e.userIdsFilter;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(i,"/block"),a.params=J({limit:s,token:o,user_ids:u}),a}return a(r)}(Z),Li=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).users=a.users.map((function(t){return new pt(e,t)})),i.next=a.next,i}return a(r)}($),Pi=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).userIdsFilter=null,i.userIdsFilter=null!==(s=a.userIdsFilter)&&void 0!==s?s:null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&O("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Di(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Li),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(er),Fi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.limit,o=e.token;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/friends"),a.params={limit:s,token:o},a}return a(r)}(Z),Gi=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).hasMore=a.has_more,i.users=a.users.map((function(t){return new pt(e,t)})),i.next=a.next,i}return a(r)}($),qi=function(e){i(r,e);var t=p(r);function r(){return n(this,r),t.apply(this,arguments)}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Fi(Object.assign(Object.assign({},this),{userId:n.userId,token:this._token})),e.next=8,r.send(a);case 8:return i=e.sent,s=i.as(Gi),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(er),Hi={},ji=function(){function e(t){var r=t.dbname,a=t.itemSizeLimit,i=void 0===a?1048576:a,s=t.cacheLimit,o=void 0===s?256:s,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,p=void 0===d?11:d,f=t.transactionApplyDelay,v=void 0===f?200:f,m=t.disableLogger,g=void 0!==m&&m;return n(this,e),Hi[r]||(this.itemSizeLimit=i,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=p,this.transactionApplyDelay=v,this.disableLogger=g,Hi[r]=this),Hi[r]}return a(e,null,[{key:"get",value:function(e){return Hi[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"}(Na||(Na={}));var Vi,Qi=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.code,s=void 0===i?Na.UNKNOWN_ERROR:i,o=e.message,u=void 0===o?"Unknown error occurred.":o;return n(this,r),(a=t.call(this,u)).code=s,Object.setPrototypeOf(h(a),r.prototype),a}return a(r,null,[{key:"storeNotDefined",get:function(){return new r({code:Na.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new r({code:Na.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new r({code:Na.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new r({code:Na.STORE_IS_FULL,message:"Store is full."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new r({code:Na.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new r({code:Na.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new r({code:Na.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new r({code:Na.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new r({code:Na.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new r({code:Na.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new r({code:Na.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new r({code:Na.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new r({code:Na.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new r({code:Na.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new r({code:Na.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new r({code:Na.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new r({code:Na.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new r({code:Na.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new r({code:Na.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new r({code:Na.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new r({code:Na.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new r({code:Na.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new r({code:Na.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new r({code:Na.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),r}(l(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Vi||(Vi={}));var Bi,Ki=function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===t(n)&&null!==n){if(r.has(n))throw Qi.circularReferenceFound;r.set(n,!0);var a=null;if(Array.isArray(n))a=n.map((function(t){return e(t,r)}));else if(n instanceof RegExp)a=n;else if(n instanceof Date)a=n;else for(var i in a={},n)a[i]=e(n[i],r);return r.delete(n),a}return n},zi=function(e,n){if(null==n)return 1;if(null==e)return-1;if(t(e)!==t(n))throw Qi.compareTypesNotMatch;var r=0;switch(t(e)){case"boolean":case"number":r=e-n;break;case"string":r=e.localeCompare(n)}return r},Wi=function(e,t){for(var n=0,r=0;r>>0)%t},Yi=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Ji=function e(n,r){if(!r)return!1;if("function"!=typeof n){for(var a in n){if(["/and","&&"].includes(a)){if(n[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(n[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,n[a])(r))return!1}else{var i=a;if("object"===t(n[i])){var s=n[i];for(var o in s)switch(o){case"/eq":case"=":if(r[i]!==s[o])return!1;break;case"/neq":case"!=":if(r[i]===s[o])return!1;break;case"/gt":case">":var u=r[i],c=s[o];if(!(zi(u,c)>0))return!1;break;case"/gte":case">=":var l=r[i],h=s[o];if(!(zi(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[i],p=s[o];if(!(zi(d,p)<0))return!1;break;case"/lte":case"<=":var f=r[i],v=s[o];if(!(zi(f,v)<=0))return!1;break;case"/in":var m=r[i];if(!s[o].includes(m))return!1;break;case"/nin":var g=r[i];if(s[o].includes(g))return!1;break;case"/contain":var _=r[i],y=s[o];if(!_.includes(y))return!1;break;case"/regex":var k=r[i];if(!s[o].test(k))return!1;break;case"/where":var E=r[i];if(!(0,s[o])(E))return!1}}else if("function"==typeof n[i]){if(!n[i](r[i]))return!1}else if(n[i]!==r[i])return!1}}return!0}return n(r)},Xi=function(){},Zi=function(){return Promise.resolve()},$i=function(e){return e},es=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Bi||(Bi={}));var ts,ns,rs,as=function(){function e(t){var r=t.initialPrevValue,a=void 0===r?null:r,i=t.initialNextValue,s=void 0===i?null:i,o=t.iterator,u=t.map,c=void 0===u?$i:u,l=t.backward,h=void 0===l?Zi:l,d=t.forward,p=void 0===d?Zi:d,f=t.complete,v=void 0===f?Xi:f;n(this,e),this._prevValue=a,this._nextValue=s,this._error=null,this._map=c,this._backward=h,this._forward=p,this._iterator=o,this._complete=v}return a(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,t=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,t=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=t,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),is=function(){function e(t){var r=t.condition,a=void 0===r?{}:r,i=t.backward,s=void 0!==i&&i,o=t.blockManager,u=t.indexer;n(this,e),this.condition=a,this.backward=s,this._blockManager=o,this._indexer=u}return a(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,n=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"===t(this.condition[s])){var u=o>0?r:n;for(var c in this.condition[s])if(u.includes(c))for(var l=a;l>=0;l--)if(o*zi(this._indexer.origin[l].columnValues[i],this.condition[s][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*zi(this._indexer.origin[h].columnValues[i],this.condition[s])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=function(){var a=0;if("function"!=typeof e.condition)for(var i=function(i){var s=e._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),e.condition[s])if("object"===t(e.condition[s]))Object.keys(e.condition[s]).forEach((function(t){if((o>0?n:r).includes(t))for(var u=a;u=0){a=u;break}}));else for(var u=a;u=0){a=u;break}},s=0;s0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Math.max(e.offset||0,0),0!==(r="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){t.next=6;break}return t.abrupt("return",[]);case 6:if(!(r<0)){t.next=8;break}throw Qi.collectionQueryNotValid;case 8:return t.prev=8,a=[],t.next=12,this._mutex.lock();case 12:return t.next=14,this._iterator.each((function(e){return E(i,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===n?(a.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(ds(e,t)).concat(n,".").concat(r)},fs=function(){function e(t){var r=t.dbname,a=t.collectionName,i=t.store;n(this,e),this.dbname=r,this.collectionName=a,this.store=i}return a(e,[{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(n=t.sent)){t.next=19;break}if(r=n.data,a=n.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(r);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,s=[],o=atob(r.split(",")[1]),u=0;u1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,new Promise((function(n){var r=ps(o.dbname,o.collectionName,t),a=new FileReader;a.onload=function(){n({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return r=n.sent,a=r.blobId,i=r.data,s=r.type,n.next=8,this.store.set({key:a,value:{data:i,type:s},generation:1});case 8:return n.abrupt("return",a);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ds(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return n=e.sent,e.next=6,Promise.all(n.filter((function(e){return e.startsWith(t)})).map((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(ts||(ts={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(ns||(ns={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(rs||(rs={}));var vs,ms=[ns.PENDING,ns.VOLATILE],gs={},_s=function(){function e(t){var r=t.dbname,a=t.limit,i=void 0===a?256:a;return n(this,e),gs[r]||(this.dbname=r,this._items=[],this._limit=i,gs[r]=this),gs[r]}return a(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:rs.DEFAULT;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=this.get(t)){r.next=8;break}return r.next=4,e.get(t);case 4:(i=r.sent)&&(a={key:t,value:i,generation:1,state:n===rs.PERSISTENT?ns.PERSISTENT:ns.VOLATILE},this.put(a)),r.next=9;break;case 8:n===rs.PERSISTENT&&(a.state=ns.PERSISTENT);case 9:return r.abrupt("return",a);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rs.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===rs.PERSISTENT&&(r.state=ns.PERSISTENT),t!==rs.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)ms.includes(this._items[t].state)&&ms.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===ns.VOLATILE})),r=n.length-this._limit;if(r>0){var a,i=[],s=k(this._items);try{for(s.s();!(a=s.n()).done;){var o=a.value;o.state===ns.VOLATILE&&r>0?r--:i.push(o)}}catch(e){s.e(e)}finally{s.f()}this._items=i}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==ns.VOLATILE}))}}],[{key:"get",value:function(e){return gs[e]}}]),e}(),ys=function(){function e(t){var r=t.dbname,a=t.collectionName,i=t.store;n(this,e),this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=r,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(us(e,t),"/trans.metadata")}(r,a),this.recordsetKey=function(e,t){return"".concat(us(e,t),"/trans.recordset")}(r,a),this._store=i}return a(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(n=t.t0).push.apply(n,g(e)),t.abrupt("return",this._reduceRecordSet(n));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],i=[],s=a.requests.length-1;s>=0;s--){var o=a.requests[s],u=o.data;n[u.key]||(i.unshift(o),n[u.key]=!0)}i.length>0&&(a.requests=i,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=_s.get(this.dbname),a=t.generation,i=t.requests,s=null,n.prev=3,n.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:a})})));case 6:for(o=n.sent,u=0;u1&&void 0!==arguments[1]?arguments[1]:null;this._requests.push({data:e,options:t});var n=_s.get(this.dbname);n.put(Object.assign({state:ns.PENDING,generation:this.generation},e))}},{key:"requestMultipleWrite",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=_s.get(this.dbname),a=k(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;this._requests.push({data:i,options:n}),r.put(Object.assign({state:ns.PENDING,generation:this.generation},i))}}catch(e){a.e(e)}finally{a.f()}}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:_s.get(this.dbname).clearByCondition((function(e){return e.state===ns.PENDING})),this._requests=[];case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h,d,p,f,v=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((t=this._requests).length>0)){e.next=20;break}for(n=[],r={},a=t.length-1;a>=0;a--)i=t[a],s=i.data,r[s.key]||(r[s.key]=!0,n.unshift(i));return o={generation:this.generation,requests:n},e.next=8,this._getReducedRecordset([o]);case 8:return u=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:u,generation:this.generation});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata,generation:1});case 14:for(c=_s.get(this.dbname),l=0;l1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return hs(this.dbname,this.collectionName,t,"".concat(Es(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})))}},{key:"_findBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=_s.get(this.dbname),r=this.metadata.blockLevel;case 2:if(!(r>0)){t.next=15;break}return a=this.createBlockId(e,r),t.next=6,n.find(this._store,a);case 6:if(!(i=t.sent)){t.next=12;break}if(s=ks.createFromCacheItem(i),!s.getItemByKey(e)){t.next=12;break}return t.abrupt("return",s);case 12:r--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),t,this)})))}},{key:"getFromBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return n=t.sent,t.abrupt("return",n?n.getItemByKey(e):null);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"putToBlock",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=ji.get(this.dbname),a=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/r.itemSizeLimit),s=_s.get(this.dbname),n.next=6,s.find(this._store,a);case 6:if(o=n.sent,!(u=o?ks.createFromCacheItem(o):new ks({blockId:a,keyName:this.keyName,items:[],limit:i})).add(t)){n.next=11;break}return this._transaction.requestWrite({key:u.blockId,value:u.serialize()}),n.abrupt("return",!0);case 11:return n.abrupt("return",!1);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"removeFromBlock",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(n=t.sent)){t.next=7;break}if(!n.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:n.blockId,value:n.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"clearAllBlocks",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ls(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return n=e.sent,r=n.filter((function(e){return e.startsWith(t)})),e.next=7,this._store.removeMany(r);case 7:return e.next=9,this._transaction.clear();case 9:_s.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(t)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),ws={},Cs=function(){function e(t){var r=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.fields,u=t.transaction,c=t.store;n(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(us(e,t),"/index.").concat(n)}(a,i,o.join(">"));return ws[l]||(this.dbname=a,this.collectionName=i,this.keyName=s,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(ts.COMMIT,this.indexerKey,(function(){return r.commit()})),this._transaction.on(ts.ERROR,this.indexerKey,(function(){return r.abort()}))),ws[l]}return a(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=m(this.indexOf(n),2),a=r[0];if(r[1]){var i=this._table[a].keys.indexOf(t);if(i>-1)return this._table[a].keys.splice(i,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var n,r,a,i=[],s=k(this.fields);try{for(s.s();!(n=s.n()).done;){var o=n.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=t(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Qi.indexTypesNotMatch;i.push(e[o])}}catch(e){s.e(e)}finally{s.f()}return i}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=zi(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=_s.get(this.dbname),e.next=3,t.find(this._store,this.indexerKey,rs.PERSISTENT);case 3:if(n=e.sent){e.next=34;break}return r=ls(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:a=e.sent,i=k(a),e.prev=10,i.s();case 12:if((s=i.n()).done){e.next=23;break}if(!(o=s.value).startsWith(r)){e.next=21;break}return e.next=17,t.find(this._store,o,rs.NO_CACHE);case 17:u=e.sent,c=ks.createFromCacheItem(u),l=k(c.items);try{for(l.s();!(h=l.n()).done;)d=h.value,this._addItem(d)}catch(e){l.e(e)}finally{l.f()}case 21:e.next=12;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(10),i.e(e.t0);case 28:return e.prev=28,i.f(),e.finish(28);case 31:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=36;break;case 34:this._origin=n.value,this._table=Ki(this._origin);case 36:ws[this.indexerKey]=this;case 37:case"end":return e.stop()}}),e,this,[[10,25,28,31]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _s.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete ws[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeItem",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Ki(this._origin)}},{key:"abort",value:function(){this._table=Ki(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in ws)delete ws[e]}}]),e}(),xs=function(){function e(t){var r=this,a=t.dbname,i=t.collectionName,s=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;n(this,e),this._state=Vi.INIT,this._metadata=null,this._indexers=[],this.dbname=a,this.name=i,this.keyName=s,this.indexes=[[s]].concat(g(u.filter((function(e){return Cs.createKey(e)!==r.keyName})))),this._keyHash=o,this._store=c,this._mutex=new ma(function(e,t){return"".concat(us(e,t),".lock")}(a,i)),this._blobContainer=new fs({dbname:a,collectionName:i,store:c}),this._transaction=new ys({dbname:a,collectionName:i,store:c})}return a(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Vi.READY}},{key:"init",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,n=ji.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return r=t.sent,this._metadata=r||{keyName:this.keyName,blockLevel:1,blockHashBase:n.blockHashBase,blockHashMultiplier:n.blockHashMultiplier,blockHashConstant:n.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new bs({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),a=g(this.indexes),i=[],s=a.map((function(e){return Cs.createKey(e)})),o=r?r.indexes.map((function(e){return Cs.createKey(e)})):[],u=k(o);try{for(u.s();!(c=u.n()).done;)l=c.value,s.includes(l)||i.push(Cs.parseKey(l))}catch(e){u.e(e)}finally{u.f()}return(h=[]).push.apply(h,g(a.map((function(e){var t=new Cs({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),h.push.apply(h,g(i.map((function(e){return new Cs({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(h);case 22:return t.next=24,this._transaction.commit();case 24:if(s.sort().join(",")===o.sort().join(",")){t.next=29;break}return d=cs(this.dbname,this.name),this._metadata.indexes=a,t.next=29,this._store.set({key:d,value:this._metadata,generation:1});case 29:this._state=Vi.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),t,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Vi.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=Cs.createKey(e),r=k(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===Cs.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"_upgradeBlockLevel",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=cs(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:t,value:this._metadata,generation:1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:r=k(this._indexers),t.prev=14,r.s();case 16:if((a=r.n()).done){t.next=22;break}return i=a.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),r.e(t.t0);case 27:return t.prev=27,r.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Qi.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),t,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(r=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(n,e);case 13:a=k(this._indexers),t.prev=14,a.s();case 16:if((i=a.n()).done){t.next=22;break}return s=i.value,t.next=20,s.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(n,e);case 34:o=k(this._indexers),t.prev=35,o.s();case 37:if((u=o.n()).done){t.next=46;break}if(0===(c=u.value).diff(c.getColumnValues(r),c.getColumnValues(e))){t.next=44;break}return t.next=42,c.removeItem(r);case 42:return t.next=44,c.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),o.e(t.t1);case 51:return t.prev=51,o.f(),t.finish(51);case 54:case"end":return t.stop()}}),t,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e[this.keyName],t.next=3,this._blockManager.getFromBlock(n);case 3:if(!(r=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(n,e);case 7:a=k(this._indexers),t.prev=8,a.s();case 10:if((i=a.n()).done){t.next=19;break}if(0===(s=i.value).diff(s.getColumnValues(r),s.getColumnValues(e))){t.next=17;break}return t.next=15,s.removeItem(r);case 15:return t.next=17,s.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),a.e(t.t0);case 24:return t.prev=24,a.f(),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(n=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:r=k(this._indexers),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return i=a.value,t.next=13,i.removeItem(n);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:case"end":return t.stop()}}),t,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:t=k(this._indexers),e.prev=3,t.s();case 5:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=9,r.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return n=t.sent,this._mutex.unlock(),t.abrupt("return",Ki(n));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Qi.collectionNotReady;case 18:case"end":return t.stop()}}),t,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.isReady?new ss({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null}},{key:"insertOne",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Qi.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Ki(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Qi.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Qi.collectionKeyNotGiven;case 6:n=k(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestInsert(Ki(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Qi.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Qi.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Ki(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Qi.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Qi.collectionKeyNotGiven;case 6:n=k(e),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return a=r.value,t.next=13,this._requestUpsert(Ki(a));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Qi.collectionNotReady;case 38:case"end":return t.stop()}}),t,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Qi.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Ki(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Qi.collectionNotReady;case 23:case"end":return t.stop()}}),t,this,[[3,14]])})))}},{key:"updateIf",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h,d,p,f=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.isReady){n.next=31;break}return n.next=3,this._mutex.lock();case 3:return n.prev=3,r=e.where,a=void 0===r?{}:r,i=e.index,s=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],l=new is({condition:a,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(s)}),n.next=9,l.each((function(e){return E(f,void 0,void 0,regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.error){n.next=4;break}if(e.hasNext){if(r=e.nextValue,Ji(a,r)&&t.set){if("function"!=typeof t.set)for(i in t.set)r[i]=t.set[i];else t.set(r);c.push(r)}e.next()}else e.stop();n.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return n.stop()}}),n)})))}));case 9:h=0,d=c;case 10:if(!(h1&&void 0!==arguments[1]?arguments[1]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._blobContainer.save(e,t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeBlob",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.remove(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"removeAllBlobs",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blobContainer.clear();case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"metadataOf",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=cs(e,t),r.next=3,n.get(a);case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}}),r)})))}}]),e}(),Rs=function(){function e(t){var r,a,i;n(this,e),this.encryption=null!==(r=t.encryption)&&void 0!==r?r:H,this.itemSizeLimit=null!==(a=t.itemSizeLimit)&&void 0!==a?a:4194304,this.metadataBuffer=null!==(i=t.metadataBuffer)&&void 0!==i?i:256}return a(e,[{key:"_getRawKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return g(Array(e).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),i=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(i).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:i}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=0,e.next=3,this._getAllRawKeys();case 3:n=e.sent,r=k(n),e.prev=5,r.s();case 7:if((a=r.n()).done){e.next=15;break}return i=a.value,e.next=11,this._getRaw(i);case 11:(s=e.sent)&&(t+=JSON.stringify(s).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=21;break}if(t.prev=5,a=r.data,!((null==(i=r.metadata)?void 0:i.shards)>1)){t.next=13;break}return t.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(t){return E(o,void 0,void 0,regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t>0)){n.next=10;break}return r=this._getRawKey(e,".".concat(t)),n.next=4,this._getRaw(r);case 4:if(i=n.sent){n.next=7;break}throw Qi.storeBrokenIntegrity;case 7:return n.abrupt("return",i.data);case 10:return n.abrupt("return",a);case 11:case"end":return n.stop()}}),n,this)})))})));case 10:t.t0=t.sent,t.next=14;break;case 13:t.t0=[a];case 14:return s=t.t0,t.abrupt("return",this.encryption.decrypt(JSON.parse(s.join(""))));case 18:return t.prev=18,t.t1=t.catch(5),t.abrupt("return",null);case 21:return t.abrupt("return",null);case 22:case"end":return t.stop()}}),t,this,[[5,18]])})))}},{key:"set",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._shardify(e),t.next=3,this._setRaw(n);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setRaw((n=[]).concat.apply(n,g(e.map((function(e){return r._shardify(e)})))));case 2:return t.abrupt("return",e.map((function(e){return e.value})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getRawKey(e,".0"),t.next=3,this._getRaw(n);case 3:if(!(r=t.sent)){t.next=9;break}return a=r.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this)})))}},{key:"removeMany",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],r=k(e),t.prev=2,i=regeneratorRuntime.mark((function e(){var t,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.value,r=s._getRawKey(t,".0"),e.next=4,s._getRaw(r);case 4:(i=e.sent)&&(o=i.metadata,n.push.apply(n,g(s._generateShardPostfixArray(null==o?void 0:o.shards).map((function(e){return s._getRawKey(t,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),r.s();case 5:if((a=r.n()).done){t.next=9;break}return t.delegateYield(i(),"t0",7);case 7:t.next=5;break;case 9:t.next=14;break;case 11:t.prev=11,t.t1=t.catch(2),r.e(t.t1);case 14:return t.prev=14,r.f(),t.finish(14);case 17:if(!(n.length>0)){t.next=20;break}return t.next=20,this._removeRaw(n);case 20:return t.abrupt("return",e);case 21:case"end":return t.stop()}}),t,this,[[2,11,14,17]])})))}}]),e}(),Ts=4194304,Is={},Ss=function(e){i(r,e);var t=p(r);function r(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,r),e=t.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:Ts}));var s=i.delay,o=void 0===s?1:s;return e.delay=o,e.observer={},e}return a(r,[{key:"rawData",get:function(){return Is[this.dbname]},set:function(e){Is[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Is[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Is[this.dbname]));case 4:throw Qi.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Is[this.dbname]){t.next=6;break}return t.next=3,Yi(this.delay);case 3:return t.abrupt("return",Is[this.dbname][e]?Object.assign({key:e},Is[this.dbname][e]):null);case 6:throw Qi.storeNotAvailable;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Is[this.dbname]){t.next=7;break}return t.next=3,Yi(this.delay);case 3:n=k(e);try{for(n.s();!(r=n.n()).done;)a=r.value,i=a.key,s=a.data,o=a.metadata,Is[this.dbname][i]=Object.freeze({data:s,metadata:o})}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Qi.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Is[this.dbname]){t.next=7;break}return t.next=3,Yi(this.delay);case 3:n=k(e);try{for(n.s();!(r=n.n()).done;)a=r.value,Is[this.dbname][a]&&delete Is[this.dbname][a]}catch(e){n.e(e)}finally{n.f()}t.next=8;break;case 7:throw Qi.storeNotAvailable;case 8:case"end":return t.stop()}}),t,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"isAvailable",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 1:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,Is[this.dbname]={};case 2:case"end":return t.stop()}}),t,this)})))}},{key:"set",value:function(e){var t=this,n=Object.create(null,{set:{get:function(){return v(s(r.prototype),"set",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.observer[e.key]||"function"!=typeof this.observer[e.key].set){t.next=4;break}if(!(r=this.observer[e.key].set())){t.next=4;break}throw r;case 4:return t.abrupt("return",n.set.call(this,e));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"setMany",value:function(e){var t=this,n=Object.create(null,{setMany:{get:function(){return v(s(r.prototype),"setMany",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=k(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=11;break}if(i=a.value,!this.observer[i.key]||"function"!=typeof this.observer[i.key].set){t.next=9;break}if(!(s=this.observer[i.key].set())){t.next=9;break}throw s;case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),r.e(t.t0);case 16:return t.prev=16,r.f(),t.finish(16);case 19:return t.abrupt("return",n.setMany.call(this,e));case 20:case"end":return t.stop()}}),t,this,[[1,13,16,19]])})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Yi(this.delay);case 2:Is[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),r}(Rs),Ns=104857600,Ms="NestDBStore",As=function(e){i(r,e);var t=p(r);function r(){var e,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),(e=t.call(this,Object.assign(Object.assign({},i),{itemSizeLimit:null!==(a=i.itemSizeLimit)&&void 0!==a?a:Ns})))._storeName=Ms,e._window="undefined"!=typeof window?window:null,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:null,e}return a(r,[{key:"_getObjectStore",value:function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,n){var r=t._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,r){var a=n._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))}},{key:"_setRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,r){var a=n.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){r("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"_removeRaw",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,r){var a=n.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return r(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"isAvailable",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(t="undefined"!=typeof window?window:null)?void 0:t.indexedDB)||(null==t?void 0:t.mozIndexedDB)||(null==t?void 0:t.webkitIndexedDB)||(null==t?void 0:t.msIndexedDB))){e.next=15;break}return e.prev=2,this._indexedDb=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,n="undefined"!=typeof document&&"undefined"!=typeof navigator,r=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),a=navigator.userAgent&&navigator.userAgent.includes("Edge/"),e.next=9,new Promise((function(e,s){if(n)if(r){var o=i._indexedDb.open("_testMozilla");o.onerror=function(){return s("Private browsing mode.")},o.onsuccess=function(){return e()}}else a?(t.PointerEvent||t.MSPointerEvent)&&s("Private browsing mode."):e()}));case 9:return e.abrupt("return",!0);case 12:return e.prev=12,e.t0=e.catch(2),e.abrupt("return",!1);case 15:return e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,this,[[2,12]])})))}},{key:"init",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,n=new Promise((function(e,t){if(r._window&&ua)if(ca){var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Qi.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}else da?r._window.indexedDB||!r._window.PointerEvent&&!r._window.MSPointerEvent||t(Qi.storeNotAvailableInPrivateBrowsing):e();else t(Qi.storeNotAvailable)})),t.next=4,n;case 4:return t.next=6,new Promise((function(t,n){var a=r._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(Ms,{keyPath:"key"})})),a.addEventListener("success",(function(e){return t(e.target.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 6:this._database=t.sent;case 7:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,n){var r=t._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),r}(Rs),Us=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.AsyncStorage,s=e.itemSizeLimit,o=void 0===s?6291456:s,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(i.mutedUsers=o.map((function(t){return new js(e,t)}))),i}return a(r)}($),eo=function(e){i(r,e);var t=p(r);function r(e,a,i,s){return n(this,r),t.call(this,e,a,i,s)}return a(r,[{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Zs(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as($s),s=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(or),to=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=x.GET,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=J({limit:o,token:u}),a}return a(r)}(Z),no=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.bannedUsers=[];var s=a.next,o=a.banned_list;return i.token=s,o&&o.length>0&&(i.bannedUsers=o.map((function(t){return new js(e,t.user)}))),i}return a(r)}($),ro=function(e){i(r,e);var t=p(r);function r(e,a,i,s){return n(this,r),t.call(this,e,a,i,s)}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new to(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(no),s=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),r}(or);e.ReportCategory=void 0,(qs=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",qs.HARASSING="harassing",qs.SUSPICIOUS="suspicious",qs.INAPPROPRIATE="inappropriate";var ao,io=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=x.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return a(r)}(Z),so=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/operators"),a.params={operator_ids:o},a}return a(r)}(Z),oo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=x.GET,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/mute/").concat(o),a}return a(r)}(Z),uo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).isMuted=!1,i.startAt=null,i.endAt=null,i.remainingDuration=null,i.description=null;var s=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return i.isMuted=s,i.startAt=o,i.endAt=u,i.remainingDuration=c,i.description=l,i}return a(r)}($),co=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=x.GET,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={keys:o,include_ts:!0},a}return a(r)}(Z),lo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=null!=o?o:null,i}return a(r)}($),ho=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metadata;return(a=t.call(this)).method=x.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0},a}return a(r)}(Z),po=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o;return n(this,r),(i=t.call(this,e,a)).metaData=null!==(s=a.metadata)&&void 0!==s?s:{},i.ts=null!==(o=a.ts)&&void 0!==o?o:null,i}return a(r)}($),fo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=x.PUT,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return a(r)}(Z),vo=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.metadata,o=a.ts;return i.metadata=s,i.ts=null!=o?o:null,i}return a(r)}($),mo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).created=null,s.updated=null,s.deleted=null,i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return a(r)}(se),go=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metadata/").concat(o),a.params={include_ts:!0},a}return a(r)}(Z),_o=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.ts;return i.ts=null!=s?s:null,i}return a(r)}($),yo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metadata"),a.params={include_ts:!0},a}return a(r)}(Z),ko=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).ts=null;var s=a.ts;return i.ts=null!=s?s:null,i}return a(r)}($),Eo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.keys;return(a=t.call(this)).method=x.GET,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={keys:o},a}return a(r)}(Z),bo=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),wo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=x.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o},a}return a(r)}(Z),Co=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),xo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=x.PUT,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return a(r)}(Z),Ro=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).metaCounter=a,i}return a(r)}($),To=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).created=null,s.updated=null,s.deleted=null,i.data&&(s.created=i.data.created,s.updated=i.data.updated,s.deleted=i.data.deleted),s}return a(r)}(se),Io=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.key;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metacounter/").concat(o),a.params=null,a}return a(r)}(Z),So=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/metacounter"),a.params=null,a}return a(r)}(Z),No=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=x.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return a(r)}(Z),Mo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new js(e,i.data),s}return a(r)}(se),Ao=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/mute/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Uo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new js(e,i.data),s}return a(r)}(se),Oo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=x.POST,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/ban"),a.params=J({user_id:o,seconds:u,description:c}),a}return a(r)}(Z),Do=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).memberCount=null,s.joinedMemberCount=null,s.user=new js(e,i.data),i.data.member_count&&(s.memberCount=i.data.member_count),i.data.joined_member_count&&(s.joinedMemberCount=i.data.joined_member_count),s}return a(r)}(se),Lo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.userId;return(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/ban/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Po=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new js(e,i.data),s}return a(r)}(se),Fo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.freezing;return(a=t.call(this)).method=x.PUT,a.path="".concat(_n(s),"/").concat(encodeURIComponent(i),"/freeze"),a.params={freeze:o},a}return a(r)}(Z),Go=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).freeze=i.data.freeze,s}return a(r)}(se),qo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=x.POST,a.path="".concat(yn(s),"/").concat(encodeURIComponent(i)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return a(r)}(Z),Ho=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(a=r.call(this)).method=x.POST,a.path="".concat(Te,"/users/").concat(l),a.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},a}return a(s)}(Z),jo=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=x.POST,a.path="".concat(yn(s),"/").concat(encodeURIComponent(i),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return a(r)}(Z),Vo=function(t){i(s,t);var r=p(s);function s(t){n(this,s);var a=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"MESG",ackRequired:!0,payload:J({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:a,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return a(s)}(le),Qo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"MESG",i)).message=new fn(e,i);var l=St.of(e).sdkState;return s.isMentioned=kn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),Bo=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"MEDI",ackRequired:!0,payload:J({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(a=t.appleCriticalAlertOptions)||void 0===a?void 0:a.serialize(),poll_id:t.pollId})})}return a(s)}(le),Ko=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"MEDI",i)).message=new fn(e,i);var p=St.of(e).sdkState;return s.mentionCountChange=En({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),zo=function(t){i(s,t);var r=p(s);function s(t){n(this,s);var a=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((function(e){return e.userId})))),r.call(this,{code:"FEDI",ackRequired:!0,payload:J({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:a,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return a(s)}(le),Wo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"FEDI",i)).message=new gn(e,i);var p=St.of(e).sdkState;return s.mentionCountChange=En({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),Yo=function(e){i(r,e);var t=p(r);function r(e){var a;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return a(r)}(Z),Jo=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"DELM",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.messageId=Number(i.msg_id),s}return a(r)}(se),Xo=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return a(r)}(Z),Zo=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).reactionEvent=new Kt(a),i}return a(r)}($),$o=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.reactionKey;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return a(r)}(Z),eu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).reactionEvent=new Kt(Object.assign({},a)),i}return a(r)}($),tu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return a(r)}(Z),nu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new fn(e,a),i}return a(r)}($),ru=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return a.method=x.POST,a.path="".concat(_n(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:At.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Wt.payloadify(e)})),apple_critical_alert_options:Xt.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},a}return a(s)}(Z),au=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new fn(e,a),i}return a(r)}($),iu=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return a.method=x.POST,a.path="".concat(_n(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),a.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:At.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return rn.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Wt.payloadify(e)})),apple_critical_alert_options:Xt.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},a}return a(s)}(Z),su=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new gn(e,a),i}return a(r)}($),ou=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l;return n(this,o),(i=r.call(this,t)).url="",i.channelType=e.ChannelType.BASE,i.name="",i.coverUrl="",i.customType="",i.data="",i.isFrozen=!1,i.isEphemeral=!1,i.creator=null,i.createdAt=0,i.url=a.channel_url,i.name=null!==(s=a.name)&&void 0!==s?s:"",i.coverUrl=null!==(u=a.cover_url)&&void 0!==u?u:"",i.customType=null!==(c=a.custom_type)&&void 0!==c?c:"",i.data=null!==(l=a.data)&&void 0!==l?l:"",i.isFrozen=!!M("boolean",a.freeze)&&a.freeze,i.isEphemeral=!!M("boolean",a.is_ephemeral)&&a.is_ephemeral,i.creator=a.created_by?new pt(i._iid,a.created_by):null,i.createdAt=1e3*a.created_at,i._cachedMetaData=new Map,a.metadata&&a.ts&&Object.keys(a.metadata).forEach((function(e){i._cachedMetaData.set(e,{value:a.metadata[e],isRemoved:!1,updatedAt:a.ts})})),i}return a(o,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Xs(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new eo(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ro(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ur(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new io({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"removeOperators",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new so({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyMutedInfo",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new oo({channelUrl:this.url,channelType:this.channelType,userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(uo),o=s.isMuted,u=s.startAt,c=s.endAt,l=s.remainingDuration,h=s.description,e.abrupt("return",{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:h});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new co({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(lo),o=s.metadata,u=s.ts,this._upsertCachedMetaData(o,u),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new co({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(lo),s=i.metadata,o=i.ts,this._upsertCachedMetaData(s,o),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new ho({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(po),o=s.metaData,this._upsertCachedMetaData(o,0),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=St.of(this._iid),a=r.requestQueue,i=new fo({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(vo),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMetaData",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new go({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(_o),o=s.ts,this._removeFromCachedMetaData([e],o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new yo({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(ko),s=i.ts,this._removeFromCachedMetaData(g(this._cachedMetaData.keys()),s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new Eo({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,r.send(a);case 5:return i=t.sent,s=i.as(bo),o=s.metaCounter,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllMetaCounters",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Eo({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(bo),s=i.metaCounter,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new wo({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Co),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"updateMetaCounters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=St.of(this._iid),a=r.requestQueue,i=new xo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),n.next=4,a.send(i);case 4:return s=n.sent,o=s.as(Ro),u=o.metaCounter,n.abrupt("return",u);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new xo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ro),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new xo({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Ro),o=s.metaCounter,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new Io({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"deleteAllMetaCounters",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new So({channelUrl:this.url,channelType:this.channelType}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.muteUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"muteUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(M("string",e)&&M("number",t,!0)&&M("string",n,!0)).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new No({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unmuteUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new Ao({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"banUser",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.banUserWithUserId(e.userId,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"banUserWithUserId",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(M("string",e)&&M("number",t,!0)&&M("string",n,!0)).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new Oo({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),r.next=5,i.send(s);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"unbanUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unbanUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new Lo({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Fo({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,n.send(r);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Fo({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,n.send(r);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},In),t),ht(M("number",e)&&Sn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getMessagesByMessageId(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessagesByTimestamp",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},In),t),ht(M("number",e)&&Sn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getMessagesByTimestamp(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Nn),t),ht(M("number",e)&&Mn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Nn),t),ht(M("string",e)&&Mn(r)).throw(T.invalidParameters),a=Yn.of(this._iid),n.next=5,a.getMessageChangelogs(this.url,this.channelType,e,r);case 5:return n.abrupt("return",n.sent);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a=St.of(this._iid).sessionManager;return J({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return Wt.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?Xt.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:tn.payloadify(a.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:t.mentionedUsers})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var i,s=k(t.translationTargetLanguages);try{for(s.s();!(i=s.n()).done;){a[i.value]=""}}catch(e){s.e(e)}finally{s.f()}}var o=J(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new fn(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a=J(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:t.fileName,size:t.fileSize,type:t.mimeType,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),i=new gn(this._iid,a);return i.messageParams=t,i}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===b.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},$r),e);return ht(ta(t)).throw(T.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=St.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=r,u=Date.now(),c=new Jn;if(!o){o=this._generateRequestId();var l=St.of(this._iid),h=l.dispatcher;Fe(2).then((function(){var r=n._createPendingUserMessage(t,o,u);h.dispatch(new On({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}))}var d=new Vo(Object.assign(Object.assign({},t),{channelUrl:this.url,channelType:this.channelType,reqId:o}));return s.send(d).then((function(t){var r=t.as(Qo).message;i.dispatch(new On({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(R(r))throw r;Fe(2).then((function(){var a=n._createPendingUserMessage(t,o,u),s=St.of(n._iid).cacheContext.localCacheEnabled&&D(r.code);n._markMessageAsFailed(a,r,s),i.dispatch(new On({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))})),c}},{key:"_autoResendUserMessage",value:function(e){return ht(e instanceof fn).throw(T.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof fn&&!e.scheduledInfo).throw(T.invalidParameters),r=new de,a=null!==(t=e.messageParams)&&void 0!==t?t:ea(e),this._sendUserMessage(a,e.reqId).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),n.abrupt("return",r.promise);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"updateUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Bs),t),ht(M("number",e)&&Ks(r)).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new Bo(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Ko),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"copyUserMessage",value:function(t,n){var r,a,i;return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var u,c;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ht(t instanceof o&&n instanceof fn&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(T.invalidParameters),ht(!n.poll).throw(T.notSupportedError),u=new de,c=null!==(r=n.messageParams)&&void 0!==r?r:Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),t._sendUserMessage(c).onSucceeded((function(e){u.resolve(e)})).onFailed((function(e){return u.reject(e)})),s.abrupt("return",u.promise);case 6:case"end":return s.stop()}}),s,this)})))}},{key:"translateUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof fn&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new tu({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(nu),u=o.message,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_createScheduledUserMessage",value:function(e,t){var n=this,r=St.of(this._iid).requestQueue,a=Date.now(),i=this._generateRequestId();Fe(2).then((function(){var r=n._createPendingScheduledUserMessage(e,i,a);He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}));var s=new ru(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(au).message;He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(R(r))throw r;Fe(2).then((function(){var s=n._createPendingScheduledUserMessage(e,i,a);n._markMessageAsFailed(s,r),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},ia),e);return ht(oa(t)).throw(T.invalidParameters),this._sendFileMessage(t)}},{key:"_sendFileMessage",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=St.of(this._iid),i=a.dispatcher,s=Yn.of(this._iid),o=s.fileMessageQueue,u=r,c=Date.now(),l=new Jn;return u||(u=this._generateRequestId(),Fe(2).then((function(){var r=n._createPendingFileMessage(t,u,c);i.dispatch(new On({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))}))),o.request(this,u,t).then((function(t){i.dispatch(new On({messages:[t],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,t));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(R(r))throw r;Fe(2).then((function(){var a=n._createPendingFileMessage(t,u,c),s=St.of(n._iid).cacheContext.localCacheEnabled&&D(r.code);n._markMessageAsFailed(a,r,s),i.dispatch(new On({messages:[a],source:a.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r,a));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){ht(e instanceof gn).throw(T.invalidParameters);var t=St.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_createScheduledFileMessage",value:function(e,t,n,r){var a=this,i=St.of(this._iid).requestQueue,s=new iu(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(s).then((function(e){var n=e.as(su).message;He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(R(i))throw i;Fe(2).then((function(){var s=a._createPendingScheduledFileMessage(e,n,r);a._markMessageAsFailed(s,i),He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t._trigger(i,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){ht(e.every((function(e){return oa(Object.assign(Object.assign({},ia),e))}))).throw(T.invalidParameters);var t,n=new Jn,r=k(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,t){var n;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=Boolean(e.url)||L(t)||L(null===(n=e.messageParams)||void 0===n?void 0:n.file),ht(e instanceof gn&&a&&!e.scheduledInfo).throw(T.invalidParameters),i=new de,s=sa(e,t),this._sendFileMessage(s,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),r.abrupt("return",i.promise);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"updateFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},zs),t),ht(M("number",e)&&Ws(r)).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new zo(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(Wo),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=Yn.of(this._iid),n.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"copyFileMessage",value:function(t,n){var r,a;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return ht(t instanceof o&&n instanceof gn&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(T.invalidParameters),s=new de,u=Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:n.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth,isPinnedMessage:!1}),t._sendFileMessage(u).onSucceeded((function(e){return s.resolve(e)})).onFailed((function(e){return s.reject(e)})),i.abrupt("return",s.promise);case 5:case"end":return i.stop()}}),i,this)})))}},{key:"deleteMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ht(e instanceof en).throw(T.invalidParameters),!(e.messageId>0)){t.next=6;break}return n=St.of(this._iid),r=n.requestQueue,a=new Yo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,r.send(a);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"addReaction",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&M("string",t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new Xo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Zo),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deleteReaction",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&M("string",t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new $o({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(eu),u=o.reactionEvent,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"_updateMessageMetaArray",value:function(t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s,o,u,c,l,h,d;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=St.of(this._iid),o=s.dispatcher,u=s.requestQueue,c=new Bo({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),i.next=4,u.send(c);case 4:return l=i.sent,h=l.as(Ko),d=h.message,o.dispatch(new On({messages:[d],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),i.abrupt("return",d);case 8:case"end":return i.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=t.map((function(e){return new Wt({key:e})})),n.abrupt("return",this._updateMessageMetaArray(e.messageId,r,"add",!0));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&O("string",t)).throw(T.invalidParameters),r=t.map((function(e){return new Wt({key:e})})),n.abrupt("return",this._updateMessageMetaArray(e.messageId,r,"remove",!0));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&t.every((function(e){return e instanceof Wt}))).throw(T.invalidParameters),n.abrupt("return",this._updateMessageMetaArray(e.messageId,t,"add",!0));case 2:case"end":return n.stop()}}),n,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(e instanceof en&&e.messageId>0&&t.every((function(e){return e instanceof Wt}))).throw(T.invalidParameters),n.abrupt("return",this._updateMessageMetaArray(e.messageId,t,"remove",!0));case 2:case"end":return n.stop()}}),n,this)})))}},{key:"report",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(A(e.ReportCategory,t)&&M("string",n)).throw(T.invalidParameters),a=St.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new qo({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),r.next=5,s.send(o);case 5:case"end":return r.stop()}}),r,this)})))}},{key:"reportUser",value:function(t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){var i,s,o,u;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ht(t instanceof pt&&A(e.ReportCategory,n)&&M("string",r)).throw(T.invalidParameters),i=St.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Ho({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.userId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}},{key:"reportMessage",value:function(t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){var i,s,o,u;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return ht(t instanceof nn&&A(e.ReportCategory,n)&&M("string",r)).throw(T.invalidParameters),i=St.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new jo({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),a.next=5,o.send(u);case 5:case"end":return a.stop()}}),a,this)})))}}],[{key:"payloadify",value:function(e){return J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:pt.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),o}(nt),uu=function(e){i(r,e);var t=p(r);function r(e,a){var i,s;return n(this,r),(i=t.call(this,e,a)).isMuted=!1,i.isMuted=null!==(s=a.is_muted)&&void 0!==s&&s,i}return a(r)}(pt),cu=null,lu=function(){function t(e,r,a){var i=this;n(this,t),this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=r;var s=St.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,l=s.sessionManager,h=s.requestQueue,d=s.logger,p=s.userEventHandlers;this._onlineDetector=new Ra({logger:d,connectionDelegate:{reconnect:function(){var t=St.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){St.of(e).connectionManager.disconnect()}}});var f=new Sa(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:d});a.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:d,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new xa,this._appStateChangeDetector.on("resume",(function(){d.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){d.debug("the page freezes"),i.setBackgroundState()})),c.on((function(t){if(t instanceof ve){if(t.stateType===ue.CONNECTED)f.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof se){if("USEV"===t.code){var n=t.as(Ua).event;if(n.category===fa.FRIEND_DISCOVERED){var r=Ma.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;He((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(r)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(t instanceof he){var a=St.of(i._iid).subscribedUnreadMessageCount,s=!1,c=t.ts;if("number"==typeof c&&c>a.ts){if(a.all!==t.all&&(s=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(s=!0),a.customTypes[l]=t.customTypes[l];s=s&&a.ts>0,a.ts=c}s&&He((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else t instanceof ft&&u.localCacheEnabled&&u.preference.set(i._getUserProfileCacheKey(o.userId),vt.payloadify(t.userProfile))}))}return a(t,[{key:"appId",get:function(){return St.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return St.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=St.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return St.of(this._iid).debugMode}},{key:"logLevel",get:function(){return St.of(this._iid).logger.level},set:function(e){St.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return St.of(this._iid).cacheContext.localCacheEnabled}},{key:"ekey",get:function(){return St.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=St.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=St.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=St.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=St.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ss?n.store:null;throw T.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=St.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"initializeCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=St.of(this._iid),r=n.sdkState,a=n.cacheContext,i=n.connectionManager,s=n.dispatcher,r.userId&&r.userId===e){t.next=23;break}return t.next=4,i.logout();case 4:if(r.userId=e,o="sendbird@".concat(r.appId,"/").concat(e,".db"),!a.localCacheEnabled){t.next=15;break}if(a.nestdb&&a.nestdb.state!==vs.CLOSED&&a.nestdb.name===o){t.next=13;break}return(u=a.nestdb=new Gs({name:"sendbird@".concat(r.appId,"/").concat(e,".db"),version:2,store:a.store})).on("upgrade",ba(u,a.store)),t.next=12,u.open();case 12:s.dispatch(new Aa(this._iid,{userId:e}));case 13:t.next=17;break;case 15:return t.next=17,a.store.init(o);case 17:return t.next=19,a.preference.init(this._getPreferenceCacheKey(e));case 19:return t.next=21,a.preference.get(this._getUserProfileCacheKey(e));case 21:(c=t.sent)&&new vt(this._iid,c).apply();case 23:case"end":return t.stop()}}),t,this)})))}},{key:"clearCachedData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),(n=t.cacheContext).localCacheEnabled&&n.nestdb&&n.nestdb.clear(),e.next=4,n.preference.clear();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ht(O("string",e)).throw(T.invalidParameters),n=Ca.of(this._iid),r=Ea.of(this._iid),!n||!r){t.next=6;break}return t.next=6,Promise.all(e.map((function(e){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.removeMessagesOfChannel(e);case 2:return t.next=4,r.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),t)})))})));case 6:case"end":return t.stop()}}),t,this)})))}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("string",e)&&M("string",t,!0)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.cacheContext,s=r.connectionManager,o=r.statLogCollector,n.prev=2,n.next=5,this.initializeCache(e);case 5:n.next=12;break;case 7:n.prev=7,n.t0=n.catch(2),u=St.of(this._iid),c=u.logger,i.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available.");case 12:return n.next=14,o.init("sendbird@".concat(a.appId,"/").concat(e,".statlog"));case 14:return this._onlineDetector.start(),this._appStateChangeDetector.start(),n.next=18,s.connect(t);case 18:return n.abrupt("return",this.currentUser);case 19:case"end":return n.stop()}}),n,this,[[2,7]])})))}},{key:"reconnect",value:function(){var e=St.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r}},{key:"disconnect",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.connectionManager,r=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),e.next=6,n.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=St.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=St.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){ht(e instanceof Gr).throw(T.invalidParameters),St.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){ht(M("string",e)&&t instanceof Hr).throw(T.invalidParameters),St.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){St.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){St.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){ht(M("string",e)&&t instanceof qr).throw(T.invalidParameters),St.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){St.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){St.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Oi(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Pi(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new qi(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new sr(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Ar(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new Dr(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=lt(e);return new pt(this._iid,pt.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Object.assign(Object.assign({},Pr),e),ht(Fr(n)).throw(T.invalidParameters),!this.currentUser){t.next=13;break}return r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new Oa(Object.assign({userId:a.userId},n)),t.next=7,i.send(s);case 7:return o=t.sent,u=o.as(Da),c=u.user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=c.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),t.abrupt("return",c);case 13:throw T.connectionRequired;case 14:case"end":return t.stop()}}),t,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ht(O("string",e)).throw(T.invalidParameters),!this.currentUser){t.next=12;break}return n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Oa({userId:r.userId,preferredLanguages:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Da),u=o.user,this.currentUser&&(this.currentUser.preferredLanguages=u.preferredLanguages),t.abrupt("return",u);case 12:throw T.connectionRequired;case 13:case"end":return t.stop()}}),t,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ht(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=20;break}if(n.prev=2,r=St.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,!a.hasDeviceToken(e.PushTokenType.FCM,t)){n.next=6;break}return n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return o=new Pa({userId:i.userId,token:t}),n.next=9,s.send(o);case 9:return n.next=11,je((function(){return E(u,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.setDeviceToken(e.PushTokenType.FCM,t),n.next=3,a.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ht(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=St.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Ga({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,je((function(){return E(l,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.FCM,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._fcmPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._fcmPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=St.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new Ha({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,je((function(){return E(c,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.FCM),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ht(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=20;break}if(n.prev=2,r=St.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,!a.hasDeviceToken(e.PushTokenType.APNS,t)){n.next=6;break}return n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return o=new La({userId:i.userId,token:t}),n.next=9,s.send(o);case 9:return n.next=11,je((function(){return E(u,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.setDeviceToken(e.PushTokenType.APNS,t),n.next=3,a.saveDeviceToken();case 3:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(ht(M("string",t)).throw(T.invalidParameters),!this.currentUser){n.next=20;break}return n.prev=2,r=St.of(this._iid),a=r.sessionManager,i=r.sdkState,s=r.requestQueue,o=new Fa({userId:i.userId,token:t}),n.next=7,s.send(o);case 7:return u=n.sent,c=u.lastDeletedAt,n.next=11,je((function(){return E(l,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a.unsetDeviceToken(e.PushTokenType.APNS,t),a.setDeviceTokenDeletedAt(c),n.next=4,a.saveDeviceToken();case 4:case"end":return n.stop()}}),n)})))}));case 11:return this._apnsPushToken="",n.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return n.prev=15,n.t0=n.catch(2),n.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:n.next=22;break;case 20:return this._apnsPushToken=t,n.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return n.stop()}}),n,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.currentUser){t.next=9;break}return n=St.of(this._iid),r=n.sessionManager,a=n.sdkState,i=n.requestQueue,s=new qa({userId:a.userId}),t.next=5,i.send(s);case 5:return o=t.sent,u=o.lastDeletedAt,t.next=9,je((function(){return E(c,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.unsetDeviceTokens(e.PushTokenType.APNS),r.setDeviceTokenDeletedAt(u),t.next=4,r.saveDeviceToken();case 4:case"end":return t.stop()}}),t)})))}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelInvitationPreference",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Qa({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Ba),o=s.autoAccept,e.abrupt("return",{autoAccept:o});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("boolean",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new Ka({userId:r.userId,willAutoAccept:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(za),u=o.autoAccept,t.abrupt("return",{autoAccept:u});case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getDoNotDisturb",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Wa({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Ya),o=s.preference,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return ht(M("boolean",e)&&M("number",t)&&M("number",n)&&M("number",r)&&M("number",a)&&M("string",i)).throw(T.invalidParameters),o=St.of(this._iid),u=o.sdkState,c=o.requestQueue,l=new Ja({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:i}),s.next=5,c.send(l);case 5:return h=s.sent,d=h.as(Xa),p=d.preference,s.abrupt("return",p);case 8:case"end":return s.stop()}}),s,this)})))}},{key:"getSnoozePeriod",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Za({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as($a),o=s.snoozePeriod,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(M("boolean",e)&&M("number",t)&&M("number",n)).throw(T.invalidParameters),a=St.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new ei({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),r.next=5,s.send(o);case 5:return u=r.sent,c=u.as(ti),l=c.snoozePeriod,r.abrupt("return",l);case 8:case"end":return r.stop()}}),r,this)})))}},{key:"getMyPushTokensByToken",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l,h,d,p,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(M("string",t)&&A(e.PushTokenType,n)).throw(T.invalidParameters),a=St.of(this._iid),i=a.sdkState,s=a.requestQueue,o=a.sessionManager,u=new ja({userId:i.userId,type:n,token:t}),r.next=5,s.send(u);case 5:c=r.sent,l=c.as(Va),h=l.pushTokens,d=k(h.deviceTokens);try{for(d.s();!(p=d.n()).done;)f=p.value,o.setDeviceToken(h.type,f)}catch(e){d.e(e)}finally{d.f()}return r.next=11,o.saveDeviceToken();case 11:return r.abrupt("return",h);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"getPushTriggerOption",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ai({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(ii).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(A(e.PushTriggerOption,t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new si({userId:a.userId,pushTriggerOption:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(oi).pushTriggerOption);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"getPushTemplate",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ui({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,e.abrupt("return",i.as(ci).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(A(e.PushTemplate,t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new li({userId:a.userId,templateName:t}),n.next=5,i.send(s);case 5:return o=n.sent,n.abrupt("return",o.as(hi).name);case 7:case"end":return n.stop()}}),n,this)})))}},{key:"blockUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(e instanceof pt||M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ni({userId:r.userId,blockedUserId:e instanceof pt?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUser",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(e instanceof pt||M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new ri({userId:r.userId,unblockedUserId:e instanceof pt?e.userId:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new di({userId:r.userId,token:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(pi),u=o.changelogs,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new ki({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Ei),o=s.allowFriendDiscovery,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("boolean",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new bi({userId:r.userId,allowFriendDiscovery:e}),t.next=5,a.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new fi({userId:r.userId,discoveries:e}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(vi),u=o.friendDiscoveryRequestId,t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new mi({userId:r.userId,discoveryKeys:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"addFriends",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new gi({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:return s=t.sent,o=s.as(_i),u=o.users,t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriend",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"deleteFriends",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(O("string",e)).throw(T.invalidParameters),n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new yi({userId:r.userId,userIds:e}),t.next=5,a.send(i);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getAllEmoji",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Ri,e.next=4,n.send(r);case 4:return a=e.sent,i=a.as(Ti),s=i.emojiContainer,e.abrupt("return",s);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new Ii({categoryId:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Si),o=s.emojiCategory,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"getEmoji",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=new Ni({key:e}),t.next=4,r.send(a);case 4:return i=t.sent,s=i.as(Mi),o=s.emoji,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})))}}],[{key:"init",value:function(e){var n=e.appId,r=e.appVersion,a=void 0===r?null:r,i=e.modules,s=void 0===i?[]:i,o=e.options,u=void 0===o?new q:o,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,p=e.newInstance,f=void 0!==p&&p,v=e.logLevel,m=e.localCacheEnabled,_=void 0!==m&&m,y=e.localCacheEncryption,k=e.useAsyncStorageStore,E=void 0===k?null:k;if(!cu||f){var b="su-".concat(B()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},C=new Ss({encryption:w});l||(C=E?new Us({AsyncStorage:E,encryption:w}):new As({encryption:w})),new St(b,{appId:n,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:C,encryption:w,logLevel:v,localCacheEnabled:_,debugMode:l});var x=[new hr,new Lr],R=new t(b,u,[].concat(g(s),x));return cu||(cu=R),R}return cu}},{key:"instance",get:function(){return cu}},{key:"version",get:function(){return w}}]),t}();e.MemberState=void 0,(ao=e.MemberState||(e.MemberState={})).NONE="none",ao.JOINED="joined",ao.INVITED="invited",ao.LEFT="left";var hu,du,pu,fu,vu,mu,gu,_u,yu=function(t){i(o,t);var r=p(o);function o(t,a){var i;return n(this,o),(i=r.call(this,t,a)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=A(e.MemberState,a.state)?a.state:null,i.role=A(e.Role,a.role)?a.role:null,a.hasOwnProperty("is_muted")&&(i.isMuted=a.is_muted),a.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=a.is_blocked_by_me),a.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=a.is_blocking_me),i}return a(o,null,[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),o}(js),ku=function(t){i(s,t);var r=p(s);function s(t,a){var i,o,u;return n(this,s),(i=r.call(this,t)).channelUrl=null!==(o=a.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=a.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new pt(i._iid,a.user),i.readAt=a.ts,i}return a(s)}(nt);e.PublicChannelFilter=void 0,(hu=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",hu.PUBLIC="public",hu.PRIVATE="private",e.MyMemberStateFilter=void 0,(du=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",du.JOINED="joined_only",du.INVITED="invited_only",du.INVITED_BY_FRIEND="invited_by_friend",du.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(pu=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",pu.SUPER="super",pu.NON_SUPER="nonsuper",pu.BROADCAST_ONLY="broadcast_only",pu.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(fu=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",fu.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(vu=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",vu.UNHIDDEN="unhidden_only",vu.HIDDEN="hidden_only",vu.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",vu.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(mu=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",mu.OPERATOR="operator",mu.NONOPERATOR="nonoperator",e.QueryType=void 0,(gu=e.QueryType||(e.QueryType={})).AND="AND",gu.OR="OR",e.GroupChannelSearchField=void 0,(_u=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",_u.CHANNEL_NAME="channel_name";var Eu,bu=function(){function t(){n(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return a(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,i=r.fields;if(a&&i&&i.length>0&&!i.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var s=this._userIdsFilter,o=s.userIds,u=s.includeMode,c=s.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.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=g(e).sort(),r=g(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(t.members.every((function(e){return e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),wu=function(t){i(s,t);var r=p(s);function s(e,t){var a,i=t.sdkState,o=t.cacheContext;return n(this,s),(a=r.call(this,e))._channels=new Map,a._sdkState=i,a._cacheContext=o,a}return a(s,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(jr):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Kc.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return g(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>n||s&&t.createdAtn||s&&t.lastMessageUpdatedAt0)){r.next=76;break}return r.next=76,this.upsert(a);case 76:case"end":return r.stop()}}),r,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!0);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"unblock",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._setBlockStateOfAllChannels(e,t,!1);case 2:case"end":return n.stop()}}),n,this)})))}},{key:"markAsRead",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g(this._channels.keys());return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=k(t),n.prev=2,a.s();case 4:if((i=a.n()).done){n.next=12;break}return s=i.value,n.next=8,this.get(s);case 8:(o=n.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(o._updateUnreadCount(0,0),r.push(o));case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(2),a.e(n.t0);case 17:return n.prev=17,a.f(),n.finish(17);case 20:if(!(r.length>0)){n.next=23;break}return n.next=23,this.upsert(r);case 23:case"end":return n.stop()}}),n,this,[[2,14,17,20]])})))}}]),s}(nt);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(Eu||(Eu={}));var Cu,xu=function(){function t(e){n(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return a(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),Ru={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Tu=function(e){return O("string",e.invitedUserIds,!0)&&M("string",e.channelUrl,!0)&&M("string",e.coverUrl,!0)&&(L(e.coverImage)||M("string",e.coverImage)||null===e.coverImage)&&M("boolean",e.isDistinct,!0)&&M("boolean",e.isSuper,!0)&&M("boolean",e.isBroadcast,!0)&&M("boolean",e.isExclusive,!0)&&M("boolean",e.isPublic,!0)&&M("boolean",e.isStrict,!0)&&M("boolean",e.isDiscoverable,!0)&&M("boolean",e.isEphemeral,!0)&&M("string",e.accessCode,!0)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&O("string",e.operatorUserIds,!0)&&M("number",e.messageSurvivalSeconds,!0)},Iu={customTypes:null,includeEmpty:!1,includeFrozen:!0},Su=function(e){return O("string",e.customTypes,!0)&&M("boolean",e.includeEmpty)&&M("boolean",e.includeFrozen)},Nu={myMemberStateFilter:e.MyMemberStateFilter.ALL},Mu=function(t){return A(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(Cu=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",Cu.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",Cu.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",Cu.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",Cu.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",Cu.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",Cu.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",Cu.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",Cu.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var Au,Uu={keys:[]},Ou=function(t){return O(e.UnreadItemKey,t.keys)},Du={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},Lu=function(t){return O("string",t.channelCustomTypesFilter,!0)&&A(e.SuperChannelFilter,t.superChannelFilter)},Pu={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},Fu=function(t){return M("string",t.channelUrl,!0)&&O(e.ScheduledStatus,t.scheduledStatus,!0)&&A(e.MessageTypeFilter,t.messageTypeFilter)};e.GroupChannelEventSource=void 0,(Au=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",Au.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Au.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Au.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Au.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Au.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Au.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Au.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Au.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Au.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Au.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Au.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Au.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Au.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Au.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Au.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Au.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Au.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Au.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Au.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Au.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Au.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Au.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Au.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Au.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Au.REQUEST_CHANNEL="REQUEST_CHANNEL",Au.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Au.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Au.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var Gu,qu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS},Hu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channels,s=e.source;return n(this,r),(a=t.call(this)).channels=i,a.source=s,a}return a(r)}(Y),ju=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrls,s=e.source;return n(this,r),(a=t.call(this)).channelUrls=i,a.source=s,a}return a(r)}(Y),Vu=function(){function e(t){var r=this,a=t.groupChannelCache,i=t.messageCache,s=t.unsentMessageCache,o=t.dispatcher;n(this,e),this._observers=new Map,o.on((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,o,u,c,l,h,d,p,f=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Hu)){t.next=26;break}n=e.channels,r=e.source,o=n.filter((function(e){return e instanceof hh})),u=a.filterOffsetChanged(o),c=k(u),t.prev=5,c.s();case 7:if((l=c.n()).done){t.next=13;break}return h=l.value,t.next=11,i.removeUnderOffset(h.url,h.messageOffsetTimestamp);case 11:t.next=7;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(5),c.e(t.t0);case 18:return t.prev=18,c.f(),t.finish(18);case 21:return t.next=23,a.upsert(o);case 23:this._broadcastUpdateEvent(o,r),t.next=38;break;case 26:if(!(e instanceof ju)){t.next=35;break}return d=e.channelUrls,p=e.source,t.next=30,a.remove(d);case 30:return t.next=32,je((function(){return E(f,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(d),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}return r=n.value,e.next=7,i.removeMessagesOfChannel(r);case 7:return e.next=9,s.removeMessagesOfChannel(r);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 32:this._broadcastRemoveEvent(d,p),t.next=38;break;case 35:if(!(e instanceof Aa)){t.next=38;break}return t.next=38,a.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 38:case"end":return t.stop()}}),t,this,[[5,15,18,21]])})))}))}return a(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Qu=function(){function e(t){var r=this,a=t.cacheContext,i=t.messageCache,s=t.unsentMessageCache,o=t.dispatcher,u=t.logger;n(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=a,this._logger=u,o.on((function(e){return E(r,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,o,u,c,l,h,d,p,f,v,m,g,_,y,k,b,w=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof On)){t.next=14;break}if(n=e.messages,r=e.source,a=n.filter((function(e){return e.messageId>0})),o=n.filter((function(e){return 0===e.messageId})),!(a.length>0)){t.next=8;break}return t.next=7,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(a);case 2:return e.next=4,s.remove(a.map((function(e){return e instanceof nn?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(a,r);case 8:if(!(o.length>0)){t.next=12;break}return t.next=11,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.upsert(o);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(o,r);case 12:t.next=61;break;case 14:if(!(e instanceof Dn)){t.next=21;break}return u=e.messageIds,c=e.source,t.next=18,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(u);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(u,c),t.next=61;break;case 21:if(!(e instanceof Ln)){t.next=28;break}return l=e.reqId,h=e.source,t.next=25,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.remove([l]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(l,h),t.next=61;break;case 28:if(!(e instanceof Pn)){t.next=41;break}if(d=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){t.next=38;break}return f=d.map((function(e){return e.messageId})),t.next=34,Promise.all(f.map((function(e){return i.get(e)})));case 34:return v=t.sent.filter((function(e){return e})),v.length>0&&d.forEach((function(e){var t=v.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),t.next=38,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(v);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(d,p),t.next=61;break;case 41:if(!(e instanceof Fn)){t.next=52;break}return m=e.event,g=e.source,t.next=45,i.get(m.messageId);case 45:if(!((_=t.sent)&&_.isUserMessage()&&_.poll&&_.poll.applyPollUpdateEvent(m))){t.next=49;break}return t.next=49,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([_]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),t.next=61;break;case 52:if(!(e instanceof Gn)){t.next=61;break}return y=e.event,k=e.source,t.next=56,i.get(y.messageId);case 56:if(!((b=t.sent)&&b.isUserMessage()&&b.poll&&b.poll.applyPollVoteEvent(y))){t.next=60;break}return t.next=60,je((function(){return E(w,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([b]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(y,k);case 61:case"end":return t.stop()}}),t,this)})))}))}return a(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=k(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Bu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.ts,o=e.token,u=e.filter;n(this,r),a=t.call(this);var c=Object.assign(Object.assign({},Iu),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),a.params=J({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:s>0?s:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return a(r)}(Z),Ku=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new hh(e,t)})),i.deletedChannelUrls=a.deleted,i.hasMore=a.has_more,i.token=a.next,i}return a(r)}($),zu=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.isInternalCall;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(s?we:be,"/").concat(encodeURIComponent(i)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return a(r)}(Z),Wu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=null,i.channel=new hh(e,a),i}return a(r)}($),Yu=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.userId,s=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,p=e.unreadChannelFilter,f=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,m=e.nicknameExactMatchFilter,g=e.channelNameContainsFilter,_=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,R=e.metadataValueStartsWith,T=e.includeFrozen,I=e.includeMetaData,S=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/my_group_channels"),a.params=J({token:s,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:p,members_nickname_contains:f,members_nickname_startswith:v,members_nickname:m,name_contains:g,channel_urls:_,custom_types:y,custom_type_startswith:k,hidden_mode:E,metadata_order_key:b,metadata_key:w,metadata_values:C,metadata_value_startswith:R,show_frozen:T,show_metadata:I}),S&&S.query&&S.fields&&(a.params.search_query=S.query,a.params.search_fields=S.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return a(r)}(Z),Ju=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new hh(e,t)}))),i.ts=null!=u?u:null,i}return a(r)}($),Xu=function(t){i(s,t);var r=p(s);function s(t){var a,i=t.userId,o=t.filter;n(this,s),a=r.call(this);var u=o.myMemberStateFilter;return a.method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/group_channel_count"),a.params={state:null!=u?u:e.MyMemberStateFilter.ALL},a}return a(s)}(Z),Zu=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).groupChannelCount=a.group_channel_count,i}return a(r)}($),$u=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.filter;n(this,r),a=t.call(this);var o=s.keys;return a.method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/unread_item_count"),a.params={item_keys:o},a}return a(r)}(Z),ec=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),i=r.call(this,t,a),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=a[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=a[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=a[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=a[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=a[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=a[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=a[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof a[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=a[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return a(s)}($),tc=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/unread_channel_count"),a}return a(r)}(Z),nc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).unreadCount=a.unread_count,i}return a(r)}($),rc=function(t){i(s,t);var r=p(s);function s(t){var a,i=t.userId,o=t.filter;n(this,s),a=r.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return a.method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/unread_message_count"),a.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},a}return a(s)}(Z),ac=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).unreadCount=a.unread_count,i}return a(r)}($),ic=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.scheduledStatus,o=e.messageTypeFilter;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(Me,"/count"),a.params={channel_url:i,status:oc(s)},o&&(a.params.message_type=o),a}return a(r)}(Z),sc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).count=a.count,i}return a(r)}($),oc=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(Bt.PENDING);break;case e.ScheduledStatus.SENT:n.push(Bt.IN_QUEUE),n.push(Bt.SENT);break;case e.ScheduledStatus.CANCELED:n.push(Bt.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(Bt.FAILED)}})),n}},uc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.userId,s=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,_=e.accessCode,y=e.name,k=e.data,E=e.customType,b=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=x.POST,a.path=be,a.params=J({user_ids:[i].concat(g(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:s,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:p,is_public:d,is_discoverable:f,strict:v,is_ephemeral:m,access_code:_,name:y,data:k,custom_type:E,operator_ids:C,message_survival_seconds:b}),a}return a(r)}(Z),cc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new hh(e,a),i.isCreated=a.is_created,i}return a(r)}($),lc=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrls;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/mark_as_read_all"),a.params={channel_urls:s},a}return a(r)}(Z),hc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).event=new xu(i),s}return a(r)}(se),dc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/join"),a.params={user_id:s,access_code:o},a}return a(r)}(Z),pc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new hh(e,a),i}return a(r)}($),fc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,p=void 0===d?null:d;return s.memberCount=c,s.joinedMemberCount=h,s.members=Array.isArray(p)?p.map((function(t){return new yu(e,t)})):[new yu(e,i.data)],s}return a(r)}(hc),vc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/leave"),a.params={user_id:s,should_remove_operator_status:o},a}return a(r)}(Z),mc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return s.memberCount=c,s.joinedMemberCount=h,s.member=new yu(s._iid,i.data),s}return a(r)}(hc),gc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userIds;return(a=t.call(this)).method=x.POST,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/invite"),a.params={user_ids:s},a}return a(r)}(Z),_c=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new hh(e,a),i}return a(r)}($),yc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,p=void 0===d?null:d,f=o.invitees,v=void 0===f?[]:f;return s.memberCount=c,s.joinedMemberCount=h,s.inviter=p?new pt(e,p):null,s.invitees=v.map((function(t){return new yu(e,t)})),s}return a(r)}(hc),kc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/decline"),a.params={user_id:s},a}return a(r)}(Z),Ec=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,p=void 0===d?null:d,f=o.invitee,v=void 0===f?null:f;return s.memberCount=c,s.joinedMemberCount=h,s.inviter=p?new pt(e,p):null,s.invitee=v?new yu(e,v):null,s}return a(r)}(hc),bc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return a(r)}(le),wc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"READ",i)).readStatus=new ku(e,i),s}return a(r)}(se),Cc=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.userId;return n(this,r),a=t.call(this),(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/messages/mark_as_delivered"),a.params=J({userId:s}),a}return a(r)}(Z),xc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"DLVR",i)).channelUrl=i.channel_url,s.deliveredStateUpdate=i.updated,s}return a(r)}(se),Rc=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/hide"),a.params={user_id:s,hide_previous_messages:o,allow_auto_unhide:u},a}return a(r)}(Z),Tc=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).messageOffsetTimestamp=null;var s=a.ts_message_offset;return i.messageOffsetTimestamp=null!=s?s:null,i}return a(r)}($),Ic=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,i.data&&(s.allowAutoUnhide=i.data.allow_auto_unhide,s.hidePreviousMessages=i.data.hide_previous_messages),s.messageOffsetTimestamp=i.ts_message_offset,s}return a(r)}(se),Sc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.time;return n(this,r),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:i}})}return a(r)}(le),Nc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new pt(e,i.data),s}return a(r)}(se),Mc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.time;return n(this,r),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:i}})}return a(r)}(le),Ac=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"SYEV",i)).user=new pt(e,i.data),s}return a(r)}(se),Uc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;n(this,r),s=t.call(this,e,a,i);var o=i.data.operators,u=void 0===o?[]:o;return s.operators=u.map((function(e){return new pt(s._iid,e)})),s}return a(r)}(hc),Oc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MCNT",i)).groupChannelMemberCounts=i.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=i.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return a(r)}(se),Dc=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl,i=e.messageId;return n(this,r),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:i}})}return a(r)}(le),Lc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c;n(this,r),(s=t.call(this,e,"ADMM",i)).message=new on(e,i);var l=St.of(e).sdkState;return s.isMentioned=kn(s.message.mentionType,null!==(o=s.message.mentionedUserIds)&&void 0!==o?o:null===(u=s.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),s.forceUpdateLastMessage=null!==(c=i.force_update_last_message)&&void 0!==c&&c,s}return a(r)}(se),Pc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u,c,l,h,d;n(this,r),(s=t.call(this,e,"AEDI",i)).message=new on(e,i);var p=St.of(e).sdkState;return s.mentionCountChange=En({mentionType:null!==(u=null===(o=i.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=i.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:s.message.mentionType,mentionedUserIds:null!==(h=s.message.mentionedUserIds)&&void 0!==h?h:null===(d=s.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},p.userId),s}return a(r)}(se),Fc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MRCT",i)).channelUrl=i.channel_url,s.channelType=i.channel_type,s.event=new Kt(i),s}return a(r)}(se),Gc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"MTHD",i)).event=new Xn(e,i),s}return a(r)}(se),qc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"PEDI",i)).event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new Ir(e,i),s.status=ln(i.poll.status)||i.poll.status,s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return a(r)}(se),Hc=function(e){i(r,e);var t=p(r);function r(e,a,i){var s;return n(this,r),(s=t.call(this,e,"VOTE",i)).event=null,s.channelUrl=null,s.channelType=null,s.event=new Sr(i),s.channelUrl=i.channel_url,s.channelType=i.channel_type,s}return a(r)}(se),jc=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k,E,b,w,C,x,R,T,I;return n(this,o),(i=r.call(this,t,a)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.nicknameContainsFilter=null,i.nicknameStartsWithFilter=null,i.nicknameExactMatchFilter=null,i.channelNameContainsFilter="",i.myMemberStateFilter=e.MyMemberStateFilter.ALL,i.unreadChannelFilter=e.UnreadChannelFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.publicChannelFilter=e.PublicChannelFilter.ALL,i.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,i.searchFilter={fields:[],query:null},i.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i.includeEmpty=null!==(s=a.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(u=a.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=a.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=a.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(h=a.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(d=a.customTypeStartsWithFilter)&&void 0!==d?d:"",i.nicknameContainsFilter=null!==(p=a.nicknameContainsFilter)&&void 0!==p?p:null,i.nicknameStartsWithFilter=null!==(f=a.nicknameStartsWithFilter)&&void 0!==f?f:null,i.nicknameExactMatchFilter=null!==(v=a.nicknameExactMatchFilter)&&void 0!==v?v:null,i.channelNameContainsFilter=null!==(m=a.channelNameContainsFilter)&&void 0!==m?m:"",i.myMemberStateFilter=null!==(g=a.myMemberStateFilter)&&void 0!==g?g:e.MyMemberStateFilter.ALL,i.unreadChannelFilter=null!==(_=a.unreadChannelFilter)&&void 0!==_?_:e.UnreadChannelFilter.ALL,i.superChannelFilter=null!==(y=a.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,i.publicChannelFilter=null!==(k=a.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,i.hiddenChannelFilter=null!==(E=a.hiddenChannelFilter)&&void 0!==E?E:e.HiddenChannelFilter.UNHIDDEN,i.searchFilter=null!==(b=a.searchFilter)&&void 0!==b?b:{fields:[],query:null},i.userIdsFilter=null!==(w=a.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},i.metadataKey=null!==(C=a.metadataKey)&&void 0!==C?C:null,i.metadataValues=null!==(x=a.metadataValues)&&void 0!==x?x:null,i.metadataOrderKeyFilter=null!==(R=a.metadataOrderKeyFilter)&&void 0!==R?R:null,i.metadataValueStartsWith=null!==(T=a.metadataValueStartsWith)&&void 0!==T?T:null,i.order=null!==(I=a.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.includeEmpty)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.channelNameContainsFilter)&&O("string",this.channelUrlsFilter,!0)&&O("string",this.customTypesFilter,!0)&&M("string",this.customTypeStartsWithFilter)&&M("string",this.nicknameContainsFilter,!0)&&M("string",this.nicknameStartsWithFilter,!0)&&M("string",this.nicknameExactMatchFilter,!0)&&A(e.MyMemberStateFilter,this.myMemberStateFilter)&&A(e.SuperChannelFilter,this.superChannelFilter)&&A(e.PublicChannelFilter,this.publicChannelFilter)&&A(e.UnreadChannelFilter,this.unreadChannelFilter)&&A(e.HiddenChannelFilter,this.hiddenChannelFilter)&&O(e.GroupChannelSearchField,this.searchFilter.fields)&&M("string",this.searchFilter.query,!0)&&O("string",this.userIdsFilter.userIds)&&M("boolean",this.userIdsFilter.includeMode)&&A(e.QueryType,this.userIdsFilter.queryType)&&A(e.GroupChannelListOrder,this.order)&&M("string",this.metadataOrderKeyFilter,!0)&&M("string",this.metadataKey,!0)&&O("string",this.metadataValues,!0)&&M("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return ct(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=Kc.of(this._iid),e.next=7,t.getMyGroupChannels(this._token,this,this.limit);case 7:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,e.abrupt("return",r);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(er),Vc=function(){function e(t){var r=t.top,a=void 0===r?Number.MAX_SAFE_INTEGER:r,i=t.bottom,s=void 0===i?0:i;n(this,e),this.top=a,this.bottom=s}return a(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||F.unreadMentionCount>0)&&(F._updateUnreadCount(0,0),this._dispatcher.dispatch(new Hu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==F.unreadMessageCount&&0!==F.unreadMentionCount||(this._dispatcher.dispatch(new Hu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new Hu({channels:[F],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onUnreadMemberStatusUpdated(F)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return n.abrupt("break",337);case 81:return G=t.as(xc),q=G.channelUrl,H=G.deliveredStateUpdate,j=void 0===H?{}:H,V=this._groupChannelCache.isCachedInMemory(q),n.next=85,this.getChannel(q,!0);case 85:if(Q=n.sent,V)for(B in j)Q._updateUndeliveredMemberState(B,j[B]);return Object.keys(j).some((function(e){return e!==dn._sdkState.userId}))&&(this._dispatcher.dispatch(new Hu({channels:[Q],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onUndeliveredMemberStatusUpdated(Q)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",337);case 89:if(K=t.as(Fc),z=K.channelUrl,W=K.channelType,Y=K.event,W!==e.ChannelType.GROUP){n.next=99;break}return n.next=93,this.getChannel(z,!0);case 93:return J=n.sent,n.next=96,this.getMessageFromCache(Y.messageId);case 96:(X=n.sent)&&(X.applyReactionEvent(Y),this._dispatcher.dispatch(new On({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onReactionUpdated(J,Y)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return n.abrupt("break",337);case 100:if(Z=t.as(Gc),($=Z.event).channelType!==e.ChannelType.GROUP){n.next=110;break}return n.next=104,this.getChannel($.channelUrl,!0);case 104:return ee=n.sent,n.next=107,this.getMessageFromCache($.targetMessageId);case 107:(te=n.sent)&&(te.applyThreadInfoUpdateEvent($),this._dispatcher.dispatch(new On({messages:[te],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onThreadInfoUpdated(ee,$)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return n.abrupt("break",337);case 111:ne=t.as(Oc),re=ne.groupChannelMemberCounts,ae=[],ie=k(re),n.prev=114,ie.s();case 116:if((se=ie.n()).done){n.next=125;break}return oe=se.value,ue=oe.channelUrl,ce=oe.memberCount,le=oe.joinedMemberCount,he=oe.updatedAt,n.next=121,this.getChannelFromCache(ue);case 121:(de=n.sent)&&de._setLatestMemberCount(ce,le,he)&&ae.push(de);case 123:n.next=116;break;case 125:n.next=130;break;case 127:n.prev=127,n.t2=n.catch(114),ie.e(n.t2);case 130:return n.prev=130,ie.f(),n.finish(130);case 133:return ae.length>0&&(this._dispatcher.dispatch(new Hu({channels:ae,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelMemberCountChanged(ae)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",337);case 135:if(pe=t.as(qc),fe=pe.event,ve=pe.status,me=pe.channelUrl,ge=pe.channelType,me&&ge){n.next=138;break}return n.abrupt("break",337);case 138:return n.next=140,this.getChannel(me,!0);case 140:return _e=n.sent,this._dispatcher.dispatch(new Fn({event:fe,source:e.MessageEventSource.EVENT_POLL_UPDATED})),He("removed"===ve?function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollDeleted(_e,fe.pollId)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollUpdated(_e,fe)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}),n.abrupt("break",337);case 144:if(ye=t.as(Hc),ke=ye.event,Ee=ye.channelUrl,be=ye.channelType,Ee&&be){n.next=147;break}return n.abrupt("break",337);case 147:return n.next=149,this.getChannel(Ee,!0);case 149:return we=n.sent,this._dispatcher.dispatch(new Gn({event:ke,source:e.MessageEventSource.EVENT_POLL_VOTED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onPollVoted(we,ke)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",337);case 153:if(Ce=t.as(hc),!(xe=Ce.event).isGroupChannelEvent){n.next=325;break}n.t3=xe.category,n.next=n.t3===Eu.CHANNEL_JOIN?158:n.t3===Eu.CHANNEL_LEAVE?167:n.t3===Eu.CHANNEL_OPERATOR_UPDATE?183:n.t3===Eu.CHANNEL_INVITE?194:n.t3===Eu.CHANNEL_DECLINE_INVITE?204:n.t3===Eu.TYPING_START||n.t3===Eu.TYPING_END?212:n.t3===Eu.USER_CHANNEL_MUTE||n.t3===Eu.USER_CHANNEL_UNMUTE?221:n.t3===Eu.USER_CHANNEL_BAN?248:n.t3===Eu.USER_CHANNEL_UNBAN?261:n.t3===Eu.CHANNEL_FREEZE||n.t3===Eu.CHANNEL_UNFREEZE?267:n.t3===Eu.CHANNEL_HIDE?275:n.t3===Eu.CHANNEL_UNHIDE?285:n.t3===Eu.CHANNEL_DELETED?292:n.t3===Eu.CHANNEL_PROP_CHANGED?298:n.t3===Eu.CHANNEL_META_DATA_CHANGED?304:n.t3===Eu.CHANNEL_META_COUNTERS_CHANGED?313:n.t3===Eu.PINNED_MESSAGE_CHANGED?319:325;break;case 158:return n.next=160,this.getChannel(xe.channelUrl,!0);case 160:return Re=n.sent,Te=t.as(fc),Ie=Te.memberCount,Se=Te.joinedMemberCount,Ne=Te.members,Me=!1,Ne.forEach((function(t){Re.isExclusive||Re.isSuper||Re.isBroadcast?Me=Me||Re._setLatestMemberCount(Ie,Se,xe.ts):(t.state=e.MemberState.JOINED,Re.addMember(t,xe.ts),dn._updateJoinedMemberCount(Re)),t.userId===dn._sdkState.userId&&(Re.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new Hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=k(Ne);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Re,r)}}catch(e){n.e(e)}finally{n.f()}Re.isBroadcast&&Me&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 167:if(!(Ae=this._leftChannels.get(xe.channelUrl))){n.next=172;break}n.t4=Ae.channel,n.next=175;break;case 172:return n.next=174,this.getChannel(xe.channelUrl,!0);case 174:n.t4=n.sent;case 175:return Ue=n.t4,Oe=t.as(mc),De=Oe.memberCount,Le=Oe.joinedMemberCount,Pe=Oe.member,Fe=!1,Ge=St.of(this._iid),qe=Ge.appInfo,Ue.isExclusive||Ue.isSuper||Ue.isBroadcast?Fe=Ue._setLatestMemberCount(De,Le,xe.ts):(qe.enabledChannelMemberShipHistory?(Ue.members.find((function(e){return e.userId===Pe.userId})).state=e.MemberState.LEFT,Ue.memberCount=De):Ue.removeMember(Pe),this._updateJoinedMemberCount(Ue)),Pe.userId===this._sdkState.userId?(Ue.myMemberState=e.MemberState.NONE,Ue.invitedAt=0,Ue.joinedAt=0,Ue._updateUnreadCount(0,0),Ue.isPublic?this._dispatcher.dispatch(new Hu({channels:[Ue],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Ue),this._dispatcher.dispatch(new ju({channelUrls:[Ue.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Hu({channels:[Ue],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Ue,Pe),Ue.isBroadcast&&Fe&&e.onChannelMemberCountChanged([Ue])}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 183:return n.next=185,this.getChannel(xe.channelUrl,!0);case 185:Ve=n.sent,Qe=t.as(Uc),Be=Qe.operators,Ke=Be.map((function(e){return e.userId})),ze=k(Ve.members);try{for(ze.s();!(We=ze.n()).done;)(Ye=We.value).role=Ke.includes(Ye.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){ze.e(e)}finally{ze.f()}return Ve.myRole=Ke.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new Hu({channels:[Ve],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Ve,Be)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 194:return n.next=196,this.getChannel(xe.channelUrl,!0);case 196:Je=n.sent,Xe=t.as(yc),Ze=Xe.memberCount,$e=Xe.joinedMemberCount,et=Xe.inviter,(tt=Xe.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),nt=k(tt);try{for(nt.s();!(rt=nt.n()).done;)at=rt.value,Je.isExclusive||Je.isSuper||Je.isBroadcast?Je._setLatestMemberCount(Ze,$e,xe.ts):Je.addMember(at,xe.ts),this._sdkState.userId===at.userId&&(Je.hiddenState=e.HiddenState.UNHIDDEN,Je.myMemberState!==e.MemberState.JOINED&&(Je.myMemberState=e.MemberState.INVITED),Je.invitedAt=xe.ts)}catch(e){nt.e(e)}finally{nt.f()}return this._dispatcher.dispatch(new Hu({channels:[Je],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Je,et,tt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 204:return n.next=206,this.getChannel(xe.channelUrl,!0);case 206:return it=n.sent,st=t.as(Ec),ot=st.memberCount,ut=st.joinedMemberCount,ct=st.inviter,lt=st.invitee,it.isExclusive||it.isSuper||it.isBroadcast?it._setLatestMemberCount(ot,ut,xe.ts):it.removeMember(lt),this._sdkState.userId===lt.userId?(it.invitedAt=0,it.myMemberState=e.MemberState.NONE,it.isPublic?this._dispatcher.dispatch(new Hu({channels:[it],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new ju({channelUrls:[it.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Hu({channels:[it],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(it,ct,lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 212:return n.next=214,this.getChannel(xe.channelUrl,!0);case 214:return ht=n.sent,dt=xe.category===Eu.TYPING_START,pt=t.as(dt?Nc:Ac),ft=pt.user,ht._updateTypingStatus(ft,dt?xe.ts:0),this._dispatcher.dispatch(new Hu({channels:[ht],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 221:return n.next=223,this.getChannel(xe.channelUrl,!0);case 223:vt=n.sent,mt=xe.category===Eu.USER_CHANNEL_MUTE,gt=t.as(mt?Mo:Uo),(_t=gt.user).userId===this._sdkState.userId&&(vt.myMutedState=mt?e.MutedState.MUTED:e.MutedState.UNMUTED),yt=k(vt.members),n.prev=228,yt.s();case 230:if((kt=yt.n()).done){n.next=237;break}if((Et=kt.value).userId!==_t.userId){n.next=235;break}return Et.isMuted=mt,n.abrupt("break",237);case 235:n.next=230;break;case 237:n.next=242;break;case 239:n.prev=239,n.t5=n.catch(228),yt.e(n.t5);case 242:return n.prev=242,yt.f(),n.finish(242);case 245:return this._dispatcher.dispatch(new Hu({channels:[vt],source:mt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){mt?e.onUserMuted(vt,_t):e.onUserUnmuted(vt,_t)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 248:if(!(bt=this._leftChannels.get(xe.channelUrl))){n.next=253;break}n.t6=bt.channel,n.next=256;break;case 253:return n.next=255,this.getChannel(xe.channelUrl,!0);case 255:n.t6=n.sent;case 256:return wt=n.t6,this._markAsLeave(wt),Ct=t.as(Do),xt=Ct.user,He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(wt,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 261:return n.next=263,this.getChannel(xe.channelUrl,!0);case 263:return Rt=n.sent,Tt=t.as(Po),It=Tt.user,He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(Rt,It)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 267:return n.next=269,this.getChannel(xe.channelUrl,!0);case 269:return Nt=n.sent,Mt=t.as(Go),At=Mt.freeze,Nt.isFrozen=At,this._dispatcher.dispatch(new Hu({channels:[Nt],source:At?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){At?e.onChannelFrozen(Nt):e.onChannelUnfrozen(Nt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 275:return n.next=277,this.getChannel(xe.channelUrl,!0);case 277:return Ut=n.sent,Ot=t.as(Ic),Dt=Ot.allowAutoUnhide,Lt=Ot.hidePreviousMessages,Pt=Ot.messageOffsetTimestamp,null!==Dt&&(Ut.hiddenState=Dt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Lt&&Lt&&Ut._updateUnreadCount(0,0),null!==Pt&&(Ut.messageOffsetTimestamp=Pt),this._dispatcher.dispatch(new Hu({channels:[Ut],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Ut)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 285:return n.next=287,this.getChannel(xe.channelUrl,!0);case 287:return(Ft=n.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new Hu({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 292:return n.next=294,this.getChannel(xe.channelUrl,!0);case 294:return Gt=n.sent,this._dispatcher.dispatch(new ju({channelUrls:[xe.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Gt.url,Gt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 298:return n.next=300,this.getChannelWithoutCache(xe.channelUrl,!0);case 300:return qt=n.sent,this._dispatcher.dispatch(new Hu({channels:[qt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 304:return n.next=306,this.getChannel(xe.channelUrl,!0);case 306:return Ht=n.sent,jt=t.as(mo),Vt=jt.created,Qt=jt.updated,Bt=jt.deleted,Vt&&Ht._upsertCachedMetaData(Vt,xe.ts),Qt&&Ht._upsertCachedMetaData(Qt,xe.ts),Bt&&Ht._removeFromCachedMetaData(Bt,xe.ts),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated(Ht,Vt),Qt&&e.onMetaDataUpdated(Ht,Qt),Bt&&e.onMetaDataDeleted(Ht,Bt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 313:return n.next=315,this.getChannel(xe.channelUrl,!0);case 315:return Kt=n.sent,zt=t.as(To),Wt=zt.created,Yt=zt.updated,Jt=zt.deleted,He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Wt&&e.onMetaCounterCreated(Kt,Wt),Yt&&e.onMetaCounterUpdated(Kt,Yt),Jt&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",325);case 319:return n.next=321,this.getChannel(xe.channelUrl,!0);case 321:return Xt=n.sent,Zt=t.as(Qc),$t=Zt.pinnedMessageIds,en=Zt.latestPinnedMessage,(tn=Zt.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=$t,Xt.lastPinnedMessage=en,Xt._pinnedMessagesUpdatedAt=tn,this._dispatcher.dispatch(new Hu({channels:[Xt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._groupChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelChanged(Xt)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))})),He((function(){return E(dn,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),n.abrupt("break",325);case 325:return n.abrupt("break",337);case 326:rn=t.as(Ua),an=rn.event,n.t7=an.category,n.next=n.t7===fa.USER_BLOCK?330:n.t7===fa.USER_UNBLOCK?333:336;break;case 330:return sn=Ma.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),n.abrupt("break",336);case 333:return cn=Ma.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,hn=cn.blockee,this._groupChannelCache.unblock(ln.userId,hn.userId),n.abrupt("break",336);case 336:return n.abrupt("break",337);case 337:n.next=343;break;case 339:if(n.prev=339,n.t8=n.catch(0),!R(n.t8)){n.next=343;break}throw n.t8;case 343:case"end":return n.stop()}}),n,this,[[0,339],[19,30,33,36],[114,127,130,133],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),n.prev=1,n.next=4,this.getChannelFromCache(e);case 4:if(!(r=n.sent)){n.next=7;break}return n.abrupt("return",r);case 7:n.next=11;break;case 9:n.prev=9,n.t0=n.catch(1);case 11:return n.next=13,this.getChannelWithoutCache(e,t);case 13:return n.abrupt("return",n.sent);case 14:case"end":return n.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return ht(M("string",t)).throw(T.invalidParameters),a=new zu({channelUrl:t,isInternalCall:n}),r.next=4,this._requestQueue.send(a);case 4:i=r.sent,s=i.as(Wu),o=s.channel,u=o.unreadMessageCount,c=o.unreadMentionCount,r.t0=o.myCountPreference,r.next=r.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:r.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:r.t0===e.CountPreference.OFF?14:17;break;case 10:return c=0,r.abrupt("break",17);case 12:return u=0,r.abrupt("break",17);case 14:return u=0,c=0,r.abrupt("break",17);case 17:return o._updateUnreadCount(u,c),r.next=20,this.upsertChannelsToCache([o]);case 20:return r.abrupt("return",o);case 21:case"end":return r.stop()}}),r,this)})))}},{key:"getMyGroupChannels",value:function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Yu(Object.assign(Object.assign({},n),{userId:this._sdkState.userId,token:t,limit:r})),e.next=3,this._requestQueue.send(i);case 3:return s=e.sent,o=s.as(Ju),u=o.channels,c=o.token,this._dispatcher.dispatch(new Hu({channels:u,source:a})),e.abrupt("return",{channels:u,token:c});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getMessagesFromCache",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Vr;return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n});case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Vr;return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0});case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:t});case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,t,n,r){return E(this,void 0,void 0,regeneratorRuntime.mark((function a(){return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._messageCache.countBetween(e,t,new Vc({top:n,bottom:r}));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),a,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var a,i,s,o,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=Object.assign(Object.assign({},Iu),n),ht((M("string",t)||M("number",t))&&Su(a)).throw(T.invalidParameters),i=new Bu(J({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:a})),e.next=5,this._requestQueue.send(i);case 5:return s=e.sent,o=s.as(Ku),u=o.updatedChannels,c=o.deletedChannelUrls,u.length>0&&this._dispatcher.dispatch(new Hu({channels:u,source:r})),c.length>0&&this._dispatcher.dispatch(new ju({channelUrls:c,source:r})),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Nu),e),ht(Mu(n)).throw(T.invalidParameters),r=new Xu({userId:this._sdkState.userId,filter:n}),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Zu),s=i.groupChannelCount,t.abrupt("return",s);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Uu),e),ht(Ou(n)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new $u({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,t.abrupt("return",o.as(ec));case 8:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new tc({userId:n.userId}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(nc),o=s.unreadCount,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Du),e),ht(Lu(n)).throw(T.invalidParameters),r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new rc({userId:a.userId,filter:n}),t.next=6,i.send(s);case 6:return o=t.sent,u=o.as(ac),c=u.unreadCount,t.abrupt("return",c);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Pu),e),ht(Fu(n)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new ic(n),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(sc),u=o.count,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=St.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=St.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=St.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),ht(Tu(n)).throw(T.invalidParameters),n.isPublic||(n.accessCode=null),r=new uc(Object.assign({userId:this._sdkState.userId},n)),t.next=6,this._requestQueue.send(r);case 6:return a=t.sent,i=a.as(cc),s=i.channel,t.next=10,this.upsertChannelsToCache([s]);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Date.now(),ht(t-this._markAsReadAllLastSentAt>=1e3).throw(T.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new lc({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(n);case 6:r=this._groupChannelCache.channels,a=k(r);try{for(a.s();!(i=a.n()).done;)(s=i.value)._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0)}catch(e){a.e(e)}finally{a.f()}if(!(r.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(r);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now(),ht(O("string",e)&&n-this._markAsReadAllLastSentAt>=1e3).throw(T.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new lc({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,i=[],s=k(a);try{for(s.s();!(o=s.n()).done;)u=o.value,e.includes(u.url)&&(u._updateUnreadMemberState(this._sdkState.userId,n),u._updateUnreadCount(0,0),i.push(u))}catch(e){s.e(e)}finally{s.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return n=t.sent,t.next=5,n.markAsDelivered();case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Bc[e]}}]),t}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gu||(Gu={}));var zc=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this))._worker=null,i._state=Gu.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=a,i}return a(r,[{key:"isIdle",get:function(){return this._state===Gu.IDLE}},{key:"isRunning",get:function(){return this._state===Gu.RUNNING}},{key:"isDone",get:function(){return this._state===Gu.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:n=t.sent,this._retryCount=0,this.dispatch("progress",n),n.hasNext?this._run(n.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount=this._limit,s.nextToken=this._metadata.range.top,this._metadata.previousComplete=!s.hasNext,f.debug("message background prev sync progress",s),n.next=17,this.saveMetadata();case 17:n.next=26;break;case 19:if(n.prev=19,n.t0=n.catch(5),f.debug("message background prev sync error",n.t0),!(n.t0 instanceof T&&n.t0.isInvalidTokenError)){n.next=25;break}return n.next=25,this.clearMetadata();case 25:throw n.t0;case 26:n.next=29;break;case 28:s.hasNext=!1;case 29:return n.abrupt("return",s);case 30:case"end":return n.stop()}}),n,this,[[5,19]])})))})),this._nextSync=new zc(v,(function(t){return E(a,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={hasNext:!0,nextToken:0},n.next=3,this.loadMetadata();case 3:return f.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),n.prev=4,o=Yn.of(this._iid),n.next=8,o.getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(a=this._metadata.range)||void 0===a?void 0:a.bottom)&&void 0!==i?i:t,{prevResultSize:0,nextResultSize:this._limit,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},e.MessageEventSource.SYNC_MESSAGE_BACKGROUND);case 8:return u=n.sent,this.extendRange(u),s.hasNext=u.length>=this._limit,s.nextToken=this._metadata.range.bottom,f.debug("message background next sync progress",s),n.next=15,this.saveMetadata();case 15:n.next=21;break;case 17:throw n.prev=17,n.t0=n.catch(4),f.debug("message background next sync error",n.t0),n.t0;case 21:return n.abrupt("return",s);case 22:case"end":return n.stop()}}),n,this,[[4,17]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,g(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,g(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={range:new Vc(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!r&&r.previousComplete};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n,r,a=St.of(this._iid),i=a.logger;a.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now()))}},{key:"pause",value:function(){St.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Jc[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Jc[e]||(Jc[e]={}),Jc[e][n.url]||(Jc[e][n.url]=new t({_iid:e,channel:n})),Jc[e][n.url].ref++,Jc[e][n.url]}},{key:"clear",value:function(e,t){Jc[e]&&Jc[e][t]&&(Jc[e][t].close(),delete Jc[e])}}]),t}(),Zc={},$c=function(){function t(r){var a=this,i=r._iid,s=r.channel;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=s;var o,u,c=St.of(this._iid),l=c.logger,h=c.sdkState,d=c.dispatcher;this._metadataKey=(o=h.userId,u=s.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new zc(p,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return l.debug("message changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),t.prev=4,a=Yn.of(this._iid),t.next=8,a.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,s=i.updatedMessages,o=i.deletedMessageIds,u=i.hasMore,c=i.token,r.hasNext=u,r.nextToken=c,(s.length>0||o.length>0)&&(this._metadata.token=c),l.debug("message changelog sync progress",r),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),l.debug("message changelog sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",r);case 29:case"end":return t.stop()}}),t,this,[[4,21]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=St.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){St.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){var e=St.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Zc[this._iid][this._channel.url])}}],[{key:"of",value:function(e,n){return Zc[e]||(Zc[e]={}),Zc[e][n.url]||(Zc[e][n.url]=new t({_iid:e,channel:n})),Zc[e][n.url].ref++,Zc[e][n.url]}},{key:"clear",value:function(e,t){Zc[e]&&Zc[e][t]&&(Zc[e][t].close(),delete Zc[e])}}]),t}(),el=function(e){i(r,e);var t=p(r);function r(e){var a,i,s,o,u,c,l;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(_n(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=J({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(i=e.threshold)&&void 0!==i?i:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0}),a}return a(r)}(Z),tl=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c;return n(this,r),(i=t.call(this,e,a)).isHugeGap=a.is_huge_gap,i.prevMessages=(null!==(s=a.prev_messages)&&void 0!==s?s:[]).map((function(t){return mn(e,t)})),i.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,i.nextMessages=(null!==(u=a.next_messages)&&void 0!==u?u:[]).map((function(t){return mn(e,t)})),i.nextHasmore=null!==(c=a.next_hasmore)&&void 0!==c&&c,i}return a(r)}($),nl=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},rl=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},al=function(e,t,n){if(e.length>0){var r=rl(e,t);if(r<0){for(var a=0,i=e.length-1,s=Math.floor((a+i)/2);a0)i=s,s=Math.floor((a+i)/2);else{if(!(o<0))return{place:s,contains:e[s].isIdentical(t)};a=s+1,s=Math.floor((a+i)/2)}}return{place:il(e[s],t,n)>0?s:s+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},il=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name.localeCompare(n.name)}},sl=function(e,t){return t instanceof nn?e.findIndex((function(e){return e instanceof nn&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},ol=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},ul=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(i<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},cl={},ll=function(){function e(t){var r=this,a=t._iid,i=t.channel,s=t.hasPollMessage;n(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=a,this._channel=i;var o,u,c=St.of(this._iid),l=c.logger,h=c.sdkState,d=c.dispatcher;this._metadataKey=(o=h.userId,u=i.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new zc(p,(function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,u,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(l.debug("poll changelog sync from",null===(t=this._metadata)||void 0===t?void 0:t.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,s();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return r={hasNext:!1,nextToken:0},e.abrupt("return",r);case 12:return this._metadata||(a=St.of(this._iid),i=a.firstConnectedAt,this._metadata={token:i}),e.prev=13,o=Tr.of(this._iid),e.next=17,o.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return u=e.sent,c=u.hasMore,h=u.token,n.hasNext=c,n.nextToken=h,this._metadata.token=h,l.debug("poll changelog sync progress",n),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),l.debug("poll changelog sync error",e.t1),!(e.t1 instanceof T&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",n);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)r.resume();else r.pause()}))}return a(e,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata=r?{token:r.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){St.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){St.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cl[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return cl[t]||(cl[t]={}),cl[t][n.url]||(cl[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cl[t][n.url].ref++,cl[t][n.url]}}]),e}(),hl=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var dl,pl,fl,vl=function(){function e(){n(this,e)}return a(e,[{key:"_invokeResponse",value:function(e,t,n){var r=this;He((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next="local"===r.t0?3:"remote"===r.t0?5:7;break;case 3:return this._onCacheResult(t,n),r.abrupt("break",7);case 5:return this._onApiResult(t,n),r.abrupt("break",7);case 7:case"end":return r.stop()}}),r,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),ml=function(){function t(r,a){var i=this,s=a.channel,o=a.filter,u=a.startingPoint,c=a.limit;n(this,t),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._iid=r,this._key="mc-".concat(B()),this.filter=null!=o?o:new zr,this._channel=s,this._syncRange=new Vc({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof u?u:Date.now()+hl,this._limit=c||Vr;var l=Kc.of(this._iid);l.subscribeGroupChannelEvent(this._key,{onUpdate:function(t,n){var r=rl(t,i._channel);if(r>=0&&(He((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new Wc(n),this._channel=t[r],(null===(a=this._handler)||void 0===a?void 0:a.onChannelUpdated)&&this._handler.onChannelUpdated(i,this.channel);case 3:case"end":return e.stop()}}),e,this)})))})),n===e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED)){var a=!1;for(var s in i._messages){if(i._messages[s].createdAt>=i._channel.messageOffsetTimestamp){a=!0;var o=parseInt(s);if(o>0){var u=i._messages.splice(0,o);i._removeMessagesFromView(u.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!a&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}},onRemove:function(e,t){e.indexOf(i.channel.url)>=0&&He((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Wc(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(r,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))}))}}),l.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=k(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(Un(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var h=St.of(this._iid).cacheContext;!this._channel.isSuper&&h.localCacheEnabled&&(this._backgroundSync=Xc.of(this._iid,this._channel),this._backgroundSync.resume()),this._changelogSync=$c.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=ll.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new zc(this._key,(function(t){return E(i,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._getRemoteMessages(t,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL});case 2:if(!((r=n.sent).length>0)){n.next=7;break}return a=Math.min.apply(Math,g(r.map((function(e){return e.createdAt})))),this._syncRange.extends(a),n.abrupt("return",{hasNext:r.length>=this._limit&&this.viewTop0)){n.next=7;break}return a=Math.max.apply(Math,g(r.map((function(e){return e.createdAt})))),this._syncRange.extends(a),n.abrupt("return",{hasNext:!(r.length>=this._limit&&this._hasNext)||this.viewBottom>a,nextToken:this._syncRange.bottom});case 7:return n.abrupt("return",{hasNext:!1,nextToken:0});case 8:case"end":return n.stop()}}),n,this)})))}));var d=St.of(this._iid),p=d.dispatcher,f=d.logger;this._connectionEventContext=p.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)f.debug("check huge gap"),i._checkHugeGap();else i._prevFill.stop(),i._nextFill.stop()}))}return a(t,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return g(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,g(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,g(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(t,n){var r,a=this,i=this._filterUnderOffsetMessage(t),s=[],o=[],u=k(i);try{for(u.s();!(r=u.n()).done;){var c=r.value;if(n===e.MessageEventSource.SYNC_MESSAGE_FILL){if(c.messageId>0){if(sl(this._messages,c)<0){sl(this._unsentMessages,c)<0&&s.push(c);var l=ul(this._messages,c);this._messages.splice(l,0,c)}}else if(c instanceof nn){sl(this._unsentMessages,c)<0&&sl(this._messages,c)<0&&(this._unsentMessages.push(c),s.push(c))}}else if(c.messageId>0){var h=sl(this._messages,c);if(h<0){var d=sl(this._unsentMessages,c);d<0?s.push(c):(this._unsentMessages.splice(d,1),o.push(c));var p=ul(this._messages,c);this._messages.splice(p,0,c)}else o.push(c),this._messages[h]=c;if(c.updatedAt>0){var f=this._updateChildMessagesInView(c);o.push.apply(o,g(f))}}else if(c instanceof nn){var v=sl(this._unsentMessages,c);v<0?sl(this._messages,c)<0&&(this._unsentMessages.push(c),s.push(c)):(o.push(c),this._unsentMessages[v]=c)}}}catch(e){u.e(e)}finally{u.f()}Un(n)&&He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Yc(n),s.length>0&&(null===(t=this._handler)||void 0===t||t.onMessagesAdded(a,this.channel,s)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,o));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,t){var n,r=this,a=[],i=k(e);try{for(i.s();!(n=i.n()).done;){var s=n.value,o=ol(this._messages,s.messageId);if(o>=0){var u=this._messages[o];u&&u.applyPoll(s),a.push(u)}}}catch(e){i.e(e)}finally{i.f()}return a.length>0&&Un(t)&&He((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Yc(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(r,this.channel,a));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_applyPollUpdateEventToView",value:function(e,t){var n=this,r=ol(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&Un(t)&&He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Yc(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(r,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,t){var n=this,r=ol(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&Un(t)&&He((function(){return E(n,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Yc(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(r,this.channel,[a]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,t){var n,r=this,a=[],i=[],s=k(e);try{for(s.s();!(n=s.n()).done;){var o=n.value;if(o.messageId>0){var u=sl(this._messages,o);if(u>=0)a.push(o),this._messages[u]=o;else{var c=sl(this._unsentMessages,o);if(c>=0){var l=this._unsentMessages.splice(c,1);if(this.hasNext&&l.length>0)i.push(l[0]);else{a.push(o);var h=ul(this._messages,o);this._messages.splice(h,0,o)}}}}else if(o instanceof nn){var d=sl(this._unsentMessages,o);d>=0&&(a.push(o),this._unsentMessages[d]=o)}}}catch(e){s.e(e)}finally{s.f()}return Un(t)&&He((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Yc(t),a.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(s,this.channel,a):i.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(s,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeMessagesFromView",value:function(e,t){var n,r=this,a=[],i=[],s=k(e);try{var o=function(){var e=n.value,t=r._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var s=r._messages[t];a.push(s.messageId),i.push(s),r._messages.splice(t,1)}};for(s.s();!(n=s.n()).done;)o()}catch(e){s.e(e)}finally{s.f()}return Un(t)&&i.length>0&&He((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Yc(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(r,this.channel,a,i);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,i=void 0===a?0:a;return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,a,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Kc.of(this._iid),!(r>0)){t.next=7;break}return t.next=4,n.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r);case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:if(a=t.t0,!(i>0)){t.next=15;break}return t.next=12,n.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:t.t1=t.sent,t.next=16;break;case 15:t.t1=[];case 16:if(s=t.t1,!(a.length>0&&s.length>0)){t.next=27;break}o=a.map((function(e){return e.messageId})),t.t2=regeneratorRuntime.keys(s);case 20:if((t.t3=t.t2()).done){t.next=27;break}if(u=t.t3.value,!o.includes(s[u].messageId)){t.next=25;break}return s.splice(parseInt(u),1),t.abrupt("break",27);case 25:t.next=20;break;case 27:return t.abrupt("return",[].concat(g(a),g(s)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return t.stop()}}),t,this)})))}},{key:"_getRemoteMessages",value:function(t,n){var r=n.prevLimit,a=void 0===r?0:r,i=n.nextLimit,s=void 0===i?0:i,o=n.source,u=void 0===o?e.MessageEventSource.REQUEST_MESSAGE:o,c=n.reverse,l=void 0!==c&&c;return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Yn.of(this._iid),!(a>0||s>0)){e.next=7;break}return e.next=4,n.getMessagesByTimestamp(this._channel.url,this._channel.channelType,t,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:a,nextResultSize:s,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=[];case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p,f,v,m,_,y=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this._messages.length>0)){t.next=16;break}return n=this.viewTop,r=this._syncRange.top,a=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,s=Kc.of(this._iid),t.next=8,s.getCachedMessageCountBetween(this._channel.url,this.filter,n,r);case 8:return o=t.sent,t.next=11,s.getCachedMessageCountBetween(this._channel.url,this.filter,a,i);case 11:return u=t.sent,t.next=14,qe((function(){return E(y,void 0,void 0,regeneratorRuntime.mark((function t(){var s,c,l,h,d,p,f,v,m,_,y,k,b,w,C,x,R,T=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=St.of(this._iid),c=s.dispatcher,l=s.requestQueue,h=new el(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:r,prevCount:o,nextStart:a,nextEnd:i,nextCount:u},this.filter)),t.next=4,l.send(h);case 4:d=t.sent,p=d.as(tl),f=p.isHugeGap,v=p.prevMessages,m=void 0===v?[]:v,_=p.prevHasMore,y=p.nextMessages,k=void 0===y?[]:y,b=p.nextHasmore,f?He((function(){return E(T,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._handler)||void 0===t||t.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=_,this._hasNext=b,w=this.viewTop,C=this.viewBottom,x=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,w].concat(g(m.map((function(e){return e.createdAt}))))),R=Math.max.apply(Math,[0,C].concat(g(k.map((function(e){return e.createdAt}))))),c.dispatch(new On({messages:m,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),c.dispatch(new On({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(x,R),wR&&this._nextFill.start(R));case 7:case"end":return t.stop()}}),t,this)})))}),1);case 14:t.next=22;break;case 16:return c=Math.floor(this._limit/2),l=Date.now(),t.next=20,this._getRemoteMessages(l,{prevLimit:c,nextLimit:c,source:e.MessageEventSource.SYNC_MESSAGE_FILL});case 20:if((h=t.sent).length>0){for(p=h.map((function(e){return e.createdAt})),f=0,v=0,m=0;m=l&&v++;this._hasPrevious=f>=c,this._hasNext=v>=c,(d=this._syncRange).extends.apply(d,g(h.map((function(e){return e.createdAt})))),this._addMessagesToView(h,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;case 22:case"end":return t.stop()}}),t,this)})))}},{key:"_loadUnsentMessages",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Kc.of(this._iid),e.next=3,t.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Kc.of(this._iid),e.next=3,t.getPollMessagesFromCache(this._channel.url,Date.now()+hl,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"initialize",value:function(t){var n=this,r=new vl;this._messages=[],this._unsentMessages=[],this._syncRange=new Vc({}),this._hasNext=!0,this._hasPrevious=!0;var a=Math.floor(this._limit/2);if(t===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:a,nextLimit:a}).then((function(t){return E(n,void 0,void 0,regeneratorRuntime.mark((function n(){var a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=this._filterUnderOffsetMessage(t),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=4,this._loadUnsentMessages();case 4:r._invokeResponse("local",null,a);case 5:case"end":return n.stop()}}),n,this)})))})).catch((function(e){if(R(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){n._getRemoteMessages(n._startingPoint,{prevLimit:a,nextLimit:a,reverse:!0}).then((function(t){n._messages=[];var i=n._filterUnderOffsetMessage(t);if(i.length>0){for(var s,o=i.map((function(e){return e.createdAt})),u=0,c=0,l=0;l=n._startingPoint&&c++}n._hasPrevious=u>=a,n._hasNext=c>=a,(s=n._syncRange).extends.apply(s,g(i.map((function(e){return e.createdAt})))),n._addMessagesToView(i,e.MessageEventSource.REQUEST_MESSAGE)}else n._hasPrevious=!1,n._hasNext=!1;r._invokeResponse("remote",null,i)})).catch((function(e){if(R(e))throw e;r._invokeResponse("remote",e,null)}))}));return r}},{key:"loadPrevious",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._hasPrevious){t.next=14;break}return n=this.viewTop,r=[],t.next=5,je((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(n,{prevLimit:this._limit});case 3:e.t1=e.sent,r=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==r.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(r)){t.next=11;break}return t.next=8,je((function(){return E(i,void 0,void 0,regeneratorRuntime.mark((function e(){var t,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getRemoteMessages(n,{prevLimit:this._limit});case 3:e.t1=e.sent,r=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1),this._hasPrevious=r.length>=this._limit,r.length>0&&((i=this._syncRange).extends.apply(i,g(r.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(r,e.MessageEventSource.REQUEST_MESSAGE),t.next=13;break;case 11:this._hasPrevious=r.length>=this._limit,r.length>0&&((a=this._syncRange).extends.apply(a,g(r.map((function(e){return e.createdAt})))),this._addMessagesToView(r,e.MessageEventSource.REQUEST_MESSAGE));case 13:return t.abrupt("return",r);case 14:return t.abrupt("return",[]);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"loadNext",value:function(){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._hasNext){n.next=2;break}return n.abrupt("return",[]);case 2:return r=this.viewBottom,a=[],n.next=6,je((function(){return E(s,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{nextLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==a.length&&(null===(t=this._backgroundSync)||void 0===t?void 0:t.isWrappingMessages(a))){n.next=12;break}return n.next=9,je((function(){return E(s,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getRemoteMessages(r,{nextLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1),this._hasNext=a.length>=this._limit,a.length>0&&((i=this._syncRange).extends.apply(i,g(a.map((function(e){return e.createdAt})))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=14;break;case 12:this._hasNext=a.length>=this._limit,a.length>0&&((i=this._syncRange).extends.apply(i,g(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 14:return n.abrupt("return",a);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"removeFailedMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Kc.of(this._iid),t.next=3,n.removeFailedMessageFromCache(e);case 3:(r=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(r,1);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"dispose",value:function(){var e,t,n;St.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var r=Kc.of(this._iid);r.unsubscribeGroupChannelEvent(this._key),r.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),t}(),gl={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},_l=function(e){return M("string",e.coverUrl,!0)&&(L(e.coverImage)||M("string",e.coverImage)||null===e.coverImage)&&M("boolean",e.isDistinct,!0)&&M("boolean",e.isPublic,!0)&&M("boolean",e.isDiscoverable,!0)&&M("string",e.accessCode,!0)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&O("string",e.operatorUserIds,!0)&&M("number",e.messageSurvivalSeconds,!0)},yl={hidePreviousMessages:!1,allowAutoUnhide:!0},kl=function(e){return M("boolean",e.hidePreviousMessages)&&M("boolean",e.allowAutoUnhide)},El=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=x.GET,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/members"),a.params={token:s,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return a(r)}(Z),bl=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.members=[];var s=a.next,o=a.members;return i.token=s,o&&o.length>0&&(i.members=o.map((function(t){return new yu(e,t)}))),i}return a(r)}($);e.MutedMemberFilter=void 0,(dl=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",dl.MUTED="muted",dl.UNMUTED="unmuted",e.MemberListOrder=void 0,(pl=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",pl.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(fl=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",fl.JOINED="joined_only",fl.INVITED="invited_only",fl.INVITED_BY_FRIEND="invited_by_friend",fl.INVITED_BY_NON_FRIEND="invited_by_non_friend";var wl,Cl,xl,Rl=function(t){i(o,t);var r=p(o);function o(t,a,i){var s,u,c,l,h;return n(this,o),(s=r.call(this,t,a,e.ChannelType.GROUP,i)).mutedMemberFilter=e.MutedMemberFilter.ALL,s.memberStateFilter=e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null,s.operatorFilter=e.OperatorFilter.ALL,s.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s.mutedMemberFilter=null!==(u=i.mutedMemberFilter)&&void 0!==u?u:e.MutedMemberFilter.ALL,s.memberStateFilter=null!==(c=i.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,s.nicknameStartsWithFilter=null!==(l=i.nicknameStartsWithFilter)&&void 0!==l?l:null,s.order=null!==(h=i.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,s}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&A(e.MutedMemberFilter,this.mutedMemberFilter)&&A(e.MemberStateFilter,this.memberStateFilter)&&(M("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&A(e.OperatorFilter,this.operatorFilter)&&A(e.MemberListOrder,this.order)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new El(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(bl),s=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(or),Tl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.userId,o=e.accessCode;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/accept"),a.params={user_id:s,access_code:o},a}return a(r)}(Z),Il=function(t){i(s,t);var r=p(s);function s(t,a){var i;return n(this,s),(i=r.call(this,t,a)).channel=new hh(t,a),i.channel.myMemberState=e.MemberState.JOINED,i}return a(s)}($),Sl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,p=e.data,f=e.customType,v=e.operatorUserIds,m=e.messageSurvivalSeconds;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i)),a.params=J({is_distinct:s,is_public:o,is_discoverable:u,name:d,data:p,custom_type:f,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:m}),a}return a(r)}(Z),Nl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new hh(e,a),i}return a(r)}($),Ml=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=x.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),Al=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=x.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/hide"),a}return a(r)}(Z),Ul=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl,o=e.countPreference;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/count_preference/").concat(encodeURIComponent(s)),a.params={count_preference:o},a}return a(r)}(Z),Ol=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).countPreference=a.count_preference,i}return a(r)}($),Dl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=x.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(i),"/reset_user_history"),a}return a(r)}(Z),Ll=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).messageOffsetTimestamp=null;var s=a.ts_message_offset;return i.messageOffsetTimestamp=null!=s?s:null,i}return a(r)}($),Pl=Object.assign(Object.assign({},Vs),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Fl=function(e){return Qs(e)&&M("number",e.scheduledAt,!0)&&(L(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Gl=Object.assign(Object.assign({},Bs),{scheduledAt:null}),ql=function(e){return Ks(e)&&M("number",e.scheduledAt,!0)},Hl=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return a.method=x.PUT,a.path="".concat(_n(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),a.params=J({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:At.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return rn.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Wt.payloadify(e)})),apple_critical_alert_options:Xt.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),a}return a(s)}(Z),jl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).message=new gn(e,a),i}return a(r)}($),Vl=function(t){i(s,t);var r=p(s);function s(t){var a,i;n(this,s),a=r.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return a.method=x.PUT,a.path="".concat(_n(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),a.params=J({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:At.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Wt.payloadify(e)})),apple_critical_alert_options:Xt.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),a}return a(s)}(Z),Ql=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=x.DELETE,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return a(r)}(Z),Bl=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r),a=t.call(this);var i=e.channelType,s=e.channelUrl,o=e.scheduledMessageId;return a.method=x.POST,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return a(r)}(Z),Kl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl,o=e.pushTriggerOption;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a.params={push_trigger_option:o},a}return a(r)}(Z),zl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return a(r)}($),Wl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.userId,s=e.channelUrl;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(ke,"/").concat(encodeURIComponent(i),"/push_preference/").concat(encodeURIComponent(s)),a}return a(r)}(Z),Yl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,i.enabled=a.enable,i}return a(r)}($),Jl=function(e){return M("string",e.title,!0)&&hn(e.data)&&M("boolean",e.allowUserSuggestion,!0)&&M("boolean",e.allowMultipleVotes,!0)&&M("number",e.closeAt,!0)},Xl=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a.params={title:s,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return a(r)}(Z),Zl=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),$l=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),eh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/close"),a}return a(r)}(Z),th=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),nh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.channelType,o=e.pollId,u=e.optionText;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(Ne,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:i,channel_type:s,text:u},a}return a(r)}(Z),rh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),ah=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.pollOptionId,o=e.optionText;return n(this,r),(a=t.call(this)).method=x.PUT,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={text:o},a}return a(r)}(Z),ih=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).poll=new pn(e,a),i}return a(r)}($),sh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.pollId,s=e.pollOptionId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(Ne,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a}return a(r)}(Z),oh=function(t){i(s,t);var r=p(s);function s(t){var a=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return n(this,s),r.call(this,{code:"VOTE",ackRequired:!0,payload:J({req_id:a,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return a(s)}(le),uh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return n(this,r),(a=t.call(this)).method=x.POST,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return a(r)}(Z),ch=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelType,s=e.channelUrl,o=e.messageId;return n(this,r),(a=t.call(this)).method=x.DELETE,a.path="".concat(_n(i),"/").concat(encodeURIComponent(s),"/messages/").concat(o,"/pin"),a}return a(r)}(Z);e.CountPreference=void 0,(wl=e.CountPreference||(e.CountPreference={})).ALL="all",wl.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",wl.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",wl.OFF="off",e.MutedState=void 0,(Cl=e.MutedState||(e.MutedState={})).MUTED="muted",Cl.UNMUTED="unmuted",e.HiddenState=void 0,(xl=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",xl.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",xl.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var lh,hh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,_,y,k,E,b,w,C,x,R;(n(this,o),(i=r.call(this,t,a))._unreadMemberStateMap=new Map,i._undeliveredMemberStateMap=new Map,i._typingStatus=new Map,i._lastMemberCountUpdated=0,i._typingStarted=0,i._typingEnded=0,i.isDistinct=!1,i.isSuper=!1,i.isBroadcast=!1,i.isExclusive=!1,i.isPublic=!1,i.isDiscoverable=!0,i.isAccessCodeRequired=!1,i.isPushEnabled=!1,i.unreadMessageCount=0,i.unreadMentionCount=0,i.members=[],i.memberCount=0,i.joinedMemberCount=0,i.hiddenState=e.HiddenState.UNHIDDEN,i.lastMessage=null,i.messageOffsetTimestamp=0,i.messageSurvivalSeconds=-1,i.myMemberState=e.MemberState.NONE,i.myRole=e.Role.NONE,i.myMutedState=e.MutedState.UNMUTED,i.myLastRead=0,i.myCountPreference=e.CountPreference.ALL,i.myPushTriggerOption=e.PushTriggerOption.DEFAULT,i.inviter=null,i.invitedAt=0,i.joinedAt=0,i.pinnedMessageIds=[],i.lastPinnedMessage=null,i._pinnedMessagesUpdatedAt=0,i.channelType=e.ChannelType.GROUP,i.isDistinct=null!==(s=a.is_distinct)&&void 0!==s&&s,i.isSuper=null!==(u=a.is_super)&&void 0!==u&&u,i.isBroadcast=null!==(c=a.is_broadcast)&&void 0!==c&&c,i.isExclusive=null!==(l=a.is_exclusive)&&void 0!==l&&l,i.isPublic=null!==(h=a.is_public)&&void 0!==h&&h,i.isDiscoverable=null!==(d=a.is_discoverable)&&void 0!==d?d:i.isPublic,i.isAccessCodeRequired=null!==(p=a.is_access_code_required)&&void 0!==p&&p,i.isPushEnabled=null!==(f=a.is_push_enabled)&&void 0!==f&&f,Array.isArray(a.members))&&(R=i.members).push.apply(R,g(a.members.map((function(e){return new yu(i._iid,e)}))));return i.memberCount=null!==(v=a.member_count)&&void 0!==v?v:0,i.joinedMemberCount=null!==(m=a.joined_member_count)&&void 0!==m?m:0,i.hiddenState=A(e.HiddenState,a.hidden_state)?a.hidden_state:e.HiddenState.UNHIDDEN,i.messageOffsetTimestamp=null!==(_=a.ts_message_offset)&&void 0!==_?_:0,i.messageSurvivalSeconds=null!==(y=a.message_survival_seconds)&&void 0!==y?y:-1,i.lastMessage=a.last_message?mn(i._iid,Object.assign({channel_type:i.channelType},a.last_message)):null,a.read_receipt&&Object.keys(a.read_receipt).forEach((function(e){M("number",a.read_receipt[e])&&i._updateUnreadMemberState(e,a.read_receipt[e])})),a.delivery_receipt&&Object.keys(a.delivery_receipt).forEach((function(e){M("number",a.delivery_receipt[e])&&i._updateUndeliveredMemberState(e,a.delivery_receipt[e])})),i.myMemberState=A(e.MemberState,a.member_state)?a.member_state:e.MemberState.NONE,i.myRole=A(e.Role,a.my_role)?a.my_role:e.Role.NONE,A(e.MutedState,a.is_muted)?i.myMutedState=a.is_muted:M("boolean",a.is_muted)?i.myMutedState=a.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:i.myMutedState=e.MutedState.UNMUTED,i.myCountPreference=A(e.CountPreference,a.count_preference)?a.count_preference:e.CountPreference.ALL,i.myPushTriggerOption=A(e.PushTriggerOption,a.push_trigger_option)?a.push_trigger_option:e.PushTriggerOption.ALL,i.myLastRead=null!==(k=a.user_last_read)&&void 0!==k?k:0,i.inviter=a.inviter?new pt(i._iid,a.inviter):null,i.invitedAt=null!==(E=a.invited_at)&&void 0!==E?E:0,i.joinedAt=null!==(b=a.joined_ts)&&void 0!==b?b:0,i._updateUnreadCount(null!==(w=a.unread_message_count)&&void 0!==w?w:0,null!==(C=a.unread_mention_count)&&void 0!==C?C:0),i.pinnedMessageIds=null!==(x=a.pinned_message_ids)&&void 0!==x?x:[],i.lastPinnedMessage=a.latest_pinned_message?mn(i._iid,Object.assign({channel_type:i.channelType},a.latest_pinned_message)):null,i}return a(o,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=k(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=m(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=k(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=m(e.value,2),a=r[0],i=r[1];t[a]=i}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof nn&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=St.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=St.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return ct(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ml(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rl(this._iid,this.url,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof yu?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof nn&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=St.of(this._iid).sdkState,a=t.createdAt,i=0,s=k(this.members);try{for(s.s();!(n=s.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=St.of(this._iid),a=r.sdkState;if(!a.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=e instanceof nn?e.sender:null,s=[];return this.members.forEach((function(r){(n||r.userId!==a.userId&&r.userId!==(null==i?void 0:i.userId))&&(t._unreadMemberStateMap.get(r.userId)>=e.createdAt&&s.push(r))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=St.of(this._iid),a=r.sdkState;if(!a.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=e instanceof nn?e.sender:null,s=[];return this.members.forEach((function(r){(n||r.userId!==a.userId&&r.userId!==(null==i?void 0:i.userId))&&(t._unreadMemberStateMap.get(r.userId)0&&void 0!==arguments[0]&&arguments[0],n=St.of(this._iid),r=n.sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var a={};return this.members.forEach((function(n){if(t||n.userId!==r.userId){var i=e._unreadMemberStateMap.get(n.userId);a[n.userId]=new ku(e._iid,{channel_url:e.url,channel_type:e.channelType,user:yu.payloadify(n),ts:i})}})),a}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=St.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,i){var s=a.ts;n-s>=t&&(e._typingStatus.delete(i),r=!0)})),r}},{key:"refresh",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.requestQueue,a=n.dispatcher,i=new zu({channelUrl:this.url}),t.next=4,r.send(i);case 4:return s=t.sent,o=s.as(Wu),u=o.channel,a.dispatch(new Hu({channels:[u],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",u);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"freeze",value:function(){var t=this,n=Object.create(null,{freeze:{get:function(){return v(s(o.prototype),"freeze",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.freeze.call(this);case 2:r=St.of(this._iid),r.dispatcher.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"unfreeze",value:function(){var t=this,n=Object.create(null,{unfreeze:{get:function(){return v(s(o.prototype),"unfreeze",t)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.unfreeze.call(this);case 2:r=St.of(this._iid),r.dispatcher.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannel",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},gl),t),ht(_l(r)).throw(T.invalidParameters),a=St.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new Sl(Object.assign({channelUrl:this.url},r)),n.next=6,s.send(o);case 6:return u=n.sent,c=u.as(Nl),l=c.channel,i.dispatch(new Hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(e.every((function(e){return e instanceof pt}))).throw(T.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"inviteWithUserIds",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(O("string",t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=new gc({channelUrl:this.url,userIds:t}),n.next=5,i.send(s);case 5:return o=n.sent,u=o.as(_c),c=u.channel,a.dispatch(new Hu({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"join",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("string",t)||null===t).throw(T.invalidParameters),r=St.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new dc({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(pc),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,a.dispatch(new Hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"leave",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=St.of(this._iid),a=r.sdkState,i=r.requestQueue,s=new vc({channelUrl:this.url,userId:a.userId,shouldRemoveOperatorStatus:t}),n.next=4,i.send(s);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return n.stop()}}),n,this)})))}},{key:"acceptInvitation",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("string",t)||null===t).throw(T.invalidParameters),r=St.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Tl({channelUrl:this.url,userId:i.userId,accessCode:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Il),(l=c.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,a.dispatch(new Hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),n.abrupt("return",this);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"declineInvitation",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.sdkState,a=n.requestQueue,i=new kc({channelUrl:this.url,userId:r.userId}),t.next=4,a.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Jn,a=St.of(this._iid).dispatcher,i=Sa.of(this._iid);return v(s(o.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Kc.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new Hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(t,n){var r=this,a=Object.create(null,{updateUserMessage:{get:function(){return v(s(o.prototype),"updateUserMessage",r)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=St.of(this._iid),s=i.dispatcher,r.next=3,a.updateUserMessage.call(this,t,n);case 3:return o=r.sent,u=!1,!o.silent&&this._shouldUpdateLastMessageWith(o)&&(this.lastMessage=o,u=!0),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Kc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)})),s.dispatch(new Hu({channels:[this],source:c?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),c&&Kc.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(l)})),s.dispatch(new On({messages:[o],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Jn,a=St.of(this._iid).dispatcher,i=Sa.of(this._iid);return v(s(o.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Kc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new Hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Jn,a=St.of(this._iid).dispatcher,i=Sa.of(this._iid);return v(s(o.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Kc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new Hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateFileMessage",value:function(t,n){var r=this,a=Object.create(null,{updateFileMessage:{get:function(){return v(s(o.prototype),"updateFileMessage",r)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=St.of(this._iid),s=i.dispatcher,r.next=3,a.updateFileMessage.call(this,t,n);case 3:return o=r.sent,u=!1,!o.silent&&this._shouldUpdateLastMessageWith(o)&&(this.lastMessage=o,u=!0),c=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===o.messageId&&(this.lastPinnedMessage=o,u=!0,c=!0),u&&(Kc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)})),s.dispatch(new Hu({channels:[this],source:c?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),c&&Kc.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(l)})),s.dispatch(new On({messages:[o],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),r.abrupt("return",o);case 12:case"end":return r.stop()}}),r,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Jn,a=St.of(this._iid).dispatcher,i=Sa.of(this._iid);return v(s(o.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var s=Kc.of(n._iid);i.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new Hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(t){var n=this,r=Object.create(null,{deleteMessage:{get:function(){return v(s(o.prototype),"deleteMessage",n)}}});return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.deleteMessage.call(this,t);case 2:0===t.messageId&&t instanceof nn&&(a=St.of(this._iid),a.dispatcher.dispatch(new Ln({reqId:t.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"hide",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},yl),t),ht(kl(r)).throw(T.invalidParameters),a=St.of(this._iid),i=a.dispatcher,s=a.sdkState,o=a.requestQueue,u=new Rc(Object.assign({channelUrl:this.url,userId:s.userId},r)),n.next=6,o.send(u);case 6:return c=n.sent,l=c.as(Tc),h=l.messageOffsetTimestamp,this.hiddenState=r.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,r.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),i.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),n.abrupt("return",this);case 13:case"end":return n.stop()}}),n,this)})))}},{key:"unhide",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Al({channelUrl:this.url}),t.next=4,a.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,r.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Ml({channelUrl:this.url}),e.next=4,n.send(r);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.sdkState,a=n.dispatcher,i=n.requestQueue,s=new bc({channelUrl:this.url}),t.next=4,i.send(s);case 4:o=t.sent,u=o.as(wc),c=u.readStatus,this._updateUnreadMemberState(r.userId,c.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Kc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(l)}))),a.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Cc({channelUrl:this.url,userId:n.userId}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=St.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,(a=(new Date).getTime())-this._typingStarted>=r&&(this._typingStarted=a,this._typingEnded=0,i=new Sc({channelUrl:this.url,time:this._typingStarted}),n.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=St.of(this._iid),n=t.requestQueue,r=t.typingIndicatorThrottle,(a=(new Date).getTime())-this._typingEnded>=r&&(this._typingStarted=0,this._typingEnded=a,i=new Mc({channelUrl:this.url,time:this._typingStarted}),n.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},ga),e),ht(function(e){return ta(e)&&M("number",e.scheduledAt,!0)}(e)).throw(T.invalidParameters);var t=new Jn;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Gl),t),ht(ql(r)).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new Vl(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(au),c=u.message,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createScheduledFileMessage",value:function(e){var t=this;e=Object.assign(Object.assign({},_a),e),ht(function(e){return Xr(e)&&M("number",e.scheduledAt)&&(L(e.file)||M("string",e.fileUrl))&&M("string",e.fileName,!0)&&M("string",e.mimeType,!0)&&M("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return M("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(T.invalidParameters);var n=Date.now(),r=this._generateRequestId(),a=new Jn;return Fe(2).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);He((function(){return E(t,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),L(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,a,r,n)})):this._createScheduledFileMessage(e,a,r,n),a}},{key:"updateScheduledFileMessage",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Object.assign(Object.assign({},Pl),t),ht(Fl(r)).throw(T.invalidParameters),!L(r.file)){n.next=5;break}return n.next=5,this._uploadFileAndUpdateParams(r);case 5:return a=new Hl(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),i=St.of(this._iid),s=i.requestQueue,n.next=9,s.send(a);case 9:return o=n.sent,u=o.as(jl),c=u.message,n.abrupt("return",c);case 12:case"end":return n.stop()}}),n,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Ql({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=St.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Bl({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),r=St.of(this._iid),a=r.requestQueue,t.next=4,a.send(n);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getMyPushTriggerOption",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.sdkState,r=t.requestQueue,a=new Wl({userId:n.userId,channelUrl:this.url}),e.next=4,r.send(a);case 4:return i=e.sent,s=i.as(Yl),o=s.pushTriggerOption,this.myPushTriggerOption=o,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(A(e.PushTriggerOption,t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Kl({userId:i.userId,channelUrl:this.url,pushTriggerOption:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(zl),l=c.pushTriggerOption,this.myPushTriggerOption=l,a.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 10:case"end":return n.stop()}}),n,this)})))}},{key:"setMyCountPreference",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(A(e.CountPreference,t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.dispatcher,i=r.sdkState,s=r.requestQueue,o=new Ul({channelUrl:this.url,userId:i.userId,countPreference:t}),n.next=5,s.send(o);case 5:return u=n.sent,c=u.as(Ol),l=c.countPreference,this.myCountPreference=l,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),a.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),n.abrupt("return",l);case 11:case"end":return n.stop()}}),n,this)})))}},{key:"resetMyHistory",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=St.of(this._iid),r=n.dispatcher,a=n.requestQueue,i=new Dl({channelUrl:this.url}),t.next=4,a.send(i);case 4:return s=t.sent,o=s.as(Ll),u=o.messageOffsetTimestamp,this.messageOffsetTimestamp=u,r.dispatch(new Hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"updatePoll",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("number",e)&&Jl(t)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new Xl(Object.assign({pollId:e},t)),n.next=5,a.send(i);case 5:return s=n.sent,o=s.as(Zl),u=o.poll,n.abrupt("return",u);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"deletePoll",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=M("number",e),ht(n).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new $l({pollId:e}),t.next=6,a.send(i);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"closePoll",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=M("number",e),ht(n).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new eh({pollId:e}),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(th),u=o.poll,t.abrupt("return",u);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"addPollOption",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=M("number",e)&&M("string",t)&&""!==t.trim(),ht(r).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new nh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),n.next=6,i.send(s);case 6:return o=n.sent,u=o.as(rh),c=u.poll,n.abrupt("return",c);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"updatePollOption",value:function(e,t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=M("number",e)&&M("number",t)&&M("string",n)&&""!==n.trim(),ht(a).throw(T.invalidParameters),i=St.of(this._iid),s=i.requestQueue,o=new ah({pollId:e,pollOptionId:t,optionText:n}),r.next=6,s.send(o);case 6:return u=r.sent,c=u.as(ih),l=c.poll,r.abrupt("return",l);case 9:case"end":return r.stop()}}),r,this)})))}},{key:"deletePollOption",value:function(e,t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=M("number",e)&&M("number",t),ht(r).throw(T.invalidParameters),a=St.of(this._iid),i=a.requestQueue,s=new sh({pollId:e,pollOptionId:t}),n.next=6,i.send(s);case 6:case"end":return n.stop()}}),n,this)})))}},{key:"votePoll",value:function(t,n){return E(this,void 0,void 0,regeneratorRuntime.mark((function r(){var a,i,s,o,u,c,l,h;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a=M("number",t)&&O("number",n),ht(a).throw(T.invalidParameters),i=St.of(this._iid),s=i.requestQueue,o=i.dispatcher,u=new oh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),r.next=6,s.send(u);case 6:return c=r.sent,l=c.as(Hc),h=l.event,o.dispatch(new Gn({event:h,source:e.MessageEventSource.EVENT_POLL_VOTED})),r.abrupt("return",h);case 10:case"end":return r.stop()}}),r,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("number",e)).throw(T.invalidParameters),n=Tr.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e,!0)),n=Tr.of(this._iid),t.next=4,n.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Ar(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new Dr(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}},{key:"pinMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("number",e)&&e>0).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new uh({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"unpinMessage",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("number",e)&&e>0).throw(T.invalidParameters),n=St.of(this._iid),r=n.requestQueue,a=new ch({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,r.send(a);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l,h,d,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!L(e.file)){t.next=11;break}return n=St.of(this._iid),r=n.requestQueue,a=new Ft({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,r.send(a);case 5:i=t.sent,s=i.as(Gt),o=s.url,u=s.fileSize,c=void 0===u?e.fileSize:u,l=s.thumbnailSizes,h=void 0===l?e.thumbnailSizes:l,d=s.requireAuth,p=void 0!==d&&d,e.fileUrl=o,e.fileSize=c,e.thumbnailSizes=h,e.requireAuth=p;case 11:case"end":return t.stop()}}),t,this)})))}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},v(s(o),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return yu.payloadify(e)})),last_message:vn(e.lastMessage),inviter:e.inviter?pt.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:vn(e.lastPinnedMessage)})):null}}]),o}(ou),dh={},ph=function(){function t(r){var a=this,i=r._iid,s=r.limit,o=void 0===s?100:s;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=o;var u,c=St.of(this._iid),l=c.sdkState,h=c.dispatcher,d=c.logger;this._metadataKey=(u=l.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new zc(p,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(d.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,a=Kc.of(this._iid),t.next=9,a.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,s=i.channels,o=i.token,n.hasNext=s.length>=this._limit&&!!o,n.nextToken=o,this._metadata.token=o,(r=this._metadata.range).extends.apply(r,g(s.map((function(e){return e.createdAt})))),this._metadata.completed=!n.hasNext,d.debug("channel background sync progress",n),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),d.debug("channel background sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:n.hasNext=!1,n.nextToken="";case 33:return t.abrupt("return",n);case 34:case"end":return t.stop()}}),t,this,[[5,22]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.get(this._metadataKey);case 4:r=e.sent,this._metadata={token:r?r.token:"",range:new Vc(r?r.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!r&&r.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=St.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){St.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete dh[this._iid])}}],[{key:"of",value:function(e){return dh[e]||(dh[e]=new t({_iid:e})),dh[e].ref++,dh[e]}},{key:"clear",value:function(e){dh[e]&&(dh[e].close(),delete dh[e])}}]),t}(),fh={},vh=function(){function t(r){var a=this,i=r._iid;n(this,t),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var s,o=St.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(s=c.userId,"sendbird:".concat(s,"@groupchannel/changelogs.meta"));var h=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new zc(h,(function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return u.debug("channel changelog sync from",this._metadata.token),t.prev=4,r=Kc.of(this._iid),t.next=8,r.getMyGroupChannelChangeLogs(this._metadata.token,{},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return a=t.sent,i=a.hasMore,s=a.token,n.hasNext=i,n.nextToken=s,this._metadata.token=s,u.debug("channel changelog sync progress",n),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),u.debug("channel changelog sync error",t.t0),!(t.t0 instanceof T&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",n);case 27:case"end":return t.stop()}}),t,this,[[4,19]])})))})),this._connectionEventContext=l.on((function(e){if(e instanceof ve)if(e.stateType===ue.CONNECTED)a.resume();else a.pause()}))}return a(t,[{key:"loadMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return t=St.of(this._iid),n=t.cacheContext,r=t.firstConnectedAt,e.next=4,n.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:r};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return t=St.of(this._iid),n=t.cacheContext,e.next=4,n.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.cacheContext,e.next=3,n.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){St.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete fh[this._iid])}}],[{key:"of",value:function(e){return fh[e]||(fh[e]=new t({_iid:e})),fh[e].ref++,fh[e]}},{key:"clear",value:function(e){fh[e]&&(fh[e].close(),delete fh[e])}}]),t}(),mh=function(){function t(r,a){var i=this,s=a.filter,o=a.order,u=a.limit;n(this,t),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=r,this._key="gcc-".concat(B()),this.filter=null!=s?s:new bu,this.order=null!=o?o:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=u?u:100;var c=St.of(this._iid),l=c.sdkState;c.cacheContext.localCacheEnabled&&(this._backgroundSync=ph.of(r),this._backgroundSync.resume()),this._changelogSync=vh.of(r),this._changelogSync.resume(),Kc.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return i.filter.match(e,l.userId)})),r=e.filter((function(e){return!i.filter.match(e,l.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)},onRemove:function(e,t){i._removeChannelsFromView(e,t)}})}return a(t,[{key:"hasMore",get:function(){return this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(t,n){var r,a=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=[],o=[],u=k(t);try{for(u.s();!(r=u.n()).done;){var c=r.value,l=al(this.channels,c,this.order),h=l.place,d=l.contains;if(d)switch(o.push(c),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:this.channels.splice(h,1);var p=al(this.channels,c,this.order),f=p.place;this.channels.splice(f,0,c);break;default:this.channels[h]=c}else h===this.channels.length?(i||!this._backgroundSync||this._backgroundSync.completed)&&(s.push(c),this.channels.push(c)):(s.push(c),this.channels.splice(h,0,c))}}catch(e){u.e(e)}finally{u.f()}qu(n)&&He((function(){return E(a,void 0,void 0,regeneratorRuntime.mark((function e(){var t,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Wc(n),s.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsAdded)&&this._handler.onChannelsAdded(a,s),o.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(a,o);case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,t){var n,r=this,a=[],i=k(e);try{var s=function(){var e=n.value,t=r.channels.findIndex((function(t){return t.url===e}));t>=0&&(a.push(r.channels[t].url),r.channels.splice(t,1))};for(i.s();!(n=i.n()).done;)s()}catch(e){i.e(e)}finally{i.f()}return qu(t)&&a.length>0&&He((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Wc(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(r,a);case 2:case"end":return e.stop()}}),e,this)})))})),a}},{key:"_getLocalChannels",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Kc.of(this._iid),n=this.channels.length>0?nl(this.channels[this.channels.length-1],this.order):null,e.next=4,t.getChannelsFromCache(n,this.filter,this.order,this._limit);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Kc.of(this._iid),e.next=3,t.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return n=e.sent,r=n.channels,a=n.token,this._token=a,this._hasMore=!!a,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"loadMore",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._hasMore){t.next=8;break}return n=[],t.next=4,je((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:n=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 4:return t.next=6,je((function(){return E(r,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getRemoteChannels();case 2:n=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 6:return this._addChannelsToView(n,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.abrupt("return",n);case 8:return t.abrupt("return",[]);case 9:case"end":return t.stop()}}),t,this)})))}},{key:"dispose",value:function(){var e,t;null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Kc.of(this._iid).unsubscribeGroupChannelEvent(this._key)}}]),t}(),gh=function(t){i(s,t);var r=p(s);function s(t){var a;n(this,s);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,p=t.customTypesFilter,f=t.customTypeStartsWithFilter,v=t.superChannelFilter,m=t.metadataOrderKeyFilter,g=t.metadataKey,_=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,E=t.includeMetaData;return(a=r.call(this)).method=x.GET,a.path=be,a.params=J({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:p,custom_type_startswith:f,super_mode:v,metadata_order_key:m,metadata_key:g,metadata_values:_,metadata_value_startswith:y,show_frozen:k,show_metadata:E}),a}return a(s)}(Z),_h=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return t.ts=u,new hh(e,t)}))),i.ts="number"==typeof u?u:null,i}return a(r)}($);e.MembershipFilter=void 0,(lh=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",lh.JOINED="joined";var yh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h,d,p,f,v,m,g,_,y,k;return n(this,o),(i=r.call(this,t,a)).includeEmpty=!1,i.includeFrozen=!0,i.includeMetaData=!0,i.channelUrlsFilter=null,i.customTypesFilter=null,i.customTypeStartsWithFilter=null,i.channelNameContainsFilter=null,i.membershipFilter=e.MembershipFilter.ALL,i.superChannelFilter=e.SuperChannelFilter.ALL,i.metadataKey=null,i.metadataValues=null,i.metadataOrderKeyFilter=null,i.metadataValueStartsWith=null,i.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,i.includeEmpty=null!==(s=a.includeEmpty)&&void 0!==s&&s,i.includeFrozen=null===(u=a.includeFrozen)||void 0===u||u,i.includeMetaData=null===(c=a.includeMetaData)||void 0===c||c,i.channelUrlsFilter=null!==(l=a.channelUrlsFilter)&&void 0!==l?l:null,i.customTypesFilter=null!==(h=a.customTypesFilter)&&void 0!==h?h:null,i.customTypeStartsWithFilter=null!==(d=a.customTypeStartsWithFilter)&&void 0!==d?d:null,i.channelNameContainsFilter=null!==(p=a.channelNameContainsFilter)&&void 0!==p?p:null,i.membershipFilter=null!==(f=a.membershipFilter)&&void 0!==f?f:e.MembershipFilter.ALL,i.superChannelFilter=null!==(v=a.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,i.metadataKey=null!==(m=a.metadataKey)&&void 0!==m?m:null,i.metadataValues=null!==(g=a.metadataValues)&&void 0!==g?g:null,i.metadataOrderKeyFilter=null!==(_=a.metadataOrderKeyFilter)&&void 0!==_?_:null,i.metadataValueStartsWith=null!==(y=a.metadataValueStartsWith)&&void 0!==y?y:null,i.order=null!==(k=a.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("boolean",this.includeEmpty)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.channelNameContainsFilter,!0)&&O("string",this.channelUrlsFilter,!0)&&O("string",this.customTypesFilter,!0)&&M("string",this.customTypeStartsWithFilter,!0)&&A(e.MembershipFilter,this.membershipFilter)&&A(e.SuperChannelFilter,this.superChannelFilter)&&A(e.PublicGroupChannelListOrder,this.order)&&M("string",this.metadataOrderKeyFilter,!0)&&M("string",this.metadataKey,!0)&&O("string",this.metadataValues,!0)&&M("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=22;break}if(this._isLoading){t.next=19;break}if(n=[],!this._hasNext){t.next=16;break}return this._isLoading=!0,r=St.of(this._iid),a=r.requestQueue,i=r.dispatcher,s=new gh(Object.assign(Object.assign({},this),{token:this._token})),t.next=9,a.send(s);case 9:return o=t.sent,u=o.as(_h),c=u.channels,l=u.token,this._token=l,this._hasNext=!!l,i.dispatch(new Hu({channels:c,source:e.GroupChannelEventSource.REQUEST_CHANNEL})),this._isLoading=!1,t.abrupt("return",c);case 16:return t.abrupt("return",n);case 19:throw T.queryInProgress;case 20:t.next=23;break;case 22:throw T.invalidParameters;case 23:case"end":return t.stop()}}),t,this)})))}}]),o}(er),kh=a((function e(){n(this,e),this.onUserMuted=oe,this.onUserUnmuted=oe,this.onUserBanned=oe,this.onUserUnbanned=oe,this.onChannelChanged=oe,this.onChannelDeleted=oe,this.onChannelFrozen=oe,this.onChannelUnfrozen=oe,this.onOperatorUpdated=oe,this.onChannelMemberCountChanged=oe,this.onMetaDataCreated=oe,this.onMetaDataUpdated=oe,this.onMetaDataDeleted=oe,this.onMetaCounterCreated=oe,this.onMetaCounterUpdated=oe,this.onMetaCounterDeleted=oe,this.onMessageReceived=oe,this.onMessageUpdated=oe,this.onMessageDeleted=oe,this.onMentionReceived=oe,this.onReactionUpdated=oe,this.onThreadInfoUpdated=oe})),Eh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).onUserJoined=oe,e.onUserLeft=oe,e.onUserReceivedInvitation=oe,e.onUserDeclinedInvitation=oe,e.onChannelHidden=oe,e.onUnreadMemberStatusUpdated=oe,e.onUndeliveredMemberStatusUpdated=oe,e.onTypingStatusUpdated=oe,e.onPollUpdated=oe,e.onPollVoted=oe,e.onPollDeleted=oe,e.onPinnedMessageUpdated=oe,e}return a(r)}(kh),bh=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(Eh),wh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.token,s=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=x.GET,a.path="".concat(Me),a.params=J({limit:s,reverse:u,channel_url:c,order:o,status:h}),i&&(a.params.token=i),l&&(a.params.message_type=l),a}return a(r)}(Z),Ch=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.scheduledMessages=[];var s=a.next,o=a.scheduled_messages;return i.token=s,i.scheduledMessages=o.map((function(t){return mn(e,t)})),i}return a(r)}($),xh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s,u,c,l,h;return n(this,o),(i=r.call(this,t,a)).channelUrl=null,i.order=null,i.reverse=!1,i.scheduledStatus=null,i.messageTypeFilter=e.MessageTypeFilter.ALL,i.channelUrl=null!==(s=a.channelUrl)&&void 0!==s?s:null,i.order=null!==(u=a.order)&&void 0!==u?u:null,i.reverse=null!==(c=a.reverse)&&void 0!==c&&c,i.scheduledStatus=null!==(l=a.scheduledStatus)&&void 0!==l?l:null,i.messageTypeFilter=null!==(h=a.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,i}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)&&M("string",this.channelUrl,!0)&&(A(e.ScheduledMessageListOrder,this.order)||null===this.order)&&M("boolean",this.reverse)&&(O(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&A(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new wh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Ch),s=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(er),Rh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="groupChannel",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Kc(e,{sdkState:n,cacheContext:l,dispatcher:a,sessionManager:i,requestQueue:o,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mh(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jc(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yh(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new xh(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){ht(M("string",e)&&t instanceof bh).throw(T.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){ht(M("string",e)).throw(T.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),t,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Iu),t),ht(M("string",e)&&Su(r)).throw(T.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Object.assign(Object.assign({},Iu),t),ht(M("number",e)&&Su(r)).throw(T.invalidParameters),n.next=4,this._manager.getMyGroupChannelChangeLogs(e,r);case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}},{key:"getGroupChannelCount",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Nu),e),ht(Mu(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),ht(Tu(n)).throw(T.invalidParameters),t.abrupt("return",this._manager.createChannel(n));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ru),e),ht(Tu(n)).throw(T.invalidParameters),n&&(n.isDistinct=!0),t.abrupt("return",this.createChannel(n));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithUserIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,regeneratorRuntime.mark((function s(){var o;return regeneratorRuntime.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Object.assign(Object.assign({},Ru),{invitedUserIds:e,isDistinct:t,name:n,data:a,customType:i}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,s.abrupt("return",this.createChannel(o));case 3:case"end":return s.stop()}}),s,this)})))}},{key:"markAsReadAll",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:ht(O("string",e)).throw(T.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"markAsDelivered",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),t.next=3,this.getChannel(e);case 3:return n=t.sent,t.next=6,n.markAsDelivered();case 6:case"end":return t.stop()}}),t,this)})))}}]),r}(Pt),Th=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return a(r,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var t;return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null!==(t=this._channels.get(e))&&void 0!==t?t:null);case 1:case"end":return n.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.forEach((function(e){if(n._channels.has(e.url)){var t=n._channels.get(e.url);Object.assign(t,e)}else n._channels.set(e.url,e)}));case 1:case"end":return t.stop()}}),t)})))}},{key:"remove",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),r}(nt),Ih={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Sh=function(e){return O("string",e.operatorUserIds,!0)&&(M("string",e.coverUrlOrImage)||L(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)&&(M("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)},Nh=function(e){i(r,e);var t=p(r);function r(e){var a,i=e.channelUrl,s=e.isInternalCall;return n(this,r),(a=t.call(this)).method=x.GET,a.path="".concat(s?xe:Ce,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),Mh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=null,i.channel=new zh(e,a),i}return a(r)}($),Ah=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=x.POST,a.path=Ce,a.params=J({channel_url:i,cover_url:M("string",s)?s:null,cover_file:L(s)?s:null,name:o,data:u,custom_type:c,operators:l}),a}return a(r)}(Z),Uh=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return a(r)}(le),Oh=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u;return n(this,r),s=t.call(this,e,"SYEV",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new pt(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return a(r)}(hc),Dh=function(e){i(r,e);var t=p(r);function r(e){var a=e.channelUrl;return n(this,r),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return a(r)}(le),Lh=function(e){i(r,e);var t=p(r);function r(e,a,i){var s,o,u;return n(this,r),s=t.call(this,e,"EXIT",i),i.data&&(s.participantCount=null!==(o=i.data.participant_count)&&void 0!==o?o:0,s.user=new pt(e,i.data),s.ts=null!==(u=i.data.edge_ts)&&void 0!==u?u:0),s}return a(r)}(hc),Ph={},Fh=function(){function t(e,r){var a=this,i=r.sdkState,s=r.dispatcher,o=r.requestQueue;return n(this,t),Ph[e]||(this._iid=e,this._sdkState=i,this._requestQueue=o,this._dispatcher=s,this._openChannelCache=new Th(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof se)a._handleEvent(e);else if(e instanceof ve&&e.stateType===ue.CONNECTED){var t,n=k(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),Ph[e]=this),Ph[e]}return a(t,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=lt(e);return new zh(this._iid,zh.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:case"end":return t.stop()}}),t,this)})))}},{key:"removeChannelsFromCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=k(e),t.prev=1,n.s();case 3:if((r=n.n()).done){t.next=9;break}return a=r.value,t.next=7,this._openChannelCache.remove(a);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n.e(t.t0);case 14:return t.prev=14,n.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(t){return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s,o,u,c,l,h,d,p,f,v,m,g,_,y,b,w,C,x,T,I,S,N,M,A,U,O,D,L,P,F,G,q,H,j,V,Q,B,K,z,W,Y,J,X,Z,$,ee,te,ne,re,ae,ie,se,oe,ue,ce,le,he,de,pe,fe,ve,me,ge,_e,ye,ke,Ee,be,we=this;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,n.t0=t.code,n.next="MESG"===n.t0||"FILE"===n.t0||"ADMM"===n.t0||"BRDM"===n.t0?4:"MEDI"===n.t0||"FEDI"===n.t0||"AEDI"===n.t0?14:"DELM"===n.t0?24:"MRCT"===n.t0?31:"MTHD"===n.t0?38:"MCNT"===n.t0?45:"SYEV"===n.t0?72:149;break;case 4:if(r=null,"MESG"===t.code?r=t.as(Qo):"FILE"===t.code?r=t.as(Cn):"ADMM"!==t.code&&"BRDM"!=t.code||(r=t.as(Lc)),!r){n.next=13;break}if(i=(a=r).message,s=a.isMentioned,i.channelType!==e.ChannelType.OPEN){n.next=13;break}return n.next=11,this.getChannel(i.channelUrl,!0);case 11:o=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(o.url)&&(r.onMessageReceived(o,i),s&&r.onMentionReceived(o,i))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return n.abrupt("break",149);case 14:if(u=null,"MEDI"===t.code?u=t.as(Ko):"FEDI"===t.code?u=t.as(Wo):"AEDI"===t.code&&(u=t.as(Pc)),!u){n.next=23;break}if(l=(c=u).message,h=c.mentionCountChange,l.channelType!==e.ChannelType.OPEN){n.next=23;break}return n.next=21,this.getChannel(l.channelUrl,!0);case 21:d=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&(r.onMessageUpdated(d,l),h>0&&r.onMentionReceived(d,l))}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return n.abrupt("break",149);case 24:if(p=t.as(Jo),f=p.channelUrl,v=p.channelType,m=p.messageId,v!==e.ChannelType.OPEN){n.next=30;break}return n.next=28,this.getChannel(f,!0);case 28:g=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onMessageDeleted(g,m)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return n.abrupt("break",149);case 31:if(_=t.as(Fc),y=_.channelUrl,b=_.channelType,w=_.event,b!==e.ChannelType.OPEN){n.next=37;break}return n.next=35,this.getChannel(y,!0);case 35:C=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(C.url)&&r.onReactionUpdated(C,w)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return n.abrupt("break",149);case 38:if(x=t.as(Gc),(T=x.event).channelType!==e.ChannelType.OPEN){n.next=44;break}return n.next=42,this.getChannel(T.channelUrl,!0);case 42:I=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)r=n.value,this._openChannelCache.isEnteredChannel(I.url)&&r.onThreadInfoUpdated(I,T)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return n.abrupt("break",149);case 45:S=t.as(Oc),N=S.openChannelMemberCounts,M=[],A=k(N),n.prev=48,A.s();case 50:if((U=A.n()).done){n.next=59;break}return O=U.value,D=O.channelUrl,L=O.participantCount,P=O.updatedAt,n.next=55,this.getChannelFromCache(D);case 55:(F=n.sent)&&F._updateParticipantCount(L,P)&&M.push(F);case 57:n.next=50;break;case 59:n.next=64;break;case 61:n.prev=61,n.t1=n.catch(48),A.e(n.t1);case 64:return n.prev=64,A.f(),n.finish(64);case 67:if(!(M.length>0)){n.next=71;break}return n.next=70,this.upsertChannelsToCache(M);case 70:He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=k(this._openChannelHandlers.values());try{for(t.s();!(n=t.n()).done;)n.value.onChannelMemberCountChanged(M)}catch(e){t.e(e)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 71:return n.abrupt("break",149);case 72:if(G=t.as(hc),!(q=G.event).isOpenChannelEvent){n.next=148;break}n.t2=q.category,n.next=n.t2===Eu.CHANNEL_ENTER?77:n.t2===Eu.CHANNEL_EXIT?84:n.t2===Eu.CHANNEL_OPERATOR_UPDATE?91:n.t2===Eu.USER_CHANNEL_MUTE||n.t2===Eu.USER_CHANNEL_UNMUTE?99:n.t2===Eu.USER_CHANNEL_BAN||n.t2===Eu.USER_CHANNEL_UNBAN?106:n.t2===Eu.CHANNEL_FREEZE||n.t2===Eu.CHANNEL_UNFREEZE?113:n.t2===Eu.CHANNEL_DELETED?121:n.t2===Eu.CHANNEL_PROP_CHANGED?128:n.t2===Eu.CHANNEL_META_DATA_CHANGED?133:n.t2===Eu.CHANNEL_META_COUNTERS_CHANGED?142:148;break;case 77:return n.next=79,this.getChannel(q.channelUrl,!0);case 79:return H=n.sent,j=t.as(Oh),V=j.participantCount,Q=j.user,B=H._updateParticipantCount(V,q.ts),He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered(H,Q),B&&e.onChannelParticipantCountChanged(H)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 84:return n.next=86,this.getChannel(q.channelUrl,!0);case 86:return K=n.sent,z=t.as(Lh),W=z.participantCount,Y=z.user,J=K._updateParticipantCount(W,q.ts),He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(K,Y),J&&e.onChannelParticipantCountChanged(K)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 91:return n.next=93,this.getChannel(q.channelUrl,!0);case 93:return X=n.sent,Z=t.as(Uc),$=Z.operators,X.operators=$,this.upsertChannelsToCache([X]),He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(X,$)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 99:return n.next=101,this.getChannel(q.channelUrl,!0);case 101:return ee=n.sent,te=q.category===Eu.USER_CHANNEL_MUTE,ne=t.as(te?Mo:Uo),re=ne.user,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){te?e.onUserMuted(ee,re):e.onUserUnmuted(ee,re)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 106:return n.next=108,this.getChannel(q.channelUrl,!0);case 108:return ae=n.sent,ie=q.category===Eu.USER_CHANNEL_BAN,se=t.as(ie?Do:Po),oe=se.user,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ie?e.onUserBanned(ae,oe):e.onUserUnbanned(ae,oe)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 113:return n.next=115,this.getChannel(q.channelUrl,!0);case 115:return ue=n.sent,ce=t.as(Go),le=ce.freeze,ue.isFrozen=le,this.upsertChannelsToCache([ue]),He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){le?e.onChannelFrozen(ue):e.onChannelUnfrozen(ue)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 121:return n.next=123,this.getChannel(q.channelUrl,!0);case 123:return he=n.sent,n.next=126,this.removeChannelsFromCache([he.url]);case 126:return He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(he.url,he.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 128:return n.next=130,this.getChannelWithoutCache(q.channelUrl,!0);case 130:return de=n.sent,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(de)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 133:return n.next=135,this.getChannel(q.channelUrl,!0);case 135:return pe=n.sent,fe=t.as(mo),ve=fe.created,me=fe.updated,ge=fe.deleted,ve&&pe._upsertCachedMetaData(ve,q.ts),me&&pe._upsertCachedMetaData(me,q.ts),ge&&pe._removeFromCachedMetaData(ge,q.ts),He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ve&&e.onMetaDataCreated(pe,ve),me&&e.onMetaDataUpdated(pe,me),ge&&e.onMetaDataDeleted(pe,ge)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 142:return n.next=144,this.getChannel(q.channelUrl,!0);case 144:return _e=n.sent,ye=t.as(To),ke=ye.created,Ee=ye.updated,be=ye.deleted,He((function(){return E(we,void 0,void 0,regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ke&&e.onMetaCounterCreated(_e,ke),Ee&&e.onMetaCounterUpdated(_e,Ee),be&&e.onMetaCounterDeleted(_e,be)}));case 1:case"end":return e.stop()}}),e,this)})))})),n.abrupt("break",148);case 148:return n.abrupt("break",149);case 149:n.next=155;break;case 151:if(n.prev=151,n.t3=n.catch(0),!R(n.t3)){n.next=155;break}throw n.t3;case 155:case"end":return n.stop()}}),n,this,[[0,151],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(n=t.sent)){t.next=7;break}return t.abrupt("return",n);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),t,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return E(this,void 0,void 0,regeneratorRuntime.mark((function n(){var r,a,i,s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return ht(M("string",e)).throw(T.invalidParameters),r=new Nh({channelUrl:e,isInternalCall:t}),n.next=4,this._requestQueue.send(r);case 4:return a=n.sent,i=a.as(Mh),s=i.channel,n.next=8,this.upsertChannelsToCache([s]);case 8:return n.abrupt("return",s);case 9:case"end":return n.stop()}}),n,this)})))}},{key:"createChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Ih),e),ht(Sh(n)).throw(T.invalidParameters),r=new Ah(n),t.next=5,this._requestQueue.send(r);case 5:return a=t.sent,i=a.as(Mh),s=i.channel,this.upsertChannelsToCache([s]),t.abrupt("return",s);case 9:case"end":return t.stop()}}),t,this)})))}}],[{key:"of",value:function(e){return Ph[e]}}]),t}(),Gh={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},qh=function(e){return O("string",e.operatorUserIds,!0)&&(M("string",e.coverUrlOrImage)||L(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&M("string",e.name,!0)&&M("string",e.data,!0)&&M("string",e.customType,!0)},Hh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.token,o=e.limit;return(a=t.call(this)).method=x.GET,a.path="".concat(Ce,"/").concat(encodeURIComponent(i),"/participants"),a.params={token:s,limit:o},a}return a(r)}(Z),jh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.participants=[];var s=a.next,o=a.participants;return i.token=s,i.participants=o.map((function(t){return new uu(e,t)})),i}return a(r)}($),Vh=function(t){i(o,t);var r=p(o);function o(t,a,i){return n(this,o),r.call(this,t,a,e.ChannelType.OPEN,i)}return a(o,[{key:"_validate",value:function(){return v(s(o.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Hh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(jh),s=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,e.abrupt("return",s);case 14:return e.abrupt("return",[]);case 17:throw T.queryInProgress;case 18:e.next=21;break;case 20:throw T.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),o}(or),Qh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl,s=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=x.PUT,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a.params=J({cover_url:M("string",s)?s:null,cover_file:L(s)?s:null,name:o,data:u,custom_type:c,operators:l}),a}return a(r)}(Z),Bh=function(e){i(r,e);var t=p(r);function r(e,a){var i;return n(this,r),(i=t.call(this,e,a)).channel=new zh(e,a),i}return a(r)}($),Kh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.channelUrl;return(a=t.call(this)).method=x.DELETE,a.path="".concat(Ce,"/").concat(encodeURIComponent(i)),a}return a(r)}(Z),zh=function(t){i(o,t);var r=p(o);function o(t,a){var i,s;return n(this,o),(i=r.call(this,t,a))._lastParticipantCountUpdated=0,i.participantCount=0,i.operators=[],i.channelType=e.ChannelType.OPEN,i.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,i.operators=Array.isArray(a.operators)?a.operators.map((function(e){return new pt(t,e)})):[],i}return a(o,[{key:"serialize",value:function(){return ct(this)}},{key:"isOperator",value:function(e){return e instanceof pt?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Vh(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Fh.of(this._iid),e.next=3,t.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Uh({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Oh),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),Fh.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Dh({channelUrl:this.url}),e.next=4,n.send(r);case 4:a=e.sent,i=a.as(Lh),s=i.participantCount,o=i.ts,this._updateParticipantCount(s,o),Fh.of(this._iid).setExitedToCache(this),Yn.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){var n,r,a,i,s,o,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.assign(Object.assign({},Gh),e),ht(qh(n)).throw(T.invalidParameters),r=St.of(this._iid),a=r.requestQueue,i=new Qh(Object.assign({channelUrl:this.url},n)),t.next=6,a.send(i);case 6:return s=t.sent,o=s.as(Bh),u=o.channel,c=Fh.of(this._iid),t.next=11,c.upsertChannelsToCache([u]);case 11:return t.abrupt("return",u);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=Object.assign(Object.assign({},Gh),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:r,customType:a}),i.abrupt("return",this.updateChannel(s));case 2:case"end":return i.stop()}}),i,this)})))}},{key:"delete",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=St.of(this._iid),n=t.requestQueue,r=new Kh({channelUrl:this.url}),e.next=4,n.send(r);case 4:return a=Fh.of(this._iid),e.next=7,a.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return ht(!e.isPinnedMessage).throw(T.notSupportedError),v(s(o.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return ht(!e.isPinnedMessage).throw(T.notSupportedError),v(s(o.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?J(Object.assign(Object.assign({},ou.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return pt.payloadify(e)}))})):null}}]),o}(ou),Wh=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).onUserEntered=oe,e.onUserExited=oe,e.onChannelParticipantCountChanged=oe,e}return a(r)}(kh),Yh=function(e){i(r,e);var t=p(r);function r(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,r),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return a(r)}(Wh),Jh=function(e){i(r,e);var t=p(r);function r(e){var a;n(this,r);var i=e.token,s=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=x.GET,a.path=Ce,a.params=J({token:i,limit:s,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return a(r)}(Z),Xh=function(e){i(r,e);var t=p(r);function r(e,a){var i;n(this,r),(i=t.call(this,e,a)).token=null,i.channels=[],i.ts=null;var s=a.next,o=a.channels,u=a.ts;return i.token=s,o&&o.length>0&&(i.channels=o.map((function(t){return new zh(e,t)}))),i.ts="number"==typeof u?u:null,i}return a(r)}($),Zh=function(e){i(r,e);var t=p(r);function r(e,a){var i,s,o,u,c,l;return n(this,r),(i=t.call(this,e,a)).includeFrozen=!0,i.includeMetaData=!0,i.nameKeyword=null,i.urlKeyword=null,i.customTypes=null,i.includeFrozen=null===(s=a.includeFrozen)||void 0===s||s,i.includeMetaData=null===(o=a.includeMetaData)||void 0===o||o,i.nameKeyword=null!==(u=a.nameKeyword)&&void 0!==u?u:null,i.urlKeyword=null!==(c=a.urlKeyword)&&void 0!==c?c:null,i.customTypes=null!==(l=a.customTypes)&&void 0!==l?l:null,i}return a(r,[{key:"_validate",value:function(){return v(s(r.prototype),"_validate",this).call(this)&&M("boolean",this.includeFrozen)&&M("boolean",this.includeMetaData)&&M("string",this.nameKeyword,!0)&&M("string",this.urlKeyword,!0)&&O("string",this.customTypes,!0)}},{key:"next",value:function(){return E(this,void 0,void 0,regeneratorRuntime.mark((function e(){var t,n,r,a,i,s,o,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,t=St.of(this._iid),n=t.requestQueue,r=new Jh(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,n.send(r);case 8:return a=e.sent,i=a.as(Xh),s=i.channels,o=i.token,this._token=o,this._hasNext=!!o,u=Fh.of(this._iid),e.next=15,u.upsertChannelsToCache(s);case 15:return this._isLoading=!1,e.abrupt("return",s);case 17:return e.abrupt("return",[]);case 20:throw T.queryInProgress;case 21:e.next=24;break;case 23:throw T.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),r}(er),$h=function(e){i(r,e);var t=p(r);function r(){var e;return n(this,r),(e=t.apply(this,arguments)).name="openChannel",e}return a(r,[{key:"init",value:function(e,t){var n=t.sdkState,a=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;v(s(r.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:a,sessionManager:i,requestQueue:o,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Fh(e,{sdkState:n,dispatcher:a,requestQueue:o})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Zh(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"getChannelWithoutCache",value:function(e){return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(this,void 0,void 0,regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,t,n,r,a){return E(this,void 0,void 0,regeneratorRuntime.mark((function i(){var s;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return(s=Object.assign({},Ih)).name=e,s.coverUrlOrImage=t,s.data=n,s.operatorUserIds=r,s.customType=a,i.abrupt("return",this._manager.createChannel(s));case 7:case"end":return i.stop()}}),i,this)})))}}]),r}(Pt);return e.AdminMessage=on,e.AppleCriticalAlertOptions=Xt,e.ApplicationUserListQuery=Oi,e.BannedUserListQuery=ro,e.BaseChannel=ou,e.BaseMessage=en,e.BlockedUserListQuery=Pi,e.ConnectionHandler=qr,e.Emoji=wi,e.EmojiCategory=Ci,e.EmojiContainer=xi,e.FileMessage=gn,e.FriendListQuery=qi,e.GroupChannel=hh,e.GroupChannelCollection=mh,e.GroupChannelEventContext=Wc,e.GroupChannelFilter=bu,e.GroupChannelHandler=bh,e.GroupChannelListQuery=jc,e.GroupChannelModule=Rh,e.Member=yu,e.MemberListQuery=Rl,e.MemoryStore=Ss,e.MessageCollection=ml,e.MessageCollectionInitHandler=vl,e.MessageEventContext=Yc,e.MessageFilter=zr,e.MessageMetaArray=Wt,e.MessageModule=hr,e.MessageRequestHandler=Jn,e.MessageSearchQuery=sr,e.MutedUserListQuery=eo,e.OGImage=Yt,e.OGMetaData=Jt,e.OpenChannel=zh,e.OpenChannelHandler=Yh,e.OpenChannelListQuery=Zh,e.OpenChannelModule=$h,e.OperatorListQuery=Xs,e.Participant=uu,e.ParticipantListQuery=Vh,e.Plugin=un,e.PreviousMessageListQuery=ur,e.PublicGroupChannelListQuery=yh,e.Reaction=zt,e.ReactionEvent=Kt,e.ReadStatus=ku,e.RestrictedUser=js,e.RestrictionInfo=Hs,e.ScheduledMessageListQuery=xh,e.SendbirdChat=lu,e.SendbirdChatOptions=q,e.SendbirdError=T,e.Sender=tn,e.SessionHandler=Gr,e.ThreadInfo=Ht,e.ThreadInfoUpdateEvent=Xn,e.Thumbnail=rn,e.User=pt,e.UserEventHandler=Hr,e.UserMessage=fn,Object.defineProperty(e,"__esModule",{value:!0}),e}({});