From 9993d45e76d2054b59203dd5cab2f43b204c184f Mon Sep 17 00:00:00 2001 From: Liam Cho Date: Wed, 22 Jun 2022 13:34:13 +0900 Subject: [PATCH] v4.0.2 --- CHANGELOG.md | 3 +++ __bundle-e580e568.js => __bundle-26bafa9e.js | 2 +- __bundle-d77a472f.js => __bundle-9ac5dba1.js | 2 +- __bundle-c65b6359.js => __bundle-ae9e1003.js | 2 +- __bundle-fecd47ae.js => __bundle-f79aa272.js | 2 +- groupChannel.d.ts | 3 +++ groupChannel.js | 2 +- lib/__definition.d.ts | 6 +++--- message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- sendbird.js | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) rename __bundle-e580e568.js => __bundle-26bafa9e.js (99%) rename __bundle-d77a472f.js => __bundle-9ac5dba1.js (98%) rename __bundle-c65b6359.js => __bundle-ae9e1003.js (99%) rename __bundle-fecd47ae.js => __bundle-f79aa272.js (60%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9854ebd..fad087b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog +## v4.0.2 (Jun 22, 2022) +- Added missing `GroupChannelListQueryParams`, `GroupChannelCollectionParams`, and `PublicGroupChannelListQueryParams` in `GroupChannelModule`. + ## v4.0.1 (Jun 17, 2022) - Added `appInfo` getter in `SendbirdChat`. - Improved stability. diff --git a/__bundle-e580e568.js b/__bundle-26bafa9e.js similarity index 99% rename from __bundle-e580e568.js rename to __bundle-26bafa9e.js index 1fbd3f4..0020479 100644 --- a/__bundle-e580e568.js +++ b/__bundle-26bafa9e.js @@ -12,4 +12,4 @@ 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 o(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 a(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},S=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("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},T=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=a([],o(e),!1).sort(),r=a([],o(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){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),N={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:a([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,o,a,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=i.sent())&&void 0!==t?t:[],i.label=2;case 2:i.trys.push([2,7,8,9]),r=s(n),o=r.next(),i.label=3;case 3:return o.done?[3,6]:(a=o.value,[4,this._store.get(a)]);case 4:(u=i.sent())&&this._preference.set(a,u),i.label=5;case 5:return o=r.next(),[3,3];case 6:return[3,9];case 7:return c=i.sent(),l={error:c},[3,9];case 8:try{o&&!o.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 r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(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 r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(a([],o(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 o=[];try{for(var a=s(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&&o.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.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(){},U=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"}(d||(d={}));var P,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):""},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=U(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(e.stringifyParams(t[n])))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=U(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),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"}(P||(P={}));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 U({stat_type:e.type,ts:e.createdAt,data:U(e.data)})},e}(),z=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},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=z()?"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(l.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(l.OS_VERSION,",").concat(l.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:P.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 r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,h,f,_,g,y,m;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),s=this._sdkState.api,o="".concat(s.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),h=Date.now(),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(f=i.sent()).json()];case 3:if(_=i.sent(),f.ok||f.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new x(this._iid,_)];throw _?((g=new p(_)).isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,g),g):(g=p.requestFailed,this._statLogApiResult(e,h,g),g);case 4:throw y=i.sent(),this._statLogApiResult(e,h,y),y instanceof p?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?p.requestCanceled:(m=p.networkError,this._logger.debug("fail api request",m),m);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=s(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}(),B=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,o=this;return(o=e.call(this)||this)._iid=t,o.code=n,o.payload=r,o.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",o}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),H=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),W=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(H),X=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 W;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}(),Y=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(j||(j={}));var J,Z=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o._pinger=null,o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o._sdkState.websocket.pingerDisabled||(o._pinger=new X({pingDelegate:{send:function(e){return o.send(e)},error:function(e){return o.error(e)}},sdkState:o._sdkState,logger:s})),o}return t(n,e),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&&y("string",e)){var n=B.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.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._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=Y,this._ws.onmessage=Y,this._ws.onerror=Y,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(M),$=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),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=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 Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new $(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 p({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new ee,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.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 r(this,void 0,void 0,(function(){return i(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 H?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.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"}(J||(J={}));var ne,re,ie,se,oe,ae,ue,ce,le,de=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),he=function(){function e(e,t){var n=t.auth,s=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=J.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:s,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof de){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case J.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return o=i.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case J.INITIALIZED:case J.DISCONNECTED:case J.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===J.CONNECTING||this._currentConnectionStateType===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof H?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 ee,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"),p.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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send websocket request (forced)",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(p.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}(),pe=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="/users/".concat(n,"/session_key"),o.method=d.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),fe=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(H),_e=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),ge=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 p(r.error):null,i}return t(n,e),n}(B),ye=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),me=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ve=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Ee=function(e,t,n){return void 0===n&&(n=new ve),r(void 0,void 0,void 0,(function(){var r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,o=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},a=function(){r=0},i.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 lt({userProfile:this}))},e}(),ht=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 dt(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new p(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=St.of(e);if(!t)throw p.lostInstance;t.sessionManager.auth.sessionKey=this.key,Me(e,this.ekey),this.userProfile.apply()},r}(B),pt=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),ft=function(e){function n(t,n){var r=n.sdkState,i=n.connectionHandlers,s=n.sessionManager,o=n.websocketClient,a=n.dispatcher,u=n.logger,c=n.entryState,l=void 0===c?new Re:c,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.connectionHandlers=i,d._sessionManager=s,d._websocketClient=o,d._dispatcher=a,d._logger=u,d._currentState=l,d._websocketClient.on("message",(function(e){if("LOGI"===e.code){d._loginTimer&&(clearTimeout(d._loginTimer),d._loginTimer=null);var t=e.as(ht);if(t.error)t.error.isSessionKeyExpiredError&&d._dispatcher.dispatch(new G),d._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),d._statLogConnection(t.error);else{t.applyTo(d._iid),d._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;d._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),d._statLogConnection(null)}d._connectionRequestQueue=[]}})).on("close",(function(){d._connectionRequestQueue.length>0&&(d._statLogConnection(p.networkError),d._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),d._connectionRequestQueue=[])})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new de({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},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._sessionManager.auth,a=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",u=s.sb_uikit?"u".concat(s.sb_uikit):"",c="JS/c".concat(l.SDK_VERSION,"/").concat(a,"/").concat(u);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(c,"&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=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new pt(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new K({type:P.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=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(ht.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(ht.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(M),_t=function(){function e(e,t){var n=t.sdkState,r=t.connectionHandlers,i=t.sessionManager,s=t.websocketClient,o=t.dispatcher,a=t.logger,u=t.disableAutoReconnect,c=void 0!==u&&u,l=this;this._context=null,this._logger=a,this._context=new ft(e,{sdkState:n,connectionHandlers:r,sessionManager:i,websocketClient:s,dispatcher:o,logger:a}),c||s.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){l._logger.debug("try reconnect by websocket connection closed"),l.reconnect()}),100)}))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===J.CONNECTING||e.type===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(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),r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),gt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Be),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"}(ut||(ut={}));var yt,mt=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=ut.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===ut.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var e,t;return i(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 gt({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 r(this,void 0,void 0,(function(){var t,n,r=this;return i(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 pt&&(r.enabledstate=e.enabled?ut.ENABLED:ut.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.enabledstate===ut.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 r(this,void 0,void 0,(function(){return i(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"}(yt||(yt={}));var vt,Et=function(){function e(){this.level=yt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var d=s(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?U({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}(),Dt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?a([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?U({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Mt=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?U({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}(),kt=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 Mt(e["og:image"]))}return e.payloadify=function(e){return e?U({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Mt.payloadify(e.defaultImage):null}):null},e}(),Lt=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.payloadify=function(e){return e?U({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Ct||(Ct={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ot||(Ot={}));var Ut,Pt=function(e){switch(e){case ie.BASE:return"";case ie.USER:return"MESG";case ie.FILE:return"FILE";case ie.ADMIN:return"ADMM"}},qt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=ne.BASE,g.messageId=0,g.parentMessageId=null,g.parentMessage=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=ie.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedUserIds=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(ne,n.channel_type)?n.channel_type:ne.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(o=n.data)&&void 0!==o?o:"",g.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",g.mentionType=m(ae,n.mention_type)?n.mention_type:null;var y=n.mentioned_users;g.mentionedUsers=y?y.map((function(e){return new ct(g._iid,e)})):null;var v=n.mentioned_user_ids;g.mentionedUserIds=null!=v?v:null,g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new At(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new Rt(e)})):[];for(var E=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),S=0;S=t)return this.parentMessage=e,!0}return!1},r}(Le),xt=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(re,n.role)?n.role:re.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?U(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(ct),Ft=function(e){function r(t,n){var r,i,s,o=this;if((o=e.call(this,t,n)||this).sender=null,o.reqId="",o.replyToChannel=!1,o.sendingStatus=le.PENDING,o.errorCode=0,o.sender=n.user?new xt(o._iid,n.user):n.sender_id,o.reqId=null!==(r=n.req_id)&&void 0!==r?r:"",o.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,o.sendingStatus=o.messageId>0?le.SUCCEEDED:le.FAILED,n.request_state&&m(le,n.request_state)&&(o.sendingStatus=n.request_state),n.scheduled_status)switch(n.scheduled_status){case Ot.SENT:case Ot.IN_QUEUE:o.sendingStatus=le.SUCCEEDED;break;case Ot.PENDING:o.sendingStatus=le.SCHEDULED;break;case Ot.FAILED:case Ot.REMOVED:o.sendingStatus=le.FAILED;break;case Ot.CANCELED:o.sendingStatus=le.CANCELED}return o.errorCode=null!==(s=n.error_code)&&void 0!==s?s:0,o}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{user:xt.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===le.FAILED&&((e=this.errorCode)>0&&f.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}(qt),Gt=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?U({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}(),Qt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},jt=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)},Kt=function(e){function s(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=ie.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),{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=Ht(t,l)}return u}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:Bt(t.parentMessage)})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},s}(qt),zt=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")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?U({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Vt=function(e){function o(t,r){var i,o,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.message=r.message,h.messageType=ie.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],h.translations==={}&&h.translationTargetLanguages.length>0)try{for(var p=s(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&&(o=p.return)&&o.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 zt(e)})):[],r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{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=Ht(t,y)}return h}return t(o,e),o.payloadify=function(t){return t?U(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 zt.payloadify(e)})),parent_message_info:Bt(t.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},o}(Ft),Bt=function(e){if(e)switch(e.messageType){case ie.USER:return Vt.payloadify(e);case ie.FILE:return Wt.payloadify(e);case ie.ADMIN:return Kt.payloadify(e)}return null},Ht=function(e,t){switch(t.type){case"MESG":return new Vt(e,t);case"FILE":return new Wt(e,t);case"ADMM":case"BRDM":return new Kt(e,t)}return null},Wt=function(e){function s(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,m,v=this;(v=e.call(this,t,r)||this).messageParams=null,v.plainUrl="",v.requireAuth=!1,v.name=null,v.size=0,v.type=null,v.thumbnails=[],v.messageSurvivalSeconds=-1,v.messageType=ie.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;if(v.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],v.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",v.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,v.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",v.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"",v.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,v.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Gt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(v.requireAuth?"?auth=".concat(Me(v._iid)):"")}))})):[],v.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),{file:I.file,url:null===(y=I.file)||void 0===y?void 0:y.url,require_auth:null===(m=I.file)||void 0===m?void 0:m.require_auth});v.parentMessage=Ht(t,S)}return v}return t(s,e),s.payloadify=function(t){return t?U(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:Bt(t.parentMessage)})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Me(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},s}(Ft),Xt=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ae.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:U({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!==ce.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,is_reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId})})||this}return t(n,e),n}(H),Yt=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=d.POST,r.path="".concat(We(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=U({message_type:ie.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 Gt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return Dt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Lt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),r}return t(n,e),n}(q),Jt=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new Wt(t,r);var u=St.of(t).sdkState;return a.isMentioned=Ye(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}(B),Zt=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new Wt(t,n);var o=St.of(t).sdkState;return s.isMentioned=Ye(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"}(Ut||(Ut={}));var $t,en=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 de&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===J.CONNECTED||this._connectionState===J.CONNECTING||this._connectionState===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._shouldSendThroughWebSocket?(r=new Xt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(Jt).message];case 2:return r=new Yt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(Zt).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.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,i.label=1;case 1:i.trys.push([1,15,16,17]),o=s(t.messageQueue),a=o.next(),i.label=2;case 2:if(a.done)return[3,14];switch(c=a.value,c.state){case Ut.PENDING:case Ut.UPLOADING:return[3,3];case Ut.UPLOADED:return[3,4];case Ut.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=Ut.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,me(100)];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),c.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return a=o.next(),[3,2];case 14:return[3,17];case 15:return h=i.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=o.return)&&g.call(o)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Ut.PENDING})))?S(n.params.file)?t.uploadQueue.length<6?(n.state=Ut.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!i.sent())return[3,8];i.label=2;case 2:return i.trys.push([2,4,5,7]),r=new bt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),o=s.as(Nt),a=o.url,u=o.fileSize,c=void 0===u?n.params.fileSize:u,l=o.thumbnailSizes,d=void 0===l?n.params.thumbnailSizes:l,h=o.requireAuth,f=void 0!==h&&h,n.params.fileUrl=a,n.params.fileSize=c,n.params.thumbnailSizes=d,n.params.requireAuth=f,n.requireAuth=f,n.state=Ut.UPLOADED,[3,7];case 4:return _=i.sent(),n.state=Ut.FAILED,n.error=_,[3,7];case 5:return(g=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(g,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return i.sent(),[7];case 7:return[3,10];case 8:return n.state=Ut.FAILED,n.error=p.connectionRequired,(g=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(g,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:i.sent(),i.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Ut.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:i.sent(),i.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,o,a;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new ee,S(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s: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:Ut.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.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 u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:a([],o(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Ut.PENDING:d.state=Ut.FAILED,d.error=p.requestCanceled,this._resolveMessageQueue(e);break;case Ut.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}(),tn={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ue.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},nn=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&m(ue,e.replyType)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.showSubchannelMessagesOnly)},rn={replyType:ue.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includePollDetails:!1},sn=function(e){return m(ue,e.replyType)&&y("boolean",e.includeReactions)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.includePollDetails)};!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.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"}($t||($t={}));var on,an=function(e){return e.startsWith("EVENT_")||e===$t.SYNC_MESSAGE_FILL||e===$t.SYNC_MESSAGE_CHANGELOGS},un=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),cn=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),ln=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),dn=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=t.includePollDetails,l=e.call(this)||this;return l.method=d.GET,l.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:c},l}return t(n,e),n}(q),hn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Ht(t,n({},r)):null,i}return t(r,e),r}(x),pn=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,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,v=t.parentMessageId,E=t.includeThreadInfo,I=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,T=t.includePollDetails,b=e.call(this)||this;return b.method=d.GET,b.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages"),b.params=U({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,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:m,parent_message_id:v,include_thread_info:E,include_parent_message_info:I,show_subchannel_message_only:S,include_poll_details:T}),b}return t(n,e),n}(q),fn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return Ht(t,e)})),r}return t(n,e),n}(x),_n=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,h=t.includePollDetails,p=e.call(this)||this;return p.method=d.GET,p.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),p.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:h},p}return t(n,e),n}(q),gn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Ht(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),yn=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(qe,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),mn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Ht(t,n({},r)):null,i}return t(r,e),r}(x),vn={},En=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._onlineDetector=s,this._cacheContext=o,this.fileMessageQueue=new en(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),vn[e]=this}return e.of=function(e){return vn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=ot(e);switch(t.messageType){case ie.USER:return new Vt(this._iid,Vt.payloadify(t));case ie.FILE:return new Wt(this._iid,Wt.payloadify(t));case ie.ADMIN:return new Kt(this._iid,Kt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return U({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)})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return U({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.url,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.buildSenderFromSerializedData=function(e){var t=ot(e);return new xt(this._iid,xt.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new dn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(hn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new yn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(mn).message]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,o,a){return void 0===a&&(a=$t.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new pn(n(n({channelType:t,channelUrl:e,timestamp:s},tn),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(fn).messages,this._dispatcher.dispatch(new un({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,o){return void 0===o&&(o=$t.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,a,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new pn(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},Qt),s),{replyType:ue.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return a=i.sent(),u=a.as(fn).messages,c=u.slice(1),this._dispatcher.dispatch(new un({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,o,a){return void 0===a&&(a=$t.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,d,h,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new _n(U(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},rn),o))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(gn),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 un({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new cn({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),In=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case le.PENDING:this._onPending(t);break;case le.FAILED:case le.CANCELED:this._onFailed(e,t.isResendable?t:null);break;case le.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}(),Sn=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.root_message_id,o=n.channel_url,a=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",o)&&y("string",a)&&(r.threadInfo=new At(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(Le),Tn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,includePollDetails:!1},bn=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 y("number",this.limit)&&this.limit>0},e}(),Nn=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,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(Qe,"/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:h,target_fields:p,after:f},_}return t(n,e),n}(q),An=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Ht(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(on||(on={}));var Cn=function(e){function s(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=on.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",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:on.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(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(on,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=St.of(this._iid).requestQueue,t=new Nn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(An),o=s.messages,a=s.hasNext,u=s.nextToken,this._nextToken=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(bn),On=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)&&y("string",this.channelUrl)&&m(ne,this.channelType)},n}(bn),wn=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=se.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ue.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:se.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:ue.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)&&y("boolean",this.reverse)&&m(se,this.messageTypeFilter)&&m(ue,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,En.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,a([Number.MAX_SAFE_INTEGER],o(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 p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(On),Rn={channelUrl:null,scheduledMessageId:0},Dn=function(e){function s(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(s,e),s.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 En(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},s.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},s.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},s.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return e=n(n({},Tn),e),at(function(e){return y("string",e.channelUrl)&&y("string",e.channelType)&&m(ne,e.channelType)&&y("number",e.messageId)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.includePollDetails)}(e)).throw(p.invalidParameters),[2,this._manager.getMessage(e)]}))}))},s.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return e=n(n({},Rn),e),at(function(e){return y("string",e.channelUrl)&&y("number",e.scheduledMessageId)}(e)).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(e)]}))}))},s}(Tt);export{L as $,d as A,bn as B,j as C,A as D,M as E,R as F,Dn as G,m as H,Le as I,ne as J,it as K,yt as L,Cn as M,se as N,ie as O,zt as P,Ft as Q,re as R,p as S,ue as T,ct as U,St as V,B as W,Vt as X,Wt as Y,En as Z,t as _,y as a,le as a0,I as a1,de as a2,J as a3,u as a4,un as a5,$t as a6,ae as a7,Dt as a8,ce as a9,cn as aA,xe as aB,qe as aC,Ve as aD,Ot as aE,st as aF,Jt as aG,z as aH,Ht as aI,an as aJ,Ee as aK,oe as aL,Gt as aM,Bt as aN,Nt as aO,bt as aP,Tt as aQ,Kt as aR,Sn as aS,Ge as aT,Fe as aU,on as aV,Mt as aW,kt as aX,Rt as aY,vt as aZ,At as a_,Lt as aa,We as ab,On as ac,Xe as ad,H as ae,Ye as af,Je as ag,wt as ah,g as ai,wn as aj,xt as ak,me as al,h as am,In as an,$e as ao,Ze as ap,tn as aq,nn as ar,rn as as,sn as at,ee as au,qt as av,T as aw,Ct as ax,Se as ay,ln as az,r as b,i as c,Ue as d,U as e,q as f,n as g,x as h,S as i,ze as j,Ke as k,E as l,o as m,Y as n,s as o,a as p,N as q,Me as r,ot as s,Ie as t,at as u,c as v,$ as w,lt as x,dt as y,b as z}; +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 o(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 a(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},S=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("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},T=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=a([],o(e),!1).sort(),r=a([],o(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){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),N={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:a([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,o,a,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=i.sent())&&void 0!==t?t:[],i.label=2;case 2:i.trys.push([2,7,8,9]),r=s(n),o=r.next(),i.label=3;case 3:return o.done?[3,6]:(a=o.value,[4,this._store.get(a)]);case 4:(u=i.sent())&&this._preference.set(a,u),i.label=5;case 5:return o=r.next(),[3,3];case 6:return[3,9];case 7:return c=i.sent(),l={error:c},[3,9];case 8:try{o&&!o.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 r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(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 r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(a([],o(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 o=[];try{for(var a=s(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&&o.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.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(){},U=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"}(d||(d={}));var P,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):""},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=U(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(e.stringifyParams(t[n])))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=U(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),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"}(P||(P={}));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 U({stat_type:e.type,ts:e.createdAt,data:U(e.data)})},e}(),z=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},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=z()?"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(l.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(l.OS_VERSION,",").concat(l.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:P.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 r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,h,f,_,g,y,m;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),s=this._sdkState.api,o="".concat(s.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),h=Date.now(),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(f=i.sent()).json()];case 3:if(_=i.sent(),f.ok||f.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new x(this._iid,_)];throw _?((g=new p(_)).isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,g),g):(g=p.requestFailed,this._statLogApiResult(e,h,g),g);case 4:throw y=i.sent(),this._statLogApiResult(e,h,y),y instanceof p?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?p.requestCanceled:(m=p.networkError,this._logger.debug("fail api request",m),m);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=s(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}(),B=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,o=this;return(o=e.call(this)||this)._iid=t,o.code=n,o.payload=r,o.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",o}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),H=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),W=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(H),X=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 W;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}(),Y=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(j||(j={}));var J,Z=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o._pinger=null,o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o._sdkState.websocket.pingerDisabled||(o._pinger=new X({pingDelegate:{send:function(e){return o.send(e)},error:function(e){return o.error(e)}},sdkState:o._sdkState,logger:s})),o}return t(n,e),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&&y("string",e)){var n=B.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.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._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=Y,this._ws.onmessage=Y,this._ws.onerror=Y,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(M),$=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),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=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 Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new $(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 p({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new ee,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.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 r(this,void 0,void 0,(function(){return i(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 H?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.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"}(J||(J={}));var ne,re,ie,se,oe,ae,ue,ce,le,de=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),he=function(){function e(e,t){var n=t.auth,s=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=J.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:s,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof de){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case J.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return o=i.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case J.INITIALIZED:case J.DISCONNECTED:case J.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===J.CONNECTING||this._currentConnectionStateType===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof H?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 ee,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"),p.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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send websocket request (forced)",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(p.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}(),pe=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="/users/".concat(n,"/session_key"),o.method=d.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),fe=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(H),_e=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),ge=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 p(r.error):null,i}return t(n,e),n}(B),ye=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),me=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ve=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Ee=function(e,t,n){return void 0===n&&(n=new ve),r(void 0,void 0,void 0,(function(){var r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,o=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},a=function(){r=0},i.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 lt({userProfile:this}))},e}(),ht=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 dt(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new p(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=St.of(e);if(!t)throw p.lostInstance;t.sessionManager.auth.sessionKey=this.key,Me(e,this.ekey),this.userProfile.apply()},r}(B),pt=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),ft=function(e){function n(t,n){var r=n.sdkState,i=n.connectionHandlers,s=n.sessionManager,o=n.websocketClient,a=n.dispatcher,u=n.logger,c=n.entryState,l=void 0===c?new Re:c,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.connectionHandlers=i,d._sessionManager=s,d._websocketClient=o,d._dispatcher=a,d._logger=u,d._currentState=l,d._websocketClient.on("message",(function(e){if("LOGI"===e.code){d._loginTimer&&(clearTimeout(d._loginTimer),d._loginTimer=null);var t=e.as(ht);if(t.error)t.error.isSessionKeyExpiredError&&d._dispatcher.dispatch(new G),d._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),d._statLogConnection(t.error);else{t.applyTo(d._iid),d._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;d._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),d._statLogConnection(null)}d._connectionRequestQueue=[]}})).on("close",(function(){d._connectionRequestQueue.length>0&&(d._statLogConnection(p.networkError),d._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),d._connectionRequestQueue=[])})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new de({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},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._sessionManager.auth,a=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",u=s.sb_uikit?"u".concat(s.sb_uikit):"",c="JS/c".concat(l.SDK_VERSION,"/").concat(a,"/").concat(u);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(c,"&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=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new pt(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new K({type:P.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=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(ht.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(ht.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(M),_t=function(){function e(e,t){var n=t.sdkState,r=t.connectionHandlers,i=t.sessionManager,s=t.websocketClient,o=t.dispatcher,a=t.logger,u=t.disableAutoReconnect,c=void 0!==u&&u,l=this;this._context=null,this._logger=a,this._context=new ft(e,{sdkState:n,connectionHandlers:r,sessionManager:i,websocketClient:s,dispatcher:o,logger:a}),c||s.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){l._logger.debug("try reconnect by websocket connection closed"),l.reconnect()}),100)}))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===J.CONNECTING||e.type===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(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),r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),gt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Be),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"}(ut||(ut={}));var yt,mt=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=ut.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===ut.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var e,t;return i(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 gt({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 r(this,void 0,void 0,(function(){var t,n,r=this;return i(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 pt&&(r.enabledstate=e.enabled?ut.ENABLED:ut.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.enabledstate===ut.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 r(this,void 0,void 0,(function(){return i(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"}(yt||(yt={}));var vt,Et=function(){function e(){this.level=yt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var d=s(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?U({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}(),Dt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?a([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?U({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Mt=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?U({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}(),kt=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 Mt(e["og:image"]))}return e.payloadify=function(e){return e?U({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Mt.payloadify(e.defaultImage):null}):null},e}(),Lt=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.payloadify=function(e){return e?U({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Ct||(Ct={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(Ot||(Ot={}));var Ut,Pt=function(e){switch(e){case ie.BASE:return"";case ie.USER:return"MESG";case ie.FILE:return"FILE";case ie.ADMIN:return"ADMM"}},qt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=ne.BASE,g.messageId=0,g.parentMessageId=null,g.parentMessage=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=ie.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedUserIds=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(ne,n.channel_type)?n.channel_type:ne.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(o=n.data)&&void 0!==o?o:"",g.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",g.mentionType=m(ae,n.mention_type)?n.mention_type:null;var y=n.mentioned_users;g.mentionedUsers=y?y.map((function(e){return new ct(g._iid,e)})):null;var v=n.mentioned_user_ids;g.mentionedUserIds=null!=v?v:null,g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new At(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new Rt(e)})):[];for(var E=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),S=0;S=t)return this.parentMessage=e,!0}return!1},r}(Le),xt=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(re,n.role)?n.role:re.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?U(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(ct),Ft=function(e){function r(t,n){var r,i,s,o=this;if((o=e.call(this,t,n)||this).sender=null,o.reqId="",o.replyToChannel=!1,o.sendingStatus=le.PENDING,o.errorCode=0,o.sender=n.user?new xt(o._iid,n.user):n.sender_id,o.reqId=null!==(r=n.req_id)&&void 0!==r?r:"",o.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,o.sendingStatus=o.messageId>0?le.SUCCEEDED:le.FAILED,n.request_state&&m(le,n.request_state)&&(o.sendingStatus=n.request_state),n.scheduled_status)switch(n.scheduled_status){case Ot.SENT:case Ot.IN_QUEUE:o.sendingStatus=le.SUCCEEDED;break;case Ot.PENDING:o.sendingStatus=le.SCHEDULED;break;case Ot.FAILED:case Ot.REMOVED:o.sendingStatus=le.FAILED;break;case Ot.CANCELED:o.sendingStatus=le.CANCELED}return o.errorCode=null!==(s=n.error_code)&&void 0!==s?s:0,o}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{user:xt.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===le.FAILED&&((e=this.errorCode)>0&&f.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}(qt),Gt=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?U({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}(),Qt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},jt=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)},Kt=function(e){function s(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=ie.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),{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=Ht(t,l)}return u}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:Bt(t.parentMessage)})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},s}(qt),zt=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")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?U({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Vt=function(e){function o(t,r){var i,o,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.message=r.message,h.messageType=ie.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],h.translations==={}&&h.translationTargetLanguages.length>0)try{for(var p=s(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&&(o=p.return)&&o.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 zt(e)})):[],r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{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=Ht(t,y)}return h}return t(o,e),o.payloadify=function(t){return t?U(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 zt.payloadify(e)})),parent_message_info:Bt(t.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},o}(Ft),Bt=function(e){if(e)switch(e.messageType){case ie.USER:return Vt.payloadify(e);case ie.FILE:return Wt.payloadify(e);case ie.ADMIN:return Kt.payloadify(e)}return null},Ht=function(e,t){switch(t.type){case"MESG":return new Vt(e,t);case"FILE":return new Wt(e,t);case"ADMM":case"BRDM":return new Kt(e,t)}return null},Wt=function(e){function s(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,m,v=this;(v=e.call(this,t,r)||this).messageParams=null,v.plainUrl="",v.requireAuth=!1,v.name=null,v.size=0,v.type=null,v.thumbnails=[],v.messageSurvivalSeconds=-1,v.messageType=ie.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;if(v.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],v.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",v.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,v.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",v.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"",v.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,v.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Gt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(v.requireAuth?"?auth=".concat(Me(v._iid)):"")}))})):[],v.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),{file:I.file,url:null===(y=I.file)||void 0===y?void 0:y.url,require_auth:null===(m=I.file)||void 0===m?void 0:m.require_auth});v.parentMessage=Ht(t,S)}return v}return t(s,e),s.payloadify=function(t){return t?U(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:Bt(t.parentMessage)})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(Me(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return t=n(n({},Qt),t),at(this.messageId>0&&y("number",e)&&jt(t)).throw(p.invalidParameters),[4,En.of(this._iid).getThreadedMessagesByTimestamp(this,e,t)];case 1:return[2,r.sent()]}}))}))},s}(Ft),Xt=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ae.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:U({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!==ce.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,is_reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId})})||this}return t(n,e),n}(H),Yt=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=d.POST,r.path="".concat(We(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=U({message_type:ie.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 Gt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return Dt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Lt.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),r}return t(n,e),n}(q),Jt=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new Wt(t,r);var u=St.of(t).sdkState;return a.isMentioned=Ye(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}(B),Zt=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new Wt(t,n);var o=St.of(t).sdkState;return s.isMentioned=Ye(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"}(Ut||(Ut={}));var $t,en=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 de&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===J.CONNECTED||this._connectionState===J.CONNECTING||this._connectionState===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._shouldSendThroughWebSocket?(r=new Xt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(Jt).message];case 2:return r=new Yt(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(Zt).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.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,i.label=1;case 1:i.trys.push([1,15,16,17]),o=s(t.messageQueue),a=o.next(),i.label=2;case 2:if(a.done)return[3,14];switch(c=a.value,c.state){case Ut.PENDING:case Ut.UPLOADING:return[3,3];case Ut.UPLOADED:return[3,4];case Ut.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=Ut.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,me(100)];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),c.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return a=o.next(),[3,2];case 14:return[3,17];case 15:return h=i.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=o.return)&&g.call(o)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Ut.PENDING})))?S(n.params.file)?t.uploadQueue.length<6?(n.state=Ut.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!i.sent())return[3,8];i.label=2;case 2:return i.trys.push([2,4,5,7]),r=new bt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),o=s.as(Nt),a=o.url,u=o.fileSize,c=void 0===u?n.params.fileSize:u,l=o.thumbnailSizes,d=void 0===l?n.params.thumbnailSizes:l,h=o.requireAuth,f=void 0!==h&&h,n.params.fileUrl=a,n.params.fileSize=c,n.params.thumbnailSizes=d,n.params.requireAuth=f,n.requireAuth=f,n.state=Ut.UPLOADED,[3,7];case 4:return _=i.sent(),n.state=Ut.FAILED,n.error=_,[3,7];case 5:return(g=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(g,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return i.sent(),[7];case 7:return[3,10];case 8:return n.state=Ut.FAILED,n.error=p.connectionRequired,(g=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(g,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:i.sent(),i.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Ut.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:i.sent(),i.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,o,a;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new ee,S(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s: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:Ut.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.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 u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:a([],o(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Ut.PENDING:d.state=Ut.FAILED,d.error=p.requestCanceled,this._resolveMessageQueue(e);break;case Ut.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}(),tn={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ue.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},nn=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&m(ue,e.replyType)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.showSubchannelMessagesOnly)},rn={replyType:ue.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includePollDetails:!1},sn=function(e){return m(ue,e.replyType)&&y("boolean",e.includeReactions)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.includePollDetails)};!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.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"}($t||($t={}));var on,an=function(e){return e.startsWith("EVENT_")||e===$t.SYNC_MESSAGE_FILL||e===$t.SYNC_MESSAGE_CHANGELOGS},un=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),cn=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),ln=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),dn=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=t.includePollDetails,l=e.call(this)||this;return l.method=d.GET,l.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:c},l}return t(n,e),n}(q),hn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Ht(t,n({},r)):null,i}return t(r,e),r}(x),pn=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,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,v=t.parentMessageId,E=t.includeThreadInfo,I=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,T=t.includePollDetails,b=e.call(this)||this;return b.method=d.GET,b.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages"),b.params=U({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,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:m,parent_message_id:v,include_thread_info:E,include_parent_message_info:I,show_subchannel_message_only:S,include_poll_details:T}),b}return t(n,e),n}(q),fn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return Ht(t,e)})),r}return t(n,e),n}(x),_n=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,h=t.includePollDetails,p=e.call(this)||this;return p.method=d.GET,p.path="".concat(We(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),p.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:h},p}return t(n,e),n}(q),gn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return Ht(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),yn=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(qe,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),mn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?Ht(t,n({},r)):null,i}return t(r,e),r}(x),vn={},En=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._onlineDetector=s,this._cacheContext=o,this.fileMessageQueue=new en(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),vn[e]=this}return e.of=function(e){return vn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=ot(e);switch(t.messageType){case ie.USER:return new Vt(this._iid,Vt.payloadify(t));case ie.FILE:return new Wt(this._iid,Wt.payloadify(t));case ie.ADMIN:return new Kt(this._iid,Kt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return U({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)})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return U({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.url,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.buildSenderFromSerializedData=function(e){var t=ot(e);return new xt(this._iid,xt.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new dn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(hn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new yn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(mn).message]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,o,a){return void 0===a&&(a=$t.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new pn(n(n({channelType:t,channelUrl:e,timestamp:s},tn),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(fn).messages,this._dispatcher.dispatch(new un({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,o){return void 0===o&&(o=$t.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,a,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new pn(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},Qt),s),{replyType:ue.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return a=i.sent(),u=a.as(fn).messages,c=u.slice(1),this._dispatcher.dispatch(new un({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,o,a){return void 0===a&&(a=$t.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,d,h,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new _n(U(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},rn),o))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(gn),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 un({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new cn({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),In=function(){function e(){this._onPending=Y,this._onFailed=Y,this._onSucceeded=Y}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case le.PENDING:this._onPending(t);break;case le.FAILED:case le.CANCELED:this._onFailed(e,t.isResendable?t:null);break;case le.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}(),Sn=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.root_message_id,o=n.channel_url,a=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",o)&&y("string",a)&&(r.threadInfo=new At(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(Le),Tn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,includePollDetails:!1},bn=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 y("number",this.limit)&&this.limit>0},e}(),Nn=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,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(Qe,"/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:h,target_fields:p,after:f},_}return t(n,e),n}(q),An=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return Ht(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(on||(on={}));var Cn=function(e){function s(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=on.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",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:on.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(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(on,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,o,a,u;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=St.of(this._iid).requestQueue,t=new Nn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(An),o=s.messages,a=s.hasNext,u=s.nextToken,this._nextToken=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(bn),On=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)&&y("string",this.channelUrl)&&m(ne,this.channelType)},n}(bn),wn=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=se.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ue.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:se.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:ue.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)&&y("boolean",this.reverse)&&m(se,this.messageTypeFilter)&&m(ue,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,En.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,a([Number.MAX_SAFE_INTEGER],o(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 p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(On),Rn={channelUrl:null,scheduledMessageId:0},Dn=function(e){function s(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(s,e),s.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 En(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},s.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},s.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},s.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return e=n(n({},Tn),e),at(function(e){return y("string",e.channelUrl)&&y("string",e.channelType)&&m(ne,e.channelType)&&y("number",e.messageId)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.includePollDetails)}(e)).throw(p.invalidParameters),[2,this._manager.getMessage(e)]}))}))},s.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return e=n(n({},Rn),e),at(function(e){return y("string",e.channelUrl)&&y("number",e.scheduledMessageId)}(e)).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(e)]}))}))},s}(Tt);export{L as $,d as A,bn as B,j as C,A as D,M as E,R as F,Dn as G,m as H,Le as I,ne as J,it as K,yt as L,Cn as M,se as N,ie as O,zt as P,Ft as Q,re as R,p as S,ue as T,ct as U,St as V,B as W,Vt as X,Wt as Y,En as Z,t as _,y as a,le as a0,I as a1,de as a2,J as a3,u as a4,un as a5,$t as a6,ae as a7,Dt as a8,ce as a9,cn as aA,xe as aB,qe as aC,Ve as aD,Ot as aE,st as aF,Jt as aG,z as aH,Ht as aI,an as aJ,Ee as aK,oe as aL,Gt as aM,Bt as aN,Nt as aO,bt as aP,Tt as aQ,Kt as aR,Sn as aS,Ge as aT,Fe as aU,on as aV,Mt as aW,kt as aX,Rt as aY,vt as aZ,At as a_,Lt as aa,We as ab,On as ac,Xe as ad,H as ae,Ye as af,Je as ag,wt as ah,g as ai,wn as aj,xt as ak,me as al,h as am,In as an,$e as ao,Ze as ap,tn as aq,nn as ar,rn as as,sn as at,ee as au,qt as av,T as aw,Ct as ax,Se as ay,ln as az,r as b,i as c,Ue as d,U as e,q as f,n as g,x as h,S as i,ze as j,Ke as k,E as l,o as m,Y as n,s as o,a as p,N as q,Me as r,ot as s,Ie as t,at as u,c as v,$ as w,lt as x,dt as y,b as z}; diff --git a/__bundle-d77a472f.js b/__bundle-9ac5dba1.js similarity index 98% rename from __bundle-d77a472f.js rename to __bundle-9ac5dba1.js index e4b34a9..cd208c6 100644 --- a/__bundle-d77a472f.js +++ b/__bundle-9ac5dba1.js @@ -1 +1 @@ -import{J as e,_ as n,W as t,U as a,aR as s,V as N,af as o,ag as E,ah as r,aS as i,n as u}from"./__bundle-e580e568.js";var _;!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"}(_||(_={}));var l=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}(),C=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new l(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,o=s.data.operators,E=void 0===o?[]:o;return N.operators=E.map((function(e){return new a(N._iid,e)})),N}return n(t,e),t}(C),h=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),A=function(e){function t(n,t,a){var E,r,i,u=this;(u=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var _=N.of(n).sdkState;return u.isMentioned=o(u.message.mentionType,null!==(E=u.message.mentionedUserIds)&&void 0!==E?E:null===(r=u.message.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),_.userId),u.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,u}return n(t,e),t}(t),c=function(e){function t(n,t,a){var o,r,i,u,_,l,C=this;(C=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=N.of(n).sdkState;return C.mentionCountChange=E({mentionType:null!==(r=null===(o=a.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==r?r:null,mentionedUserIds:null!==(u=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==u?u:[]},{mentionType:C.message.mentionType,mentionedUserIds:null!==(_=C.message.mentionedUserIds)&&void 0!==_?_:null===(l=C.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),C}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=u,this.onUserUnmuted=u,this.onUserBanned=u,this.onUserUnbanned=u,this.onChannelChanged=u,this.onChannelDeleted=u,this.onChannelFrozen=u,this.onChannelUnfrozen=u,this.onOperatorUpdated=u,this.onChannelMemberCountChanged=u,this.onMetaDataCreated=u,this.onMetaDataUpdated=u,this.onMetaDataDeleted=u,this.onMetaCounterCreated=u,this.onMetaCounterUpdated=u,this.onMetaCounterDeleted=u,this.onMessageReceived=u,this.onMessageUpdated=u,this.onMessageDeleted=u,this.onMentionReceived=u,this.onReactionUpdated=u,this.onThreadInfoUpdated=u};export{A,U as B,C,h as M,d as O,H as R,T,c as U,_ as a}; +import{J as e,_ as n,W as t,U as a,aR as s,V as N,af as o,ag as E,ah as r,aS as i,n as u}from"./__bundle-26bafa9e.js";var _;!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"}(_||(_={}));var l=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}(),C=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new l(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,o=s.data.operators,E=void 0===o?[]:o;return N.operators=E.map((function(e){return new a(N._iid,e)})),N}return n(t,e),t}(C),h=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),A=function(e){function t(n,t,a){var E,r,i,u=this;(u=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var _=N.of(n).sdkState;return u.isMentioned=o(u.message.mentionType,null!==(E=u.message.mentionedUserIds)&&void 0!==E?E:null===(r=u.message.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),_.userId),u.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,u}return n(t,e),t}(t),c=function(e){function t(n,t,a){var o,r,i,u,_,l,C=this;(C=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=N.of(n).sdkState;return C.mentionCountChange=E({mentionType:null!==(r=null===(o=a.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==r?r:null,mentionedUserIds:null!==(u=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==u?u:[]},{mentionType:C.message.mentionType,mentionedUserIds:null!==(_=C.message.mentionedUserIds)&&void 0!==_?_:null===(l=C.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),C}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=u,this.onUserUnmuted=u,this.onUserBanned=u,this.onUserUnbanned=u,this.onChannelChanged=u,this.onChannelDeleted=u,this.onChannelFrozen=u,this.onChannelUnfrozen=u,this.onOperatorUpdated=u,this.onChannelMemberCountChanged=u,this.onMetaDataCreated=u,this.onMetaDataUpdated=u,this.onMetaDataDeleted=u,this.onMetaCounterCreated=u,this.onMetaCounterUpdated=u,this.onMetaCounterDeleted=u,this.onMessageReceived=u,this.onMessageUpdated=u,this.onMessageDeleted=u,this.onMentionReceived=u,this.onReactionUpdated=u,this.onThreadInfoUpdated=u};export{A,U as B,C,h as M,d as O,H as R,T,c as U,_ as a}; diff --git a/__bundle-c65b6359.js b/__bundle-ae9e1003.js similarity index 99% rename from __bundle-c65b6359.js rename to __bundle-ae9e1003.js index 60355a7..500c712 100644 --- a/__bundle-c65b6359.js +++ b/__bundle-ae9e1003.js @@ -1 +1 @@ -import{N as e,O as t,Q as n,T as s,_ as r,S as a,g as i,X as c,Y as o,Z as u,b as l,c as h,I as d,o as f,U as p,$ as g,W as v,A as _,d as b,f as E,h as m,a0 as A,a1 as C,a2 as y,a3 as I,a4 as S,a5 as w,a6 as L}from"./__bundle-e580e568.js";import{s as T,e as N,F as M,i as P,f as O}from"./__bundle-fecd47ae.js";var R,U,D,x;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(R||(R={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(U||(U={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(D||(D={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(x||(x={}));var k,F,H,B=100,z="GroupChannel",q="url",G=100,K="Message",Q="messageId";!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"}(k||(k={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(F||(F={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(H||(H={}));var j,W=function(e){switch(e){case k.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case k.CHRONOLOGICAL:return["-createdAt","syncIndex"];case k.CHANNEL_NAME_ALPHABETICAL:return["name"]}},V=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=s.NONE}return r.prototype.clone=function(){var e=new r,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((function(n){e[n]=t[n]})),e},r.prototype.match=function(r){switch(this.messageTypeFilter){case e.USER:if(r.messageType!==t.USER)return!1;break;case e.FILE:if(r.messageType!==t.FILE)return!1;break;case e.ADMIN:if(r.messageType!==t.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof n))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case s.NONE:if(r.parentMessageId>0)return!1;break;case s.ONLY_REPLY_TO_CHANNEL:if(r instanceof n&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(j||(j={}));var Y,J=function(e){switch(e){case j.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case j.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},X="UnsentMessage",Z="reqId",$={},ee=function(e){function t(t,n){var s=n.sdkState,r=n.cacheContext,a=e.call(this,t)||this;return a._sdkState=s,a._cacheContext=r,$[t]=a,a}return r(t,e),t.of=function(e){return $[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw a.invalidParameters;var t=i({},e.serialize());return e instanceof c?t.messageParams=T(e.messageParams):e instanceof o&&(t.messageParams=N(e.messageParams)),t},t.prototype._deserialize=function(e){return e?(e=i(i({},e),{messageId:parseInt(e.messageId)}),u.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype.get=function(e){return l(this,void 0,void 0,(function(){var t;return h(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]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,s=e.filter,r=void 0===s?new V:s,a=e.order,i=void 0===a?j.CHANNEL_LATEST:a,d=e.sendingStatus,f=void 0===d?null:d,p=e.backward,g=void 0!==p&&p,v=e.parentMessageId,_=void 0===v?null:v;return l(this,void 0,void 0,(function(){var e,t,s,a,d=this;return h(this,(function(p){switch(p.label){case 0:return this.localCacheEnabled?(e=J(i),t={"/where":function(e){return!!(i!==j.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&r.match(d._deserialize(e))}},n&&(t.channelUrl=n),f&&(t.sendingStatus=f),s={where:t,index:e,backward:g},[4,this.collection.query(s)]):[3,3];case 1:return[4,p.sent().fetch({})];case 2:return a=p.sent(),[2,Promise.all(a.map((function(e){return l(d,void 0,void 0,(function(){var t,n,s,r;return h(this,(function(a){switch(a.label){case 0:return t=this._deserialize(e),(n=e.messageParams)?(s=u.of(this._iid),t instanceof c?(t.messageParams=s.buildUserMessageCreateParamsFromSerializedData(n,t),[3,4]):[3,1]):[3,4];case 1:return t instanceof o?n.fileKey&&"string"==typeof n.fileKey&&O(n.fileType)?(r=n,[4,this.collection.getBlob(n.fileKey)]):[3,3]:[3,4];case 2:r.file=a.sent(),a.label=3;case 3:t.messageParams=s.buildFileMessageCreateParamsFromSerializedData(n,t),a.label=4;case 4:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new V),l(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:j.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return l(this,void 0,void 0,(function(){var t,n=this;return h(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return s.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.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=s.sent(),s.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return l(this,void 0,void 0,(function(){var t,n,s,r,a,i;return h(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),t=f(e),n=t.next(),c.label=2;case 2:return n.done?[3,5]:(s=n.value,[4,this.collection.remove(s)]);case 3:c.sent(),c.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return r=c.sent(),a={error:r},[3,8];case 7:try{n&&!n.done&&(i=t.return)&&i.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.clear=function(){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.saveBlobs=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.label){case 0:return e instanceof o&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=s.sent(),t.fileKey=n,t.fileType=M.BLOB,s.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(d),te={},ne=function(e){function t(t,n){var s=n.sdkState,r=n.cacheContext,a=n.unsentMessageCache,i=e.call(this,t)||this;return i._sdkState=s,i._cacheContext=r,i._unsentMessageCache=a,te[t]=i,i}return r(t,e),t.of=function(e){return te[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return i(i({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=i(i({},e),{messageId:parseInt(e.messageId)}),u.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return l(this,void 0,void 0,(function(){var t;return h(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]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,s=e.limit,r=void 0===s?100:s,a=e.filter,i=void 0===a?new V:a,u=e.order,d=void 0===u?j.CHANNEL_LATEST:u,f=e.backward,p=void 0!==f&&f,g=e.parentMessageId,v=void 0===g?null:g;return l(this,void 0,void 0,(function(){var e,s,a,u=this;return h(this,(function(f){switch(f.label){case 0:return this.localCacheEnabled?(e=J(d),s={where:{channelUrl:t,"/where":function(e){if(n)switch(d){case j.CHANNEL_LATEST:if(!p&&e.createdAt>n||p&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=s.sent(),s.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return l(this,void 0,void 0,(function(){var t,n,s,r,a,i;return h(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),t=f(e),n=t.next(),c.label=2;case 2:return n.done?[3,5]:(s=n.value,[4,this.collection.remove("".concat(s))]);case 3:c.sent(),c.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return r=c.sent(),a={error:r},[3,8];case 7:try{n&&!n.done&&(i=t.return)&&i.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return l(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:J(j.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]}}))}))},t.prototype.removeUnderOffset=function(e,t){return l(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:J(j.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.countBetween=function(e,t,n){return l(this,void 0,void 0,(function(){var s,r=this;return h(this,(function(a){switch(a.label){case 0:return this.localCacheEnabled?(s=J(j.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var s=r._deserialize(e);return n.includes(s.createdAt)&&t.match(s)}},index:s}).count()]):[3,2];case 1:return[2,a.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.label){case 0:return e instanceof o&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=s.sent(),t.fileKey=n,s.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(d);!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Y||(Y={}));var se=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,s=n.blocker,r=n.blockee;return{blocker:new p(e,s),blockee:new p(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new p(e,t)})):[]}},e}(),re=function(e){function t(t,n){var s=n.userId,r=e.call(this)||this;return r._iid=t,r.userId=s,r}return r(t,e),t}(g),ae=function(e){function t(t,n,s){var r=e.call(this,t,"USEV",s)||this;return r.event=new se(s),r}return r(t,e),t}(v),ie=function(e){function t(t){var n=t.userId,s=e.call(this)||this;return s.method=_.GET,s.path="".concat(b,"/").concat(encodeURIComponent(n),"/push_preference"),s}return r(t,e),t}(E),ce=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.pushTriggerOption=n.push_trigger_option,s}return r(t,e),t}(m),oe=function(e){function t(t){var n=t.userId,s=t.pushTriggerOption,r=e.call(this)||this;return r.method=_.PUT,r.path="".concat(b,"/").concat(encodeURIComponent(n),"/push_preference"),r.params={push_trigger_option:s},r}return r(t,e),t}(E),ue=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.pushTriggerOption=n.push_trigger_option,s}return r(t,e),t}(m),le=function(e){function t(t){var n=t.message,s=e.call(this)||this;return s.message=n,s}return r(t,e),t}(g),he={},de=function(){function e(e,t){var n=t.localCacheEnabled,s=t.dispatcher,r=t.sdkState,a=t.logger,i=this;this._iid=e,he[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=s,this._logger=a,this._sdkState=r,this._localCacheEnabled&&s.on((function(e){if(e instanceof y)switch(e.stateType){case I.CONNECTED:i._isProcessingAutoResend||i.processAutoResendRegisteredPendingMessages().then((function(){return i._processNextAutoResend()}));break;case I.DISCONNECTED:i._isProcessingAutoResend=!1}}))}return e.of=function(e){return he[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return l(this,void 0,void 0,(function(){var e,t,n,s,r,a;return h(this,(function(i){switch(i.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=i.sent();try{for(t=f(e),n=t.next();!n.done;n=t.next())0===(s=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=A.FAILED,s.errorCode=S.ACK_TIMEOUT,this._dispatcher.dispatch(new w({messages:[s],source:L.LOCAL_MESSAGE_FAILED})))}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(r)throw r.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return l(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,c;return h(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=f(e),n=t.next();!n.done;n=t.next())(s=n.value).errorCode&&C(s.errorCode)&&(r=(new Date).getTime(),a=s.createdAt+2592e5,r<=a?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(a).toLocaleString()),s.sendingStatus=A.FAILED,this._dispatcher.dispatch(new w({messages:[s],source:L.LOCAL_MESSAGE_FAILED}))))}catch(e){i={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===A.SUCCEEDED||e.sendingStatus===A.FAILED&&!C(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return l(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,ee.of(this._iid).fetch({sendingStatus:A.PENDING,backward:!0})];case 1:return[2,e.sent()]}}))}))},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 l(this,void 0,void 0,(function(){var e;return h(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 le({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}();export{de as A,re as D,k as G,j as M,z as N,D as P,ue as S,ae as U,q as a,K as b,Q as c,J as d,X as e,Z as f,W as g,Y as h,se as i,ne as j,ee as k,R as l,ce as m,ie as n,U as o,oe as p,x as q,B as r,le as s,G as t,V as u,F as v,H as w}; +import{N as e,O as t,Q as n,T as s,_ as r,S as a,g as i,X as c,Y as o,Z as u,b as l,c as h,I as d,o as f,U as p,$ as g,W as v,A as _,d as b,f as E,h as m,a0 as A,a1 as C,a2 as y,a3 as I,a4 as S,a5 as w,a6 as L}from"./__bundle-26bafa9e.js";import{s as T,e as N,F as M,i as P,f as O}from"./__bundle-f79aa272.js";var R,U,D,x;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(R||(R={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(U||(U={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(D||(D={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(x||(x={}));var k,F,H,B=100,z="GroupChannel",q="url",G=100,K="Message",Q="messageId";!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"}(k||(k={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(F||(F={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(H||(H={}));var j,W=function(e){switch(e){case k.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case k.CHRONOLOGICAL:return["-createdAt","syncIndex"];case k.CHANNEL_NAME_ALPHABETICAL:return["name"]}},V=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=s.NONE}return r.prototype.clone=function(){var e=new r,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((function(n){e[n]=t[n]})),e},r.prototype.match=function(r){switch(this.messageTypeFilter){case e.USER:if(r.messageType!==t.USER)return!1;break;case e.FILE:if(r.messageType!==t.FILE)return!1;break;case e.ADMIN:if(r.messageType!==t.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof n))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case s.NONE:if(r.parentMessageId>0)return!1;break;case s.ONLY_REPLY_TO_CHANNEL:if(r instanceof n&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(j||(j={}));var Y,J=function(e){switch(e){case j.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case j.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},X="UnsentMessage",Z="reqId",$={},ee=function(e){function t(t,n){var s=n.sdkState,r=n.cacheContext,a=e.call(this,t)||this;return a._sdkState=s,a._cacheContext=r,$[t]=a,a}return r(t,e),t.of=function(e){return $[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw a.invalidParameters;var t=i({},e.serialize());return e instanceof c?t.messageParams=T(e.messageParams):e instanceof o&&(t.messageParams=N(e.messageParams)),t},t.prototype._deserialize=function(e){return e?(e=i(i({},e),{messageId:parseInt(e.messageId)}),u.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype.get=function(e){return l(this,void 0,void 0,(function(){var t;return h(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]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,s=e.filter,r=void 0===s?new V:s,a=e.order,i=void 0===a?j.CHANNEL_LATEST:a,d=e.sendingStatus,f=void 0===d?null:d,p=e.backward,g=void 0!==p&&p,v=e.parentMessageId,_=void 0===v?null:v;return l(this,void 0,void 0,(function(){var e,t,s,a,d=this;return h(this,(function(p){switch(p.label){case 0:return this.localCacheEnabled?(e=J(i),t={"/where":function(e){return!!(i!==j.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&r.match(d._deserialize(e))}},n&&(t.channelUrl=n),f&&(t.sendingStatus=f),s={where:t,index:e,backward:g},[4,this.collection.query(s)]):[3,3];case 1:return[4,p.sent().fetch({})];case 2:return a=p.sent(),[2,Promise.all(a.map((function(e){return l(d,void 0,void 0,(function(){var t,n,s,r;return h(this,(function(a){switch(a.label){case 0:return t=this._deserialize(e),(n=e.messageParams)?(s=u.of(this._iid),t instanceof c?(t.messageParams=s.buildUserMessageCreateParamsFromSerializedData(n,t),[3,4]):[3,1]):[3,4];case 1:return t instanceof o?n.fileKey&&"string"==typeof n.fileKey&&O(n.fileType)?(r=n,[4,this.collection.getBlob(n.fileKey)]):[3,3]:[3,4];case 2:r.file=a.sent(),a.label=3;case 3:t.messageParams=s.buildFileMessageCreateParamsFromSerializedData(n,t),a.label=4;case 4:return[2,t]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new V),l(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:j.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return l(this,void 0,void 0,(function(){var t,n=this;return h(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return s.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.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=s.sent(),s.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return l(this,void 0,void 0,(function(){var t,n,s,r,a,i;return h(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),t=f(e),n=t.next(),c.label=2;case 2:return n.done?[3,5]:(s=n.value,[4,this.collection.remove(s)]);case 3:c.sent(),c.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return r=c.sent(),a={error:r},[3,8];case 7:try{n&&!n.done&&(i=t.return)&&i.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.clear=function(){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.saveBlobs=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.label){case 0:return e instanceof o&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=s.sent(),t.fileKey=n,t.fileType=M.BLOB,s.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(d),te={},ne=function(e){function t(t,n){var s=n.sdkState,r=n.cacheContext,a=n.unsentMessageCache,i=e.call(this,t)||this;return i._sdkState=s,i._cacheContext=r,i._unsentMessageCache=a,te[t]=i,i}return r(t,e),t.of=function(e){return te[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return i(i({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=i(i({},e),{messageId:parseInt(e.messageId)}),u.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return l(this,void 0,void 0,(function(){var t;return h(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]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,s=e.limit,r=void 0===s?100:s,a=e.filter,i=void 0===a?new V:a,u=e.order,d=void 0===u?j.CHANNEL_LATEST:u,f=e.backward,p=void 0!==f&&f,g=e.parentMessageId,v=void 0===g?null:g;return l(this,void 0,void 0,(function(){var e,s,a,u=this;return h(this,(function(f){switch(f.label){case 0:return this.localCacheEnabled?(e=J(d),s={where:{channelUrl:t,"/where":function(e){if(n)switch(d){case j.CHANNEL_LATEST:if(!p&&e.createdAt>n||p&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=s.sent(),s.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return l(this,void 0,void 0,(function(){var t,n,s,r,a,i;return h(this,(function(c){switch(c.label){case 0:if(!this.localCacheEnabled)return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),t=f(e),n=t.next(),c.label=2;case 2:return n.done?[3,5]:(s=n.value,[4,this.collection.remove("".concat(s))]);case 3:c.sent(),c.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return r=c.sent(),a={error:r},[3,8];case 7:try{n&&!n.done&&(i=t.return)&&i.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return l(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:J(j.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]}}))}))},t.prototype.removeUnderOffset=function(e,t){return l(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:J(j.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return l(this,void 0,void 0,(function(){return h(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]}}))}))},t.prototype.countBetween=function(e,t,n){return l(this,void 0,void 0,(function(){var s,r=this;return h(this,(function(a){switch(a.label){case 0:return this.localCacheEnabled?(s=J(j.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var s=r._deserialize(e);return n.includes(s.createdAt)&&t.match(s)}},index:s}).count()]):[3,2];case 1:return[2,a.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return l(this,void 0,void 0,(function(){var t=this;return h(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return l(t,void 0,void 0,(function(){var t,n;return h(this,(function(s){switch(s.label){case 0:return e instanceof o&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=s.sent(),t.fileKey=n,s.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(d);!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Y||(Y={}));var se=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,s=n.blocker,r=n.blockee;return{blocker:new p(e,s),blockee:new p(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new p(e,t)})):[]}},e}(),re=function(e){function t(t,n){var s=n.userId,r=e.call(this)||this;return r._iid=t,r.userId=s,r}return r(t,e),t}(g),ae=function(e){function t(t,n,s){var r=e.call(this,t,"USEV",s)||this;return r.event=new se(s),r}return r(t,e),t}(v),ie=function(e){function t(t){var n=t.userId,s=e.call(this)||this;return s.method=_.GET,s.path="".concat(b,"/").concat(encodeURIComponent(n),"/push_preference"),s}return r(t,e),t}(E),ce=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.pushTriggerOption=n.push_trigger_option,s}return r(t,e),t}(m),oe=function(e){function t(t){var n=t.userId,s=t.pushTriggerOption,r=e.call(this)||this;return r.method=_.PUT,r.path="".concat(b,"/").concat(encodeURIComponent(n),"/push_preference"),r.params={push_trigger_option:s},r}return r(t,e),t}(E),ue=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.pushTriggerOption=n.push_trigger_option,s}return r(t,e),t}(m),le=function(e){function t(t){var n=t.message,s=e.call(this)||this;return s.message=n,s}return r(t,e),t}(g),he={},de=function(){function e(e,t){var n=t.localCacheEnabled,s=t.dispatcher,r=t.sdkState,a=t.logger,i=this;this._iid=e,he[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=s,this._logger=a,this._sdkState=r,this._localCacheEnabled&&s.on((function(e){if(e instanceof y)switch(e.stateType){case I.CONNECTED:i._isProcessingAutoResend||i.processAutoResendRegisteredPendingMessages().then((function(){return i._processNextAutoResend()}));break;case I.DISCONNECTED:i._isProcessingAutoResend=!1}}))}return e.of=function(e){return he[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return l(this,void 0,void 0,(function(){var e,t,n,s,r,a;return h(this,(function(i){switch(i.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=i.sent();try{for(t=f(e),n=t.next();!n.done;n=t.next())0===(s=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",s.reqId),s.sendingStatus=A.FAILED,s.errorCode=S.ACK_TIMEOUT,this._dispatcher.dispatch(new w({messages:[s],source:L.LOCAL_MESSAGE_FAILED})))}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(r)throw r.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return l(this,void 0,void 0,(function(){var e,t,n,s,r,a,i,c;return h(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=f(e),n=t.next();!n.done;n=t.next())(s=n.value).errorCode&&C(s.errorCode)&&(r=(new Date).getTime(),a=s.createdAt+2592e5,r<=a?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(s.reqId)<0&&this._autoResendQueue.push(s):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(a).toLocaleString()),s.sendingStatus=A.FAILED,this._dispatcher.dispatch(new w({messages:[s],source:L.LOCAL_MESSAGE_FAILED}))))}catch(e){i={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===A.SUCCEEDED||e.sendingStatus===A.FAILED&&!C(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return l(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,ee.of(this._iid).fetch({sendingStatus:A.PENDING,backward:!0})];case 1:return[2,e.sent()]}}))}))},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 l(this,void 0,void 0,(function(){var e;return h(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 le({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}();export{de as A,re as D,k as G,j as M,z as N,D as P,ue as S,ae as U,q as a,K as b,Q as c,J as d,X as e,Z as f,W as g,Y as h,se as i,ne as j,ee as k,R as l,ce as m,ie as n,U as o,oe as p,x as q,B as r,le as s,G as t,V as u,F as v,H as w}; diff --git a/__bundle-fecd47ae.js b/__bundle-f79aa272.js similarity index 60% rename from __bundle-fecd47ae.js rename to __bundle-f79aa272.js index b8f6890..6976463 100644 --- a/__bundle-fecd47ae.js +++ b/__bundle-f79aa272.js @@ -1 +1 @@ -import{a7 as e,a as t,H as n,l as r,U as i,a8 as a,a9 as s,aa as o,g as u,e as c,i as l,_ as d,A as h,ab as p,f,h as m,b as v,c as y,ac as g,S as _,V as T,W as U,ad as I,J as w,ae as E,X as M,af as b,ag as S,Y as C,ah as A,F as P,ai as D,aj as R,ak as q,a0 as N,o as k,O,a1 as L,a4 as F,u as Q,al as z,a5 as x,a6 as G,t as V,am as j,Z as B,an as W,I as K,ao as Y,ap as H,p as J,m as X,aq as Z,ar as $,as as ee,at as te,au as ne,Q as re,av as ie}from"./__bundle-e580e568.js";var ae,se={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},oe=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)},ue=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ce=u(u({},se),{message:null,translationTargetLanguages:null}),le=function(e){return oe(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ae||(ae={}));var de,he=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},pe=function(e){return e===ae.BLOB||e===ae.FILE},fe=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},me=u(u({},se),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),ve=function(e){return oe(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"}(de||(de={}));var ye,ge=function(){function e(e){var t,r,i;this.restrictionType=null,this.description=null,this.endAt=-1,n(de,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}(),_e=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new ge(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),ge.payloadify(t.restrictionInfo))):null},t}(i),Te={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},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)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},Ie=u(u({},Te),{message:null,translationTargetLanguages:null}),we=function(e){return Ue(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)},Ee=u({},Te),Me=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),Se=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 Me(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),Ce=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 _e(t,e)}))),r}return d(t,e),t}(m),Pe=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 Ce(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),De=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),Re=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 _e(t,e.user)}))),r}return d(t,e),t}(m),qe=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 De(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Re),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"}(ye||(ye={}));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.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 ke=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 Oe=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),Le=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),Fe=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),Qe=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),ze=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),xe=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),Ge=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),Ve=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),je=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),Be=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),We=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),Ke=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),Ye=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),He=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),Je=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,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),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),$e=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),et=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 tt=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 nt=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 rt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new _e(t,r.data),i}return d(t,e),t}(U),it=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 at=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new _e(t,r.data),i}return d(t,e),t}(U),st=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 ot=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 _e(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),ut=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 ct=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new _e(t,r.data),i}return d(t,e),t}(U),lt=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 dt=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),ht=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),pt=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="/report/users/".concat(o),n.params={channel_url:r,channel_type:i===w.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),ft=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),mt=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,is_reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId})})||this}return d(n,t),n}(E),vt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new M(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),yt=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:"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:r,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return d(n,t),n}(E),gt=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 M(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({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),_t=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:"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),Tt=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 C(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({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),Ut=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 It=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),wt=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),Et=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),Mt=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),bt=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),St=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),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new M(t,n),r}return d(t,e),t}(m),At=function(e){function l(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=w.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(l,e),l.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}))},l.prototype.isGroupChannel=function(){return this.channelType===w.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===w.OPEN},Object.defineProperty(l.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),l.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})}))},l.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 St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Ct).message]}}))}))},l.prototype.sendFileMessage=function(e){return e=u(u({},me),e),Q(ve(e)).throw(_.invalidParameters),this._sendFileMessage(e)},l.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Date.now()),void 0===n&&(n=null);var i=T.of(this._iid).dispatcher,a=B.of(this._iid).fileMessageQueue,s=n,o=new W;return s||(s=this._generateRequestId(),z(2).then((function(){var n=r._createPendingFileMessage(e,s,t);i.dispatch(new x({messages:[n],source:G.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,n)]}))}))}))})).catch((function(e){throw e}))),a.request(this,s,e).then((function(e){i.dispatch(new x({messages:[e],source:G.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(n){if(j(n))throw n;z(2).then((function(){var a=r._createPendingFileMessage(e,s,t);r._markMessageAsFailed(a,n),i.dispatch(new x({messages:[a],source:a.sendingStatus===N.PENDING?G.REQUEST_RESEND_MESSAGE:G.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(n,a)]}))}))}))})).catch((function(e){throw e}))})),o},l.prototype._autoResendFileMessage=function(e){Q(e instanceof C).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.createdAt,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},l.prototype.sendFileMessages=function(e){var t,n;Q(e.every((function(e){return ve(u(u({},me),e))}))).throw(_.invalidParameters);var r=new W;try{for(var i=k(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},l.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(a){return Q(e instanceof C&&t instanceof Blob).throw(_.invalidParameters),r=new ne,i=null!==(n=e.messageParams)&&void 0!==n?n:function(e,t){return void 0===t&&(t=null),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:t,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(i).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},l.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s,o,c;return y(this,(function(l){switch(l.label){case 0:return n=u(u({},Ee),n),Q(t("number",e)&&function(e){return Ue(e)}(n)).throw(_.invalidParameters),r=T.of(this._iid),i=r.dispatcher,a=r.requestQueue,s=new _t(u({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,a.send(s)];case 1:return o=l.sent(),c=o.as(Tt).message,i.dispatch(new x({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(t("string",e)).throw(_.invalidParameters),B.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.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 Q(e instanceof l&&t instanceof C&&e.url===t.channelUrl).throw(_.invalidParameters),i=new ne,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}),e._sendFileMessage(a).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},l.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 Q(e instanceof re).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Ut({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]}}))}))},l.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 Q(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new wt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Et).reactionEvent]}}))}))},l.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 Q(e instanceof ie&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Mt({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]}}))}))},l.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 yt({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(gt).message,a.dispatch(new x({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return Q(e instanceof re&&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)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(i){return Q(e instanceof re&&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)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(e instanceof re&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(e instanceof re&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.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 Q(n(ye,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new ht({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},l.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 Q(e instanceof i&&n(ye,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new pt({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]}}))}))},l.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 Q(e instanceof re&&n(ye,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new ft({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]}}))}))},l}(K);export{qe as B,It as D,ae as F,Pe as M,Se as O,ye as R,$e as U,At as a,_e as b,ge as c,de as d,fe as e,pe as f,Ge as g,dt as h,he as i,ct as j,ot as k,rt as l,at as m,gt as n,Tt as o,vt as p,ce as q,se as r,ue as s,oe as t,Te as u,le as v,Ue as w,Ie as x,we as y}; +import{a7 as e,a as t,H as n,l as r,U as a,a8 as i,a9 as s,aa as o,g as u,e as c,i as l,_ as d,A as h,ab as p,f,h as m,b as v,c as y,ac as g,S as _,V as T,W as U,ad as I,J as w,ae as E,X as M,af as b,ag as S,Y as C,ah as A,F as P,ai as D,aj as R,ak as q,a0 as N,o as k,O,a1 as L,a4 as F,u as Q,al as z,a5 as x,a6 as G,t as V,am as j,Z as B,an as W,I as K,ao as Y,ap as H,p as J,m as X,aq as Z,ar as $,as as ee,at as te,au as ne,Q as re,av as ae}from"./__bundle-26bafa9e.js";var ie,se={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},oe=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(a,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(i,u.metaArrays,!0)&&t("number",u.parentMessageId,!0)&&t("boolean",u.isReplyToChannel)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},ue=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ce=u(u({},se),{message:null,translationTargetLanguages:null}),le=function(e){return oe(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ie||(ie={}));var de,he=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},pe=function(e){return e===ie.BLOB||e===ie.FILE},fe=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},me=u(u({},se),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),ve=function(e){return oe(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"}(de||(de={}));var ye,ge=function(){function e(e){var t,r,a;this.restrictionType=null,this.description=null,this.endAt=-1,n(de,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(a=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?c({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},e}(),_e=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new ge(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),ge.payloadify(t.restrictionInfo))):null},t}(a),Te={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Ue=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(a,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(i,u.metaArrays,!0)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},Ie=u(u({},Te),{message:null,translationTargetLanguages:null}),we=function(e){return Ue(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)},Ee=u({},Te),Me=function(e){function t(t){var n=t.channelUrl,r=t.channelType,a=t.token,i=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:a,limit:i},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 a(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Se=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||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,a,i,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 Me(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=o.sent(),a=r.as(be),i=a.operators,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),Ce=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:i,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 a=n.next,i=n.muted_list;return r.token=a,i&&i.length>0&&(r.mutedUsers=i.map((function(e){return new _e(t,e)}))),r}return d(t,e),t}(m),Pe=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,a,i;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 Ce(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Ae),a=r.mutedUsers,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(g),De=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({limit:i,token:s}),n}return d(t,e),t}(f),Re=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var a=n.next,i=n.banned_list;return r.token=a,i&&i.length>0&&(r.bannedUsers=i.map((function(e){return new _e(t,e.user)}))),r}return d(t,e),t}(m),qe=function(e){function t(t,n,r,a){return e.call(this,t,n,r,a)||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,a,i;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 De(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Re),a=r.bannedUsers,i=r.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,a];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"}(ye||(ye={}));var Ne=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ke=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:i},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 Oe=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/mute/").concat(i),n}return d(t,e),t}(f),Le=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 a=n.is_muted,i=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=a,r.startAt=i,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),Fe=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:i,include_ts:!0},n}return d(t,e),t}(f),Qe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return d(t,e),t}(m),ze=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:i,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.metadata,i=n.ts;return r.metadata=a,r.ts=null!=i?i:null,r}return d(t,e),t}(m),Ge=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return d(t,e),t}(U),Ve=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metadata/").concat(i),n.params={include_ts:!0},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 a=n.ts;return r.ts=null!=a?a:null,r}return d(t,e),t}(m),Be=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),We=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var a=n.ts;return r.ts=null!=a?a:null,r}return d(t,e),t}(m),Ke=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:i},n}return d(t,e),t}(f),Ye=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),He=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i},n}return d(t,e),t}(f),Je=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,a=t.channelType,i=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(a),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:i,upsert:o,mode:c},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),$e=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.created=null,a.updated=null,a.deleted=null,r.data&&(a.created=r.data.created,a.updated=r.data.updated,a.deleted=r.data.deleted),a}return d(t,e),t}(U),et=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/metacounter/").concat(i),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 tt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").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 nt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:i,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 rt=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new _e(t,r.data),a}return d(t,e),t}(U),at=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(i)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var it=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new _e(t,r.data),a}return d(t,e),t}(U),st=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/ban"),n.params=c({user_id:i,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 ot=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.memberCount=null,a.joinedMemberCount=null,a.user=new _e(t,r.data),r.data.member_count&&(a.memberCount=r.data.member_count),r.data.joined_member_count&&(a.joinedMemberCount=r.data.joined_member_count),a}return d(t,e),t}(U),ut=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(i)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var ct=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.user=new _e(t,r.data),a}return d(t,e),t}(U),lt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(a),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:i},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var dt=function(e){function t(t,n,r){var a=e.call(this,t,"SYEV",r)||this;return a.freeze=r.data.freeze,a}return d(t,e),t}(U),ht=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(a),"/").concat(encodeURIComponent(r)),n.params={report_category:i,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),pt=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="/report/users/".concat(o),n.params={channel_url:r,channel_type:a===w.OPEN?"open_channels":"group_channels",report_category:i,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),ft=function(e){function t(t){var n=this,r=t.channelUrl,a=t.channelType,i=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(a),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:i,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),mt=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,is_reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId})})||this}return d(n,t),n}(E),vt=function(e){function t(t,n,r){var a,i,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new M(t,r);var u=T.of(t).sdkState;return o.isMentioned=b(o.message.mentionType,null!==(a=o.message.mentionedUserIds)&&void 0!==a?a:null===(i=o.message.mentionedUsers)||void 0===i?void 0:i.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),yt=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:"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:r,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return d(n,t),n}(E),gt=function(e){function t(t,n,r){var a,i,s,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new M(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i: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),_t=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:"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),Tt=function(e){function t(t,n,r){var a,i,s,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new C(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null!==(i=null===(a=r.old_values)||void 0===a?void 0:a.mention_type)&&void 0!==i?i: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),Ut=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 It=function(e){function t(t,n,r){var a=e.call(this,t,"DELM",r)||this;return a.channelUrl=r.channel_url,a.channelType=r.channel_type,a.messageId=Number(r.msg_id),a}return d(t,e),t}(U),wt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},s}return d(t,e),t}(f),Et=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),Mt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(a,"/reactions"),s.params={reaction:i},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(u({},n)),r}return d(t,e),t}(m),St=function(e){function t(t){var n=t.channelType,r=t.channelUrl,a=t.messageId,i=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(a),"/translation"),s.params={target_langs:i},s}return d(t,e),t}(f),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new M(t,n),r}return d(t,e),t}(m),At=function(e){function l(n,r){var i,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=w.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!==(i=r.name)&&void 0!==i?i:"",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 a(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(l,e),l.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:a.payloadify(t.creator),created_at:t.createdAt/1e3}))},l.prototype.isGroupChannel=function(){return this.channelType===w.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===w.OPEN},Object.defineProperty(l.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),l.prototype._upsertCachedMetaData=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})}))},l.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,a=new St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(a)];case 1:return i=s.sent(),[2,i.as(Ct).message]}}))}))},l.prototype.sendFileMessage=function(e){return e=u(u({},me),e),Q(ve(e)).throw(_.invalidParameters),this._sendFileMessage(e)},l.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Date.now()),void 0===n&&(n=null);var a=T.of(this._iid).dispatcher,i=B.of(this._iid).fileMessageQueue,s=n,o=new W;return s||(s=this._generateRequestId(),z(2).then((function(){var n=r._createPendingFileMessage(e,s,t);a.dispatch(new x({messages:[n],source:G.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,n)]}))}))}))})).catch((function(e){throw e}))),i.request(this,s,e).then((function(e){a.dispatch(new x({messages:[e],source:G.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(n){if(j(n))throw n;z(2).then((function(){var i=r._createPendingFileMessage(e,s,t);r._markMessageAsFailed(i,n),a.dispatch(new x({messages:[i],source:i.sendingStatus===N.PENDING?G.REQUEST_RESEND_MESSAGE:G.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(r,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(n,i)]}))}))}))})).catch((function(e){throw e}))})),o},l.prototype._autoResendFileMessage=function(e){Q(e instanceof C).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.createdAt,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},l.prototype.sendFileMessages=function(e){var t,n;Q(e.every((function(e){return ve(u(u({},me),e))}))).throw(_.invalidParameters);var r=new W;try{for(var a=k(e),i=a.next();!i.done;i=a.next()){var s=i.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{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r},l.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,a;return y(this,(function(i){return Q(e instanceof C&&t instanceof Blob).throw(_.invalidParameters),r=new ne,a=null!==(n=e.messageParams)&&void 0!==n?n:function(e,t){return void 0===t&&(t=null),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:t,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).onFailed((function(e){return r.reject(e)})).onSucceeded((function(e){return r.resolve(e)})),[2,r.promise]}))}))},l.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,a,i,s,o,c;return y(this,(function(l){switch(l.label){case 0:return n=u(u({},Ee),n),Q(t("number",e)&&function(e){return Ue(e)}(n)).throw(_.invalidParameters),r=T.of(this._iid),a=r.dispatcher,i=r.requestQueue,s=new _t(u({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,i.send(s)];case 1:return o=l.sent(),c=o.as(Tt).message,a.dispatch(new x({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(t("string",e)).throw(_.invalidParameters),B.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.prototype.copyFileMessage=function(e,t){var n,r;return v(this,void 0,void 0,(function(){var a,i;return y(this,(function(o){return Q(e instanceof l&&t instanceof C&&e.url===t.channelUrl).throw(_.invalidParameters),a=new ne,i=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}),e._sendFileMessage(i).onSucceeded((function(e){return a.resolve(e)})).onFailed((function(e){return a.reject(e)})),[2,a.promise]}))}))},l.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 Q(e instanceof re).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Ut({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]}}))}))},l.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,a,i;return y(this,(function(s){switch(s.label){case 0:return Q(e instanceof ae&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,a=new wt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(a)];case 1:return i=s.sent(),[2,i.as(Et).reactionEvent]}}))}))},l.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,a,i;return y(this,(function(s){switch(s.label){case 0:return Q(e instanceof ae&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,a=new Mt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(a)];case 1:return i=s.sent(),[2,i.as(bt).reactionEvent]}}))}))},l.prototype._updateMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var a,i,s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return a=T.of(this._iid),i=a.dispatcher,s=a.requestQueue,o=new yt({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(gt).message,i.dispatch(new x({messages:[c],source:G.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(a){return Q(e instanceof re&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new i({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return y(this,(function(a){return Q(e instanceof re&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new i({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(e instanceof re&&e.messageId>0&&t.every((function(e){return e instanceof i}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return Q(e instanceof re&&e.messageId>0&&t.every((function(e){return e instanceof i}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var a,i,s,o;return y(this,(function(u){switch(u.label){case 0:return Q(n(ye,e)&&t("string",r)).throw(_.invalidParameters),a=T.of(this._iid),i=a.sdkState,s=a.requestQueue,o=new ht({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},l.prototype.reportUser=function(e,r,i){return v(this,void 0,void 0,(function(){var s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return Q(e instanceof a&&n(ye,r)&&t("string",i)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new pt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:i}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},l.prototype.reportMessage=function(e,r,a){return v(this,void 0,void 0,(function(){var i,s,o,u;return y(this,(function(c){switch(c.label){case 0:return Q(e instanceof re&&n(ye,r)&&t("string",a)).throw(_.invalidParameters),i=T.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new ft({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:a}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},l}(K);export{qe as B,It as D,ie as F,Pe as M,Se as O,ye as R,$e as U,At as a,_e as b,ge as c,de as d,fe as e,pe as f,Ge as g,dt as h,he as i,ct as j,ot as k,rt as l,it as m,gt as n,Tt as o,vt as p,ce as q,se as r,ue as s,oe as t,Te as u,le as v,Ue as w,Ie as x,we as y}; diff --git a/groupChannel.d.ts b/groupChannel.d.ts index 70237d1..01e821a 100644 --- a/groupChannel.d.ts +++ b/groupChannel.d.ts @@ -5,6 +5,7 @@ export { GroupChannelChangeLogsParams, GroupChannelCollection, GroupChannelCollectionEventHandler, + GroupChannelCollectionParams, GroupChannelCountParams, GroupChannelCreateParams, GroupChannelEventContext, @@ -14,6 +15,7 @@ export { GroupChannelHideParams, GroupChannelListOrder, GroupChannelListQuery, + GroupChannelListQueryParams, GroupChannelModule, GroupChannelSearchField, GroupChannelSearchFilter, @@ -40,6 +42,7 @@ export { PublicChannelFilter, PublicGroupChannelListOrder, PublicGroupChannelListQuery, + PublicGroupChannelListQueryParams, QueryType, ReadStatus, SendbirdGroupChat, diff --git a/groupChannel.js b/groupChannel.js index 02e0463..6d4eccb 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,H as t,R as n,e as r,g as s,J as i,U as a,I as o,aw as c,p as l,m as h,b as d,c as _,o as f,l as p,a as m,i as g,N as y,ax as E,$ as C,ay as N,az as b,aA as M,a5 as S,Q as A,A as T,d as U,f as I,h as w,aB as D,aC as L,aD as R,aE as O,ae as k,W as F,aF as P,B as x,S as H,s as V,V as q,X as B,Y as K,am as j,t as z,a6 as Q,aG as W,u as Y,a0 as J,aH as X,F as Z,al as $,E as ee,a2 as te,a3 as ne,Z as re,T as se,ab as ie,aI as ae,aJ as oe,aK as ue,ac as ce,a7 as le,aL as he,a8 as de,aa as _e,aM as fe,aN as pe,an as me,aO as ve,aP as ge,n as ye,aQ as Ee}from"./__bundle-e580e568.js";export{a6 as MessageEventSource}from"./__bundle-e580e568.js";import{N as Ce,G as Ne,g as be,r as Me,D as Se,k as Ae,j as Te,s as Ue,U as Ie,h as we,i as De,t as Le,u as Re,A as Oe,o as ke,m as Fe,n as Pe,S as xe,p as He,v as Ve,w as Ge}from"./__bundle-c65b6359.js";export{G as GroupChannelListOrder,u as MessageFilter,v as PublicGroupChannelListOrder}from"./__bundle-c65b6359.js";import{b as qe,U as Be,g as Ke,h as je,j as ze,k as Qe,l as We,m as Ye,D as Je,n as Xe,o as Ze,p as $e,q as et,v as tt,r as nt,t as rt,u as st,w as it,x as at,y as ot,a as ut}from"./__bundle-fecd47ae.js";import{C as ct,a as lt,O as ht,M as dt,T as _t,R as ft,U as pt,A as mt,B as vt}from"./__bundle-d77a472f.js";var gt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited"}(gt||(gt={}));var yt,Et,Ct,Nt,bt,Mt,St,At,Tt=function(i){function a(e,r){var s=i.call(this,e,r)||this;return s.state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=t(gt,r.state)?r.state:null,s.role=t(n,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(s.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(s.isBlockingMe=r.is_blocking_me),s}return e(a,i),a.payloadify=function(e){return e?r(s(s({},i.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},a}(qe),Ut=function(t){function n(e,n){var r,s,o=this;return(o=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(s=n.channel_type)&&void 0!==s?s:i.GROUP,o.reader=new a(o._iid,n.user),o.readAt=n.ts,o}return e(n,t),n}(o);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(yt||(yt={})),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"}(Et||(Et={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ct||(Ct={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Nt||(Nt={})),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"}(bt||(bt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Mt||(Mt={})),function(e){e.AND="AND",e.OR="OR"}(St||(St={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(At||(At={}));var It,wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter="",this.channelNameContainsFilter="",this.myMemberStateFilter=Et.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ct.ALL,this.publicChannelFilter=yt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Nt.ALL,this.hiddenChannelFilter=bt.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=St.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 At.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case At.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 St.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case St.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(!c(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 h=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Et.JOINED:if("joined"!==e.myMemberState)return!1;break;case Et.INVITED:if("invited"!==e.myMemberState)return!1;break;case Et.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Et.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1;break;case Et.ALL:if("none"===e.myMemberState)return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case bt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case bt.HIDDEN:if(!e.isHidden)return!1;break;case bt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case bt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Nt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case yt.PUBLIC:if(!e.isPublic)return!1;break;case yt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ct.SUPER:if(!e.isSuper)return!1;break;case Ct.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Dt=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(Ce):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),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return Gn.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return l([],h(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.get=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._channels.set(e,n),[2,n];r.label=2;case 2:return[2,null];case 3:return[2,this._channels.get(e)]}}))}))},n.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?Me:n,s=e.backward,i=void 0!==s&&s,a=e.filter,o=void 0===a?new wt:a,u=e.order,c=void 0===u?Ne.LATEST_LAST_MESSAGE:u;return d(this,void 0,void 0,(function(){var e,n,s,a,u=this;return _(this,(function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=be(c),n={where:function(e){if(t)switch(c){case Ne.CHANNEL_NAME_ALPHABETICAL:if(!i&&e.name.localeCompare(t)<0||i&&e.name.localeCompare(t)>0)return!1;break;case Ne.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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=l([],h(this._channels.keys()),!1)),d(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=f(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),l.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(o),Lt={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},Rt=function(e){return p("string",e.invitedUserIds,!0)&&m("string",e.channelUrl,!0)&&m("string",e.coverUrl,!0)&&(g(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)&&p("string",e.operatorUserIds,!0)&&m("number",e.messageSurvivalSeconds,!0)},Ot={customTypes:null,includeEmpty:!1,includeFrozen:!0},kt=function(e){return p("string",e.customTypes,!0)&&m("boolean",e.includeEmpty)&&m("boolean",e.includeFrozen)},Ft={myMemberStateFilter:Et.ALL},Pt=function(e){return t(Et,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"}(It||(It={}));var xt,Ht={keys:[]},Vt={channelCustomTypesFilter:null,superChannelFilter:Ct.ALL},Gt={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.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"}(xt||(xt={}));var qt=function(e){return e.startsWith("EVENT_")||e===xt.SYNC_CHANNEL_BACKGROUND||e===xt.SYNC_CHANNEL_CHANGELOGS},Bt=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}(C),Kt=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}(C),jt=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 d(i,void 0,void 0,(function(){var s,i,a,o,u=this;return _(this,(function(c){switch(c.label){case 0:return e instanceof Bt?(s=e.channels,o=e.source,i=s.filter((function(e){return e instanceof Kr})),[4,t.upsert(i)]):[3,2];case 1:return c.sent(),this._broadcastUpdateEvent(i,o),[3,7];case 2:return e instanceof Kt?(a=e.channelUrls,o=e.source,[4,t.remove(a)]):[3,5];case 3:return c.sent(),[4,N((function(){return d(u,void 0,void 0,(function(){var e,t,s,i,o,u;return _(this,(function(c){switch(c.label){case 0:c.trys.push([0,6,7,8]),e=f(a),t=e.next(),c.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return c.sent(),[4,r.removeMessagesOfChannel(s)];case 3:c.sent(),c.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=c.sent(),o={error:i},[3,8];case 7:try{t&&!t.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))}))];case 4:return c.sent(),this._broadcastRemoveEvent(a,o),[3,7];case 5:return e instanceof Se?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:c.sent(),c.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(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=f(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}(),zt=function(){function e(e){var t=e.messageCache,n=e.unsentMessageCache,r=e.dispatcher,s=e.logger,i=this;this._observers=new Map,this._logger=null,this._logger=s,r.on((function(e){return d(i,void 0,void 0,(function(){var r,s,i,a,o,u,c=this;return _(this,(function(l){switch(l.label){case 0:return e instanceof S?(r=e.messages,u=e.source,s=r.filter((function(e){return e.messageId>0})),i=r.filter((function(e){return 0===e.messageId})),s.length>0?[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.upsert(s)];case 1:return e.sent(),[4,n.remove(s.map((function(e){return e instanceof A?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:l.sent(),this._broadcastUpdateEvent(s,u),l.label=2;case 2:return i.length>0?[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:l.sent(),this._broadcastUpdateEvent(i,u),l.label=4;case 4:return[3,9];case 5:return e instanceof M?(a=e.messageIds,u=e.source,[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return l.sent(),this._broadcastRemoveEvent(a,u),[3,9];case 7:return e instanceof b?(o=e.reqId,u=e.source,[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:l.sent(),this._broadcastRemoveUnsentEvent(o,u),l.label=9;case 9:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(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=f(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=f(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}(),Qt=function(t){function n(e){var n=e.userId,i=e.ts,a=e.token,o=e.filter,u=t.call(this)||this,c=s(s({},Ot),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=T.GET,u.path="".concat(U,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(I),Wt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new Kr(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(w),Yt=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=T.GET,s.path="".concat(r?D:L,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(I),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new Kr(e,n),r}return e(n,t),n}(w),Xt=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,f=e.channelNameContainsFilter,p=e.channelUrlsFilter,m=e.customTypesFilter,v=e.customTypeStartsWithFilter,g=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,E=e.metadataKey,C=e.metadataValues,N=e.metadataValueStartsWith,b=e.includeFrozen,M=e.includeMetaData,S=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=T.GET,n.path="".concat(U,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:_,name_contains:f,channel_urls:p,custom_types:m,custom_type_startswith:v,hidden_mode:g,metadata_order_key:y,metadata_key:E,metadata_values:C,metadata_value_startswith:N,show_frozen:b,show_metadata:M}),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}(I),Zt=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 Kr(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(w),$t=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Et.ALL},s}return e(n,t),n}(I),en=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}(w),tn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(I),nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[It.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[It.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[It.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[It.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[It.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[It.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[It.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[It.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[It.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[It.SUPER_INVITATION_COUNT]),"number"==typeof n[It.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[It.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[It.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[It.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[It.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(w),rn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=T.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(I),sn=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}(w),an=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=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ct.ALL,custom_types:i},s}return e(n,t),n}(I),on=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}(w),un=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=T.GET,i.path="".concat(R,"/count"),i.params={channel_url:n,status:ln(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(I),cn=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}(w),ln=function(e){if(e){var t=[];e.forEach((function(e){switch(e){case E.PENDING:t.push(O.PENDING);break;case E.SENT:t.push(O.IN_QUEUE),t.push(O.SENT);break;case E.CANCELED:t.push(O.CANCELED);break;case E.FAILED:t.push(O.FAILED)}}))}},hn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,d=e.isBroadcast,_=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(n=t.call(this)||this).method=T.POST,n.path=L,n.params=r({user_ids:l([s],h(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:d,is_exclusive:f,is_public:_,is_discoverable:p,strict:m,is_ephemeral:v,access_code:g,name:y,data:E,custom_type:C,operator_ids:M,message_survival_seconds:N}),n}return e(n,t),n}(I),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(w),_n=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=T.PUT,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var fn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(I),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),mn=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,l=i.users,h=void 0===l?null:l;return s.memberCount=o,s.joinedMemberCount=c,s.members=Array.isArray(h)?h.map((function(t){return new Tt(e,t)})):[new Tt(e,r.data)],s}return e(n,t),n}(ct),vn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(I);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(w);var gn=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;return s.memberCount=o,s.joinedMemberCount=c,s.member=new Tt(s._iid,r.data),s}return e(n,t),n}(ct),yn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=T.POST,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(I),En=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),Cn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,_=i.invitees,f=void 0===_?[]:_;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitees=f.map((function(t){return new Tt(e,t)})),s}return e(n,t),n}(ct),Nn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(I),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.channel.myMemberState=gt.NONE,r}return e(n,t),n}(w),Mn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,_=i.invitee,f=void 0===_?null:_;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitee=f?new Tt(e,f):null,s}return e(n,t),n}(ct),Sn=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}(k),An=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new Ut(e,r),s}return e(n,t),n}(F),Tn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=T.PUT,i.path="".concat(L,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var Un,In=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}(F),wn=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=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(I),Dn=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}(w),Ln=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}(F),Rn=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}(k),On=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(F),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}(k),Fn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(F),Pn=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}(k),xn=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,_,f,p,m,v,g,y,E,C,N,b=this;return(b=n.call(this,e,t)||this).includeEmpty=!1,b.includeFrozen=!0,b.includeMetaData=!0,b.channelUrlsFilter=null,b.customTypesFilter=null,b.customTypeStartsWithFilter=null,b.nicknameContainsFilter="",b.channelNameContainsFilter="",b.myMemberStateFilter=Et.ALL,b.unreadChannelFilter=Nt.ALL,b.superChannelFilter=Ct.ALL,b.publicChannelFilter=yt.ALL,b.hiddenChannelFilter=bt.UNHIDDEN,b.searchFilter={fields:[],query:null},b.userIdsFilter={userIds:[],includeMode:!0,queryType:St.AND},b.metadataKey=null,b.metadataValues=null,b.metadataOrderKeyFilter=null,b.metadataValueStartsWith=null,b.order=Ne.LATEST_LAST_MESSAGE,b.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,b.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,b.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,b.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,b.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,b.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",b.nicknameContainsFilter=null!==(c=t.nicknameContainsFilter)&&void 0!==c?c:"",b.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:"",b.myMemberStateFilter=null!==(h=t.myMemberStateFilter)&&void 0!==h?h:Et.ALL,b.unreadChannelFilter=null!==(d=t.unreadChannelFilter)&&void 0!==d?d:Nt.ALL,b.superChannelFilter=null!==(_=t.superChannelFilter)&&void 0!==_?_:Ct.ALL,b.publicChannelFilter=null!==(f=t.publicChannelFilter)&&void 0!==f?f:yt.ALL,b.hiddenChannelFilter=null!==(p=t.hiddenChannelFilter)&&void 0!==p?p:bt.UNHIDDEN,b.searchFilter=null!==(m=t.searchFilter)&&void 0!==m?m:{fields:[],query:null},b.userIdsFilter=null!==(v=t.userIdsFilter)&&void 0!==v?v:{userIds:[],includeMode:!0,queryType:St.AND},b.metadataKey=null!==(g=t.metadataKey)&&void 0!==g?g:null,b.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,b.metadataOrderKeyFilter=null!==(E=t.metadataOrderKeyFilter)&&void 0!==E?E:null,b.metadataValueStartsWith=null!==(C=t.metadataValueStartsWith)&&void 0!==C?C:null,b.order=null!==(N=t.order)&&void 0!==N?N:Ne.LATEST_LAST_MESSAGE,b}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)&&m("boolean",this.includeFrozen)&&m("boolean",this.includeMetaData)&&m("string",this.channelNameContainsFilter)&&p("string",this.channelUrlsFilter,!0)&&p("string",this.customTypesFilter,!0)&&m("string",this.customTypeStartsWithFilter)&&m("string",this.nicknameContainsFilter)&&t(Et,this.myMemberStateFilter)&&t(Ct,this.superChannelFilter)&&t(yt,this.publicChannelFilter)&&t(Nt,this.unreadChannelFilter)&&t(bt,this.hiddenChannelFilter)&&p(At,this.searchFilter.fields)&&m("string",this.searchFilter.query,!0)&&p("string",this.userIdsFilter.userIds)&&m("boolean",this.userIdsFilter.includeMode)&&t(St,this.userIdsFilter.queryType)&&t(Ne,this.order)&&m("string",this.metadataOrderKeyFilter,!0)&&m("string",this.metadataKey,!0)&&p("string",this.metadataValues,!0)&&m("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return P(this)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Gn.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 H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),Hn=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||U.unreadMentionCount>0)&&(U._updateUnreadCount(0,0),this._dispatcher.dispatch(new Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}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!==U.unreadMessageCount&&0!==U.unreadMentionCount||(this._dispatcher.dispatch(new Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}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 Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),nn.label=12;case 12:return[3,71];case 13:return I=e.as(In),Z=I.channelUrl,w=I.deliveredStateUpdate,D=void 0===w?{}:w,L=this._groupChannelCache.isCachedInMemory(Z),[4,this.getChannel(Z,!0)];case 14:if(R=nn.sent(),L)for(O in D)R._updateUndeliveredMemberState(O,D[O]);return this._dispatcher.dispatch(new Bt({channels:[R],source:xt.EVENT_CHANNEL_DELIVERED})),Object.keys(D).some((function(e){return e!==tn._sdkState.userId}))&&z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(R)}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,71];case 15:return k=e.as(ft),Z=k.channelUrl,F=k.channelType,P=k.event,F!==i.GROUP?[3,18]:[4,this.getChannel(Z,!0)];case 16:return x=nn.sent(),[4,this.getMessageFromCache(P.messageId)];case 17:(G=nn.sent())&&(G.applyReactionEvent(P),this._dispatcher.dispatch(new S({messages:[G],source:Q.EVENT_MESSAGE_REACTION_UPDATED}))),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(x,P)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),nn.label=18;case 18:return[3,71];case 19:return(H=e.as(_t).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(H.channelUrl,!0)];case 20:return V=nn.sent(),[4,this.getMessageFromCache(H.targetMessageId)];case 21:(G=nn.sent())&&(G.applyThreadInfoUpdateEvent(H),this._dispatcher.dispatch(new S({messages:[G],source:Q.EVENT_MESSAGE_THREADINFO_UPDATED}))),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(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]}))}))})),nn.label=22;case 22:return[3,71];case 23:B=e.as(dt).groupChannelMemberCounts,K=[],nn.label=24;case 24:nn.trys.push([24,29,30,31]),Y=f(B),J=Y.next(),nn.label=25;case 25:return J.done?[3,28]:(X=J.value,Z=X.channelUrl,Ue=X.memberCount,Le=X.joinedMemberCount,$=X.updatedAt,[4,this.getChannelFromCache(Z)]);case 26:(ee=nn.sent())&&ee._setLatestMemberCount(Ue,Le,$)&&K.push(ee),nn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=nn.sent(),Qt={error:te},[3,31];case 30:try{J&&!J.done&&(Wt=Y.return)&&Wt.call(Y)}finally{if(Qt)throw Qt.error}return[7];case 31:return K.length>0&&(this._dispatcher.dispatch(new Bt({channels:K,source:xt.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(K)}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,71];case 32:if(!(ne=e.as(ct).event).isGroupChannelEvent)return[3,69];switch(ne.category){case lt.CHANNEL_JOIN:return[3,33];case lt.CHANNEL_LEAVE:return[3,35];case lt.CHANNEL_OPERATOR_UPDATE:return[3,39];case lt.CHANNEL_INVITE:return[3,41];case lt.CHANNEL_DECLINE_INVITE:return[3,43];case lt.TYPING_START:case lt.TYPING_END:return[3,45];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,47];case lt.USER_CHANNEL_BAN:return[3,49];case lt.USER_CHANNEL_UNBAN:return[3,53];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,55];case lt.CHANNEL_HIDE:return[3,57];case lt.CHANNEL_UNHIDE:return[3,59];case lt.CHANNEL_DELETED:return[3,61];case lt.CHANNEL_PROP_CHANGED:return[3,63];case lt.CHANNEL_META_DATA_CHANGED:return[3,65];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,67]}return[3,69];case 33:return[4,this.getChannel(ne.channelUrl,!0)];case 34:return re=nn.sent(),se=e.as(mn),ie=se.memberCount,ae=se.joinedMemberCount,oe=se.members,ue=!1,oe.forEach((function(e){re.isExclusive||re.isSuper||re.isBroadcast?ue=ue||re._setLatestMemberCount(ie,ae,ne.ts):(e.state=gt.JOINED,re.addMember(e,ne.ts),tn._updateJoinedMemberCount(re)),e.userId===tn._sdkState.userId&&(re.myMemberState=gt.JOINED)})),this._dispatcher.dispatch(new Bt({channels:[re],source:xt.EVENT_CHANNEL_JOINED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=f(oe),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(re,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}re.isBroadcast&&ue&&e.onChannelMemberCountChanged([re])})),[2]}))}))})),[3,69];case 35:return(tt=this._leftChannels.get(ne.channelUrl))?(le=tt.channel,[3,38]):[3,36];case 36:return[4,this.getChannel(ne.channelUrl,!0)];case 37:le=nn.sent(),nn.label=38;case 38:return ce=le,he=e.as(gn),Ue=he.memberCount,Le=he.joinedMemberCount,de=he.member,_e=!1,ce.isExclusive||ce.isSuper||ce.isBroadcast?_e=ce._setLatestMemberCount(Ue,Le,ne.ts):(ce.removeMember(de),this._updateJoinedMemberCount(ce)),de.userId===this._sdkState.userId?ce.isPublic?(ce.myMemberState=gt.NONE,ce.invitedAt=0,ce.joinedAt=0,ce._updateUnreadCount(0,0),this._dispatcher.dispatch(new Bt({channels:[ce],source:xt.EVENT_CHANNEL_LEFT}))):(this._markAsLeave(ce),this._dispatcher.dispatch(new Kt({channelUrls:[ce.url],source:xt.EVENT_CHANNEL_LEFT}))):this._dispatcher.dispatch(new Bt({channels:[ce],source:xt.EVENT_CHANNEL_LEFT})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ce,de),ce.isBroadcast&&_e&&e.onChannelMemberCountChanged([ce])})),[2]}))}))})),[3,69];case 39:return[4,this.getChannel(ne.channelUrl,!0)];case 40:fe=nn.sent(),pe=e.as(ht).operators,me=pe.map((function(e){return e.userId}));try{for(ve=f(fe.members),ge=ve.next();!ge.done;ge=ve.next())(et=ge.value).role=me.includes(et.userId)?n.OPERATOR:n.NONE}catch(e){Yt={error:e}}finally{try{ge&&!ge.done&&(Jt=ve.return)&&Jt.call(ve)}finally{if(Yt)throw Yt.error}}return fe.myRole=me.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new Bt({channels:[fe],source:xt.EVENT_CHANNEL_OPERATOR_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(fe,pe)})),[2]}))}))})),[3,69];case 41:return[4,this.getChannel(ne.channelUrl,!0)];case 42:ye=nn.sent(),Ee=e.as(Cn),Ue=Ee.memberCount,Le=Ee.joinedMemberCount,Ce=Ee.inviter,(Ne=Ee.invitees).forEach((function(e){return e.state=gt.INVITED}));try{for(be=f(Ne),Me=be.next();!Me.done;Me=be.next())Se=Me.value,ye.isExclusive||ye.isSuper||ye.isBroadcast?ye._setLatestMemberCount(Ue,Le,ne.ts):ye.addMember(Se,ne.ts),this._sdkState.userId===Se.userId&&(ye.hiddenState=Vr.UNHIDDEN,ye.myMemberState!==gt.JOINED&&(ye.myMemberState=gt.INVITED),ye.invitedAt=ne.ts)}catch(e){Xt={error:e}}finally{try{Me&&!Me.done&&(Zt=be.return)&&Zt.call(be)}finally{if(Xt)throw Xt.error}}return this._dispatcher.dispatch(new Bt({channels:[ye],source:xt.EVENT_CHANNEL_INVITED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ye,Ce,Ne)})),[2]}))}))})),[3,69];case 43:return[4,this.getChannel(ne.channelUrl,!0)];case 44:return Ae=nn.sent(),Te=e.as(Mn),Ue=Te.memberCount,Le=Te.joinedMemberCount,Re=Te.inviter,Oe=Te.invitee,Ae.isExclusive||Ae.isSuper||Ae.isBroadcast?Ae._setLatestMemberCount(Ue,Le,ne.ts):Ae.removeMember(Oe),this._sdkState.userId===Oe.userId?(Ae.invitedAt=0,Ae.myMemberState=gt.NONE,Ae.isPublic?this._dispatcher.dispatch(new Bt({channels:[Ae],source:xt.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Kt({channelUrls:[Ae.url],source:xt.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Bt({channels:[Ae],source:xt.EVENT_CHANNEL_DECLINED_INVITE})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Ae,Re,Oe)})),[2]}))}))})),[3,69];case 45:return[4,this.getChannel(ne.channelUrl,!0)];case 46:return ke=nn.sent(),Fe=ne.category===lt.TYPING_START,Pe=e.as(Fe?On:Fn).user,ke._updateTypingStatus(Pe,Fe?ne.ts:0),this._dispatcher.dispatch(new Bt({channels:[ke],source:xt.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(ke)})),[2]}))}))})),[3,69];case 47:return[4,this.getChannel(ne.channelUrl,!0)];case 48:xe=nn.sent(),He=ne.category===lt.USER_CHANNEL_MUTE,(Ve=e.as(He?We:Ye).user).userId===this._sdkState.userId&&(xe.myMutedState=He?Hr.MUTED:Hr.UNMUTED);try{for(Ge=f(xe.members),qe=Ge.next();!qe.done;qe=Ge.next())if((et=qe.value).userId===Ve.userId){et.isMuted=He;break}}catch(e){$t={error:e}}finally{try{qe&&!qe.done&&(en=Ge.return)&&en.call(Ge)}finally{if($t)throw $t.error}}return this._dispatcher.dispatch(new Bt({channels:[xe],source:He?xt.EVENT_CHANNEL_MUTED:xt.EVENT_CHANNEL_UNMUTED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){He?e.onUserMuted(xe,Ve):e.onUserUnmuted(xe,Ve)})),[2]}))}))})),[3,69];case 49:return(tt=this._leftChannels.get(ne.channelUrl))?(rt=tt.channel,[3,52]):[3,50];case 50:return[4,this.getChannel(ne.channelUrl,!0)];case 51:rt=nn.sent(),nn.label=52;case 52:return nt=rt,this._markAsLeave(nt),st=e.as(Qe).user,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(nt,st)})),[2]}))}))})),[3,69];case 53:return[4,this.getChannel(ne.channelUrl,!0)];case 54:return it=nn.sent(),at=e.as(ze).user,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(it,at)})),[2]}))}))})),[3,69];case 55:return[4,this.getChannel(ne.channelUrl,!0)];case 56:return ot=nn.sent(),ut=e.as(je).freeze,ot.isFrozen=ut,this._dispatcher.dispatch(new Bt({channels:[ot],source:ut?xt.EVENT_CHANNEL_FROZEN:xt.EVENT_CHANNEL_UNFROZEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){ut?e.onChannelFrozen(ot):e.onChannelUnfrozen(ot)})),[2]}))}))})),[3,69];case 57:return[4,this.getChannel(ne.channelUrl,!0)];case 58:return vt=nn.sent(),yt=e.as(Ln),Et=yt.allowAutoUnhide,Ct=yt.hidePreviousMessages,Nt=yt.messageOffsetTimestamp,null!==Et&&(vt.hiddenState=Et?Vr.HIDDEN_ALLOW_AUTO_UNHIDE:Vr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ct&&Ct&&vt._updateUnreadCount(0,0),null!==Nt&&(vt.messageOffsetTimestamp=Nt),this._dispatcher.dispatch(new Bt({channels:[vt],source:xt.EVENT_CHANNEL_HIDDEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(vt)})),[2]}))}))})),[3,69];case 59:return[4,this.getChannel(ne.channelUrl,!0)];case 60:return(bt=nn.sent()).hiddenState=Vr.UNHIDDEN,this._dispatcher.dispatch(new Bt({channels:[bt],source:xt.EVENT_CHANNEL_UNHIDDEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(bt)})),[2]}))}))})),[3,69];case 61:return[4,this.getChannel(ne.channelUrl,!0)];case 62:return Mt=nn.sent(),this._dispatcher.dispatch(new Kt({channelUrls:[ne.channelUrl],source:xt.EVENT_CHANNEL_DELETED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Mt.url,Mt.channelType)})),[2]}))}))})),[3,69];case 63:return[4,this.getChannelWithoutCache(ne.channelUrl,!0)];case 64:return St=nn.sent(),this._dispatcher.dispatch(new Bt({channels:[St],source:xt.EVENT_CHANNEL_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(St)})),[2]}))}))})),[3,69];case 65:return[4,this.getChannel(ne.channelUrl,!0)];case 66:return At=nn.sent(),Tt=e.as(Ke),Ut=Tt.created,It=Tt.updated,wt=Tt.deleted,Ut&&At._upsertCachedMetaData(Ut,ne.ts),It&&At._upsertCachedMetaData(It,ne.ts),wt&&At._removeFromCachedMetaData(wt,ne.ts),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ut&&e.onMetaDataCreated(At,Ut),It&&e.onMetaDataUpdated(At,It),wt&&e.onMetaDataDeleted(At,wt)})),[2]}))}))})),[3,69];case 67:return[4,this.getChannel(ne.channelUrl,!0)];case 68:return Dt=nn.sent(),Lt=e.as(Be),Rt=Lt.created,Ot=Lt.updated,kt=Lt.deleted,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Rt&&e.onMetaCounterCreated(Dt,Rt),Ot&&e.onMetaCounterUpdated(Dt,Ot),kt&&e.onMetaCounterDeleted(Dt,kt)})),[2]}))}))})),[3,69];case 69:return[3,71];case 70:switch((Ft=e.as(Ie).event).category){case we.USER_BLOCK:Pt=De.getDataAsUserBlockEvent(this._iid,Ft),Vt=Pt.blocker,Gt=Pt.blockee,this._groupChannelCache.block(Vt.userId,Gt.userId);break;case we.USER_UNBLOCK:Ht=De.getDataAsUserBlockEvent(this._iid,Ft),Vt=Ht.blocker,Gt=Ht.blockee,this._groupChannelCache.unblock(Vt.userId,Gt.userId)}return[3,71];case 71:return[3,73];case 72:if(qt=nn.sent(),j(qt))throw qt;return[3,73];case 73: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===gt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),d(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:Y(m("string",e)).throw(H.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),d(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(m("string",e)).throw(H.invalidParameters),n=new Yt({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(Jt).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case xr.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case xr.UNREAD_MENTION_COUNT_ONLY:i=0;break;case xr.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=xt.REQUEST_CHANNEL),d(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return i=new Xt(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(Zt),u=o.channels,c=o.token,this._dispatcher.dispatch(new Bt({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return d(this,void 0,void 0,(function(){return _(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=Le),d(this,void 0,void 0,(function(){return _(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.getAllFailedMessagesFromCache=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t,sendingStatus:J.FAILED})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Hn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=xt.REQUEST_CHANNEL_CHANGELOGS),d(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=s(s({},Ot),t),Y(m("string",e)&&kt(t)).throw(H.invalidParameters),i=new Qt(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:t})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(Wt),u=o.updatedChannels,c=o.deletedChannelUrls,u.length>0&&this._dispatcher.dispatch(new Bt({channels:u,source:n})),c.length>0&&this._dispatcher.dispatch(new Kt({channelUrls:c,source:n})),[2,o]}}))}))},e.prototype.getGroupChannelCount=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=s(s({},Ft),e),Y(Pt(e)).throw(H.invalidParameters),t=new $t({userId:this._sdkState.userId,filter:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(en).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=s(s({},Ht),e),Y(function(e){return p(It,e.keys)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new tn({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return[2,a.sent().as(nn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(sn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return d(this,void 0,void 0,(function(){var n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=s(s({},Vt),e),Y(function(e){return p("string",e.channelCustomTypesFilter)&&t(Ct,e.superChannelFilter)}(e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new an({userId:r.userId,filter:e}),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(on).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),d(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=s(s({},Gt),e),Y(function(e){return m("string",e.channelUrl,!0)&&p(E,e.scheduledStatus,!0)&&t(y,e.messageTypeFilter)}(e)).throw(H.invalidParameters),n=q.of(this._iid).requestQueue,r=new un(e),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(cn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=q.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=q.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=q.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return d(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),e.isPublic||(e.accessCode=null),t=new hn(s({userId:this._sdkState.userId},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),r=n.as(dn).channel,[4,this._groupChannelCache.upsert([r])];case 2:return i.sent(),[2,r]}}))}))},e.prototype.markAsReadAll=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=Date.now(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(H.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new _n({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=f(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._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(p("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(H.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new _n({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=f(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&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return d(this,void 0,void 0,(function(){return _(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}(),qn=new Map,Bn=new Map,Kn=new Map,jn=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],X()?(qn[this._holdersKey]||(qn[this._holdersKey]=[]),Bn[this._resolversKey]||(Bn[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return d(o,void 0,void 0,(function(){var t,n;return _(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(X())return this.numLocks-qn[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return X()?Bn[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(X())return Kn[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){X()?Kn[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,$(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),X()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),d(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){return X()?[2,new Promise((function(t){for(var r={key:Z(),resolver:function(e){return t(e)},priority:e},s=Bn[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?Bn[n._resolversKey].splice(i,0,r):Bn[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=Z(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(X()){if((t=qn[this._holdersKey].indexOf(e))>=0)return qn[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=l([],h(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(X()){if(qn[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return(r=o.sent())instanceof H&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:return t.hasNext=!1,t.nextToken=0,[3,8];case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new Qn(c,(function(e){return d(r,void 0,void 0,(function(){var t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return a.sent(),u.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),[4,re.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(s=this._metadata.range)||void 0===s?void 0:s.bottom)&&void 0!==i?i:e,{prevResultSize:0,nextResultSize:100,replyType:se.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},Q.SYNC_MESSAGE_BACKGROUND)];case 2:return n=a.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[2,t]}}))}))}))}return e.of=function(t,n){if(Jn[t]||(Jn[t]={}),!Jn[t][n.url]){var r=Jn[t][n.url]=new e({_iid:t,channel:n});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)r.resume();else r.pause()}))}return Jn[t][n.url]},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,l([],h(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,l([],h(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,q.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new Hn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){var e,t,n,r;q.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(){q.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),Zn={},$n=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=q.of(this._iid).sdkState;this._metadataKey=(s=a.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var o=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(a.userId,this._channel.url);this._sync=new Qn(o,(function(){return d(r,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,re.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:se.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includePollDetails:!0},Q.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[3,8];case 5:return(s=i.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return e.of=function(t,n){if(Zn[t]||(Zn[t]={}),!Zn[t][n.url]){var r=Zn[t][n.url]=new e({_iid:t,channel:n});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)r.resume();else r.pause()}))}return Zn[t][n.url]},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=q.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),er=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=T.GET,c.path="".concat(ie(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({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!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u}),c}return e(n,t),n}(I),tr=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 ae(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 ae(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(w),nr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},rr=function(e,t,n){if(e.length>0){var r=nr(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:sr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},sr=function(e,t,n){switch(n){case Ne.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 Ne.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ne.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},ir=function(e,t){if(t instanceof A)return e.findIndex((function(e){return e instanceof A&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},ar=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};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(zn||(zn={}));var or,ur,cr,lr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;z((function(){return d(r,void 0,void 0,(function(){return _(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}(),hr=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._iid=e,this._key="mc-".concat(Z()),this.filter=null!=r?r:new Re,this._channel=n,this._syncRange=new Hn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||Le;var o=Gn.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=nr(e,a._channel);if(o>=0)switch(z((function(){return d(a,void 0,void 0,(function(){var n;return _(this,(function(r){return n=new Wn(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case xt.EVENT_CHANNEL_UPDATED:var u=!1;for(var c in a._messages){if((g=a._messages[c]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var l=parseInt(c);if(l>0){var h=a._messages.splice(0,l);a._removeMessagesFromView(h.map((function(e){return e.messageId})),Q.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),Q.EVENT_MESSAGE_OFFSET_UPDATED);break;case xt.EVENT_CHANNEL_READ:var p=[];try{for(var m=f(a._messages),v=m.next();!v.done;v=m.next()){var g=v.value;if((C=a._readReceiptMap.get(g.messageId))>0)C!==a._channel.getUnreadMemberCount(g)&&p.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}p.length>0&&a._updateMessagesToView(p,Q.EVENT_MESSAGE_READ);break;case xt.EVENT_CHANNEL_DELIVERED:p=[];try{for(var y=f(a._messages),E=y.next();!E.done;E=y.next()){var C;g=E.value;if((C=a._deliveryReceiptMap.get(g.messageId))>0)C!==a._channel.getUndeliveredMemberCount(g)&&p.push(g)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(i=y.return)&&i.call(y)}finally{if(s)throw s.error}}p.length>0&&a._updateMessagesToView(p,Q.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&z((function(){return d(a,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),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=f(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(oe(t)){if(s.length>0)switch(t){case Q.EVENT_MESSAGE_SENT_FAILED:case Q.EVENT_MESSAGE_SENT_SUCCESS:case Q.EVENT_MESSAGE_UPDATED:case Q.EVENT_MESSAGE_THREADINFO_UPDATED:case Q.EVENT_MESSAGE_REACTION_UPDATED:case Q.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case Q.EVENT_MESSAGE_SENT_PENDING:case Q.EVENT_MESSAGE_RECEIVED:case Q.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)}});var u=q.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&Xn.of(this._iid,this._channel).resume(),$n.of(this._iid,this._channel).resume(),this._prevFill=new Qn(this._key,(function(e){return d(a,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:Q.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,l([],h(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,l([],h(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 c=q.of(this._iid),p=c.dispatcher,m=c.logger;p.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)m.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 l([],h(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===J.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===J.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,l(l([],h(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,l(l([],h(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){var t=this;return e.filter((function(e){return e.createdAt>=t._channel.messageOffsetTimestamp}))},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=f(i),c=u.next();!c.done;c=u.next()){var p=c.value;if(p.messageId>0){if((y=ir(this._messages,p))<0){var m=ir(this._unsentMessages,p);m<0?a.push(p):(this._unsentMessages.splice(m,1),o.push(p));var v=ar(this._messages,p);this._messages.splice(v,0,p)}else o.push(p),this._messages[y]=p;if(this._readReceiptMap.set(p.messageId,this._channel.getUnreadMemberCount(p)),this._deliveryReceiptMap.set(p.messageId,this._channel.getUndeliveredMemberCount(p)),p.updatedAt>0){var g=this._updateChildMessagesInView(p);o.push.apply(o,l([],h(g),!1))}}else{var y;if(p instanceof A)(y=ir(this._unsentMessages,p))<0?ir(this._messages,p)<0&&(this._unsentMessages.push(p),a.push(p)):(o.push(p),this._unsentMessages[y]=p)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}oe(t)&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=f(e),o=a.next();!o.done;o=a.next()){var u,c=o.value;if(c.messageId>0)if((u=ir(this._messages,c))>=0)i.push(c),this._messages[u]=c;else{var l=ir(this._unsentMessages,c);if(l>=0){i.push(c),this._unsentMessages.splice(l,1);var h=ar(this._messages,c);this._messages.splice(h,0,c)}}else if(c instanceof A)(u=ir(this._unsentMessages,c))>=0&&(i.push(c),this._unsentMessages[u]=c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return oe(t)&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return oe(t)&&i.length>0&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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 d(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return _(this,(function(d){switch(d.label){case 0:return t=Gn.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=d.sent(),[3,3];case 2:s=[],d.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=d.sent(),[3,6];case 5:o=[],d.label=6;case 6:if(a=o,n.length>0&&a.length)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,l(l([],h(n),!1),h(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,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?Q.REQUEST_MESSAGE:o;return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(i){switch(i.label){case 0:return t=re.of(this._iid),r>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,c,f,p=this;return _(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,(i=Gn.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return o=m.sent(),[4,ue((function(){return d(p,void 0,void 0,(function(){var i,u,c,f,p,m,v,g,y,E,C,N,b,M,A,T,U,I=this;return _(this,(function(w){switch(w.label){case 0:return i=q.of(this._iid),u=i.dispatcher,c=i.requestQueue,f=new er(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:n,nextEnd:r,nextCount:o},this.filter)),[4,c.send(f)];case 1:return p=w.sent(),m=p.as(tr),v=m.isHugeGap,g=m.prevMessages,y=void 0===g?[]:g,E=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?z((function(){return d(I,void 0,void 0,(function(){return _(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=b,M=this.viewTop,A=this.viewBottom,T=Math.min.apply(Math,l([Number.MAX_SAFE_INTEGER],h(y.map((function(e){return e.createdAt}))),!1)),U=Math.max.apply(Math,l([0],h(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new S({messages:y,source:Q.SYNC_MESSAGE_FILL})),u.dispatch(new S({messages:N,source:Q.SYNC_MESSAGE_FILL})),this._syncRange.extends(T,U),MU&&this._nextFill.start(U)),[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:Q.SYNC_MESSAGE_FILL})];case 5:(c=m.sent()).length>0&&((f=this._syncRange).extends.apply(f,l([],h(c.map((function(e){return e.createdAt}))),!1)),c.length0&&((s=t._syncRange).extends.apply(s,l([],h(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,Q.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(j(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,N((function(){return d(s,void 0,void 0,(function(){var n;return _(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 i.sent(),n=Xn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,N((function(){return d(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,l([],h(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Q.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,l([],h(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Q.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,N((function(){return d(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=Xn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,N((function(){return d(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,l([],h(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Q.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,l([],h(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Q.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,Gn.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=Gn.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),dr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},_r={hidePreviousMessages:!1,allowAutoUnhide:!0},fr=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,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=T.GET,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(I),pr=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 Tt(e,t)}))),r}return e(n,t),n}(w);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(or||(or={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ur||(ur={})),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"}(cr||(cr={}));var mr=function(n){function r(e,t,r){var s,a,o,u,c=this;return(c=n.call(this,e,t,i.GROUP,r)||this).mutedMemberFilter=or.ALL,c.memberStateFilter=cr.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Mt.ALL,c.order=ur.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:or.ALL,c.memberStateFilter=null!==(a=r.memberStateFilter)&&void 0!==a?a:cr.ALL,c.nicknameStartsWithFilter=null!==(o=r.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=r.order)&&void 0!==u?u:ur.MEMBER_NICKNAME_ALPHABETICAL,c}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(or,this.mutedMemberFilter)&&t(cr,this.memberStateFilter)&&(m("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(Mt,this.operatorFilter)&&t(ur,this.order)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new fr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(pr),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(ce),vr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(I),gr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.channel.myMemberState=gt.JOINED,r}return e(n,t),n}(w),yr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,f=e.operatorUserIds,p=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:p}),n}return e(n,t),n}(I),Er=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),Cr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.DELETE,n.path="".concat(L,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(I);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(w);var Nr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.DELETE,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var br=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=T.PUT,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(I),Mr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=xr[n.count_preference],r}return e(n,t),n}(w),Sr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(I),Ar=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}(w),Tr=s(s({},et),{scheduledAt:null}),Ur=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl;return r.method=T.POST,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages"),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new B(e,n),r}return e(n,t),n}(w),wr=s(s({},nt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Dr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl;return r.method=T.POST,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages"),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return fe.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Lr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new K(e,n),r}return e(n,t),n}(w),Rr=s(s({},st),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Or=s(s({},at),{scheduledAt:null}),kr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=T.PUT,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return fe.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new K(e,n),r}return e(n,t),n}(w),Pr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=T.PUT,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new B(e,n),r}e(n,t)}(w);var xr,Hr,Vr,Gr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=T.DELETE,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(I),qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=T.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(I);!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"}(xr||(xr={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(Hr||(Hr={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Vr||(Vr={}));var Br,Kr=function(o){function u(e,r){var u,c,d,_,f,p,v,g,y,E,C,N,b,M,S,A,T,U,I=this;return(I=o.call(this,e,r)||this)._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=Vr.UNHIDDEN,I.lastMessage=null,I.messageOffsetTimestamp=0,I.messageSurvivalSeconds=-1,I.myMemberState=gt.NONE,I.myRole=n.NONE,I.myMutedState=Hr.UNMUTED,I.myLastRead=0,I.myCountPreference=xr.ALL,I.myPushTriggerOption=ke.DEFAULT,I.inviter=null,I.invitedAt=0,I.joinedAt=0,I.channelType=i.GROUP,I.isDistinct=null!==(c=r.is_distinct)&&void 0!==c&&c,I.isSuper=null!==(d=r.is_super)&&void 0!==d&&d,I.isBroadcast=null!==(_=r.is_broadcast)&&void 0!==_&&_,I.isExclusive=null!==(f=r.is_exclusive)&&void 0!==f&&f,I.isPublic=null!==(p=r.is_public)&&void 0!==p&&p,I.isDiscoverable=null!==(v=r.is_discoverable)&&void 0!==v?v:I.isPublic,I.isAccessCodeRequired=null!==(g=r.is_access_code_required)&&void 0!==g&&g,I.isPushEnabled=null!==(y=r.is_push_enabled)&&void 0!==y&&y,Array.isArray(r.members)&&(u=I.members).push.apply(u,l([],h(r.members.map((function(e){return new Tt(I._iid,e)}))),!1)),I.memberCount=null!==(E=r.member_count)&&void 0!==E?E:0,I.joinedMemberCount=null!==(C=r.joined_member_count)&&void 0!==C?C:0,I.hiddenState=t(Vr,r.hidden_state)?r.hidden_state:Vr.UNHIDDEN,I.messageOffsetTimestamp=null!==(N=r.ts_message_offset)&&void 0!==N?N:0,I.messageSurvivalSeconds=null!==(b=r.message_survival_seconds)&&void 0!==b?b:-1,I.lastMessage=r.last_message?ae(I._iid,s({channel_type:I.channelType},r.last_message)):null,r.read_receipt&&Object.keys(r.read_receipt).forEach((function(e){m("number",r.read_receipt[e])&&I._updateUnreadMemberState(e,r.read_receipt[e])})),r.delivery_receipt&&Object.keys(r.delivery_receipt).forEach((function(e){m("number",r.delivery_receipt[e])&&I._updateUndeliveredMemberState(e,r.delivery_receipt[e])})),I.myMemberState=t(gt,r.member_state)?r.member_state:gt.NONE,I.myRole=t(n,r.my_role)?r.my_role:n.NONE,t(Hr,r.is_muted)?I.myMutedState=r.is_muted:m("boolean",r.is_muted)?I.myMutedState=r.is_muted?Hr.MUTED:Hr.UNMUTED:I.myMutedState=Hr.UNMUTED,I.myCountPreference=t(xr,r.count_preference)?r.count_preference:xr.ALL,I.myPushTriggerOption=t(ke,r.push_trigger_option)?r.push_trigger_option:ke.ALL,I.myLastRead=null!==(M=r.user_last_read)&&void 0!==M?M:0,I.inviter=r.inviter?new a(I._iid,r.inviter):null,I.invitedAt=null!==(S=r.invited_at)&&void 0!==S?S:0,I.joinedAt=null!==(A=r.joined_ts)&&void 0!==A?A:0,I._updateUnreadCount(null!==(T=r.unread_message_count)&&void 0!==T?T:0,null!==(U=r.unread_mention_count)&&void 0!==U?U:0),I}return e(u,o),Object.defineProperty(u.prototype,"isHidden",{get:function(){return this.hiddenState!==Vr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=h(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(u.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=h(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}),u.payloadify=function(e){return e?r(s(s({},o.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 Tt.payloadify(e)})),last_message:pe(e.lastMessage),inviter:e.inviter?a.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},u.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===xr.ALL||this.myCountPreference===xr.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=q.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===xr.ALL||this.myCountPreference===xr.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},u.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},u.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},u.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},u.prototype.isReadMessage=function(e){var t=q.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},u.prototype.serialize=function(){var e=this;return P(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},u.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new hr(this._iid,s({channel:this},e))},u.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new mr(this._iid,this.url,e)},u.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===gt.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)}},u.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},u.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof A&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=q.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=f(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===gt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},u.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=q.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},u.prototype.refresh=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new Yt({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(Jt).channel,n.dispatch(new Bt({channels:[i],source:xt.REQUEST_CHANNEL})),[2,i]}}))}))},u.prototype.freeze=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,o.prototype.freeze.call(this)];case 1:return e.sent(),q.of(this._iid).dispatcher.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},u.prototype.unfreeze=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,o.prototype.unfreeze.call(this)];case 1:return e.sent(),q.of(this._iid).dispatcher.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},u.prototype.updateChannel=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=s(s({},dr),e),Y(function(e){return m("string",e.coverUrl,!0)&&(g(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)&&p("string",e.operatorUserIds,!0)&&m("number",e.messageSurvivalSeconds,!0)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new yr(s({channelUrl:this.url},e)),[4,r.send(i)];case 1:return a=u.sent(),o=a.as(Er).channel,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_UPDATED})),[2,o]}}))}))},u.prototype.invite=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(e.every((function(e){return e instanceof a}))).throw(H.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},u.prototype.inviteWithUserIds=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(p("string",e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new yn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(En).channel,n.dispatch(new Bt({channels:[a],source:xt.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},u.prototype.join=function(e){return void 0===e&&(e=null),d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(m("string",e)||null===e).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new fn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(pn).channel).myMemberState=gt.JOINED,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},u.prototype.leave=function(e){return void 0===e&&(e=!1),d(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new vn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},u.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(m("string",e)||null===e).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new vr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(gr).channel).myMemberState=gt.JOINED,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},u.prototype.declineInvitation=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(bn).channel).myMemberState=gt.NONE,[2,i]}}))}))},u.prototype.sendUserMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype.sendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendUserMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype._autoResendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.sendFileMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype.sendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendFileMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype._autoResendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.deleteMessage=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,o.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&q.of(this._iid).dispatcher.dispatch(new b({reqId:e.reqId,source:Q.EVENT_MESSAGE_DELETED})),[2]}}))}))},u.prototype.hide=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return e=s(s({},_r),e),Y(function(e){return m("boolean",e.hidePreviousMessages)&&m("boolean",e.allowAutoUnhide)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,i=t.requestQueue,a=new wn(s({channelUrl:this.url,userId:r.userId},e)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(Dn).messageOffsetTimestamp,this.hiddenState=e.allowAutoUnhide?Vr.HIDDEN_ALLOW_AUTO_UNHIDE:Vr.HIDDEN_PREVENT_AUTO_UNHIDE,e.hidePreviousMessages&&this._updateUnreadCount(0,0),u&&(this.messageOffsetTimestamp=u),n.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},u.prototype.unhide=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Nr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=Vr.UNHIDDEN,t.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},u.prototype.delete=function(){return d(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=q.of(this._iid).requestQueue,t=new Cr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.markAsRead=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Sn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(An).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Gn.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_READ})),[2]}}))}))},u.prototype.markAsDelivered=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Tn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.startTyping=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=q.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new Rn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.endTyping=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=q.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]}))}))},u.prototype.createScheduledUserMessage=function(e){return d(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return e=s(s({},Tr),e),Y(function(e){return tt(e)&&m("number",e.scheduledAt,!0)}(e)).throw(H.invalidParameters),t=q.of(this._iid).requestQueue,n=new Ur(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e)),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Ir).message]}}))}))},u.prototype.updateScheduledUserMessage=function(e,t){return d(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=s(s({},Or),t),Y(function(e){return ot(e)&&m("number",e.scheduledAt,!0)}(t)).throw(H.invalidParameters),n=q.of(this._iid).requestQueue,r=new Pr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t)),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(Ir).message]}}))}))},u.prototype.createScheduledFileMessage=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=s(s({},wr),e),Y(function(e){return rt(e)&&m("number",e.scheduledAt)&&(g(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(H.invalidParameters),g(e.file)?[4,this._uploadFileAndUpdateParams(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return t=new Dr(s(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth})),[4,q.of(this._iid).requestQueue.send(t)];case 3:return n=r.sent(),[2,n.as(Lr).message]}}))}))},u.prototype.updateScheduledFileMessage=function(e,t){return d(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return t=s(s({},Rr),t),Y(function(e){return it(e)&&m("number",e.scheduledAt,!0)&&(g(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})))}(t)).throw(H.invalidParameters),g(t.file)?[4,this._uploadFileAndUpdateParams(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return n=new kr(s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t),{fileUrl:t.fileUrl,requireAuth:t.requireAuth})),[4,q.of(this._iid).requestQueue.send(n)];case 3:return r=i.sent(),[2,r.as(Fr).message]}}))}))},u.prototype.cancelScheduledMessage=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Gr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,q.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.sendScheduledMessageNow=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,q.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.getMyPushTriggerOption=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(Fe).pushTriggerOption]}}))}))},u.prototype.setMyPushTriggerOption=function(e){return d(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(t(ke,e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new He({userId:r.userId,pushTriggerOption:e}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(xe).pushTriggerOption]}}))}))},u.prototype.setMyCountPreference=function(e){return d(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(t(xr,e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new br({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(Mr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},u.prototype.resetMyHistory=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Sr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Ar).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},u.prototype._uploadFileAndUpdateParams=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return g(e.file)?(t=q.of(this._iid).requestQueue,n=new ge({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(ve),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},u}(ut),jr={},zr=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadata=null,this._iid=t;var r,s=q.of(this._iid),i=s.sdkState,a=s.logger;this._metadataKey=(r=i.userId,"sendbird:".concat(r,"@groupchannel/sync.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(i.userId);this._sync=new Qn(o,(function(){return d(n,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(o){switch(o.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(o.sent(),a.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];o.label=2;case 2:return o.trys.push([2,5,,8]),[4,Gn.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:Ne.CHRONOLOGICAL},100,xt.SYNC_CHANNEL_BACKGROUND)];case 3:return t=o.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,l([],h(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,a.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return(s=o.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:o.sent(),o.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",o.label=10;case 10:return[2,e]}}))}))}))}return e.of=function(t){if(!jr[t]){var n=jr[t]=new e({_iid:t});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)n.resume();else n.pause()}))}return jr[t]},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 d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,q.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Hn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,q.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.resume=function(){var e,t;q.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(){q.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e}(),Qr={},Wr=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=q.of(this._iid).sdkState;this._metadataKey=(r=s.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var i=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(s.userId);this._sync=new Qn(i,(function(){return d(n,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,Gn.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},xt.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[3,8];case 5:return(s=i.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return e.of=function(t){if(!Qr[t]){var n=Qr[t]=new e({_iid:t});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)n.resume();else n.pause()}))}return Qr[t]},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=q.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Yr=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._iid=e,this._key="gcc-".concat(Z()),this.filter=null!=n?n:new wt,this.order=null!=r?r:Ne.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Me;var a=q.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&zr.of(e).resume(),Wr.of(e).resume(),Gn.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=f(e),c=u.next();!c.done;c=u.next()){var l=c.value,h=rr(this.channels,l,this.order),p=h.place;if(h.contains)switch(o.push(l),t){case xt.EVENT_CHANNEL_UPDATED:case xt.EVENT_MESSAGE_RECEIVED:this.channels.splice(p,1);var m=rr(this.channels,l,this.order).place;this.channels.splice(m,0,l);break;default:this.channels[p]=l}else if(p===this.channels.length){var v=zr.of(this._iid);(n||v.completed)&&(a.push(l),this.channels.push(l))}else a.push(l),this.channels.splice(p,0,l)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}qt(t)&&z((function(){return d(i,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),a.length>0&&this._handler.onChannelsAdded(e,a),o.length>0&&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=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return qt(t)&&i.length>0&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,Gn.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return d(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return[4,Gn.of(this._iid).getMyGroupChannels(this._token,s(s({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,[2,t]}}))}))},e.prototype.loadMore=function(){return d(this,void 0,void 0,(function(){var e,t=this;return _(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,N((function(){return d(t,void 0,void 0,(function(){return _(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,N((function(){return d(t,void 0,void 0,(function(){return _(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,xt.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){Gn.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Jr=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,c=e.channelNameContainsFilter,l=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,_=e.superChannelFilter,f=e.metadataOrderKeyFilter,p=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=T.GET,n.path=L,n.params=r({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:yt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:_,metadata_order_key:f,metadata_key:p,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(I),Xr=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 Kr(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(w);!function(e){e.ALL="all",e.JOINED="joined"}(Br||(Br={}));var Zr=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,_,f,p,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.nicknameContainsFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=Br.ALL,v.superChannelFilter=Ct.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=Ve.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!==(c=t.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=t.membershipFilter)&&void 0!==l?l:Br.ALL,v.superChannelFilter=null!==(h=t.superChannelFilter)&&void 0!==h?h:Ct.ALL,v.metadataKey=null!==(d=t.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(_=t.metadataValues)&&void 0!==_?_:null,v.metadataOrderKeyFilter=null!==(f=t.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(p=t.metadataValueStartsWith)&&void 0!==p?p:null,v.order=null!==(m=t.order)&&void 0!==m?m:Ve.CHRONOLOGICAL,v}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)&&m("boolean",this.includeFrozen)&&m("boolean",this.includeMetaData)&&m("string",this.channelNameContainsFilter,!0)&&p("string",this.channelUrlsFilter,!0)&&p("string",this.customTypesFilter,!0)&&m("string",this.customTypeStartsWithFilter,!0)&&t(Br,this.membershipFilter)&&t(Ct,this.superChannelFilter)&&t(Ve,this.order)&&m("string",this.metadataOrderKeyFilter,!0)&&m("string",this.metadataKey,!0)&&p("string",this.metadataValues,!0)&&m("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=q.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new Jr(s(s({},this),{token:this._token})),[4,n.send(i)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(Xr),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,r.dispatch(new Bt({channels:u,source:xt.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),$r=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=ye,e.onUserLeft=ye,e.onUserReceivedInvitation=ye,e.onUserDeclinedInvitation=ye,e.onChannelHidden=ye,e.onUnreadMemberStatusUpdated=ye,e.onUndeliveredMemberStatusUpdated=ye,e.onTypingStatusUpdated=ye,e}return e(n,t),n}(vt)),es=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,c=e.messageTypeFilter,l=e.scheduledStatus;return(n=t.call(this)||this).method=T.GET,n.path="".concat(R),n.params=r({limit:i,reverse:o,channel_url:u,order:a,status:l}),s&&(n.params.token=s),c&&(n.params.message_type_filter=c),n}return e(n,t),n}(I),ts=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 ae(e,t)})),r}return e(n,t),n}(w),ns=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)&&m("string",this.channelUrl,!0)&&(t(Ge,this.order)||null===this.order)&&m("boolean",this.reverse)&&(p(E,this.scheduledStatus)||null===this.scheduledStatus)&&t(y,this.messageTypeFilter)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new es(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(ts),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),rs=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,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new Gn(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Yr(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Zr(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ns(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(m("string",e)&&t instanceof $r).throw(H.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(m("string",e)).throw(H.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 d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(m("string",e)).throw(H.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(m("string",e)).throw(H.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t=s(s({},Ot),t),Y(m("string",e)&&kt(t)).throw(H.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t=s(s({},Ot),t),Y(m("number",e)&&kt(t)).throw(H.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Ft),e),Y(Pt(e)).throw(H.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(e){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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={}),d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,i,a){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=""),void 0===a&&(a=""),d(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=s(s({},Lt),{invitedUserIds:e,isDistinct:t,name:n,data:i,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(p("string",e)).throw(H.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return Y(m("string",e)).throw(H.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(Ee);export{xr as CountPreference,Kr as GroupChannel,Yr as GroupChannelCollection,Wn as GroupChannelEventContext,xt as GroupChannelEventSource,wt as GroupChannelFilter,$r as GroupChannelHandler,xn as GroupChannelListQuery,rs as GroupChannelModule,At as GroupChannelSearchField,bt as HiddenChannelFilter,Vr as HiddenState,Tt as Member,ur as MemberListOrder,mr as MemberListQuery,gt as MemberState,cr as MemberStateFilter,Br as MembershipFilter,hr as MessageCollection,lr as MessageCollectionInitHandler,zn as MessageCollectionInitPolicy,Yn as MessageEventContext,Hr as MutedState,Et as MyMemberStateFilter,Mt as OperatorFilter,yt as PublicChannelFilter,Zr as PublicGroupChannelListQuery,St as QueryType,Ut as ReadStatus,Ct as SuperChannelFilter,Nt as UnreadChannelFilter}; +import{_ as e,H as t,R as n,e as r,g as s,J as i,U as a,I as o,aw as c,p as l,m as h,b as d,c as _,o as f,l as p,a as m,i as g,N as y,ax as E,$ as C,ay as N,az as b,aA as M,a5 as S,Q as A,A as T,d as U,f as I,h as w,aB as D,aC as L,aD as R,aE as O,ae as k,W as F,aF as P,B as x,S as H,s as V,V as q,X as B,Y as K,am as j,t as z,a6 as Q,aG as W,u as Y,a0 as J,aH as X,F as Z,al as $,E as ee,a2 as te,a3 as ne,Z as re,T as se,ab as ie,aI as ae,aJ as oe,aK as ue,ac as ce,a7 as le,aL as he,a8 as de,aa as _e,aM as fe,aN as pe,an as me,aO as ve,aP as ge,n as ye,aQ as Ee}from"./__bundle-26bafa9e.js";export{a6 as MessageEventSource}from"./__bundle-26bafa9e.js";import{N as Ce,G as Ne,g as be,r as Me,D as Se,k as Ae,j as Te,s as Ue,U as Ie,h as we,i as De,t as Le,u as Re,A as Oe,o as ke,m as Fe,n as Pe,S as xe,p as He,v as Ve,w as Ge}from"./__bundle-ae9e1003.js";export{G as GroupChannelListOrder,u as MessageFilter,v as PublicGroupChannelListOrder}from"./__bundle-ae9e1003.js";import{b as qe,U as Be,g as Ke,h as je,j as ze,k as Qe,l as We,m as Ye,D as Je,n as Xe,o as Ze,p as $e,q as et,v as tt,r as nt,t as rt,u as st,w as it,x as at,y as ot,a as ut}from"./__bundle-f79aa272.js";import{C as ct,a as lt,O as ht,M as dt,T as _t,R as ft,U as pt,A as mt,B as vt}from"./__bundle-9ac5dba1.js";var gt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited"}(gt||(gt={}));var yt,Et,Ct,Nt,bt,Mt,St,At,Tt=function(i){function a(e,r){var s=i.call(this,e,r)||this;return s.state=null,s.role=null,s.isMuted=!1,s.isBlockedByMe=!1,s.isBlockingMe=!1,s.state=t(gt,r.state)?r.state:null,s.role=t(n,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(s.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(s.isBlockingMe=r.is_blocking_me),s}return e(a,i),a.payloadify=function(e){return e?r(s(s({},i.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},a}(qe),Ut=function(t){function n(e,n){var r,s,o=this;return(o=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(s=n.channel_type)&&void 0!==s?s:i.GROUP,o.reader=new a(o._iid,n.user),o.readAt=n.ts,o}return e(n,t),n}(o);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(yt||(yt={})),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"}(Et||(Et={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ct||(Ct={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Nt||(Nt={})),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"}(bt||(bt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Mt||(Mt={})),function(e){e.AND="AND",e.OR="OR"}(St||(St={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(At||(At={}));var It,wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter="",this.channelNameContainsFilter="",this.myMemberStateFilter=Et.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ct.ALL,this.publicChannelFilter=yt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Nt.ALL,this.hiddenChannelFilter=bt.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=St.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 At.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case At.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 St.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case St.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(!c(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 h=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(h)})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Et.JOINED:if("joined"!==e.myMemberState)return!1;break;case Et.INVITED:if("invited"!==e.myMemberState)return!1;break;case Et.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Et.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1;break;case Et.ALL:if("none"===e.myMemberState)return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case bt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case bt.HIDDEN:if(!e.isHidden)return!1;break;case bt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case bt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Nt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case yt.PUBLIC:if(!e.isPublic)return!1;break;case yt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ct.SUPER:if(!e.isSuper)return!1;break;case Ct.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Dt=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(Ce):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),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return Gn.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return l([],h(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.get=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._channels.set(e,n),[2,n];r.label=2;case 2:return[2,null];case 3:return[2,this._channels.get(e)]}}))}))},n.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?Me:n,s=e.backward,i=void 0!==s&&s,a=e.filter,o=void 0===a?new wt:a,u=e.order,c=void 0===u?Ne.LATEST_LAST_MESSAGE:u;return d(this,void 0,void 0,(function(){var e,n,s,a,u=this;return _(this,(function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=be(c),n={where:function(e){if(t)switch(c){case Ne.CHANNEL_NAME_ALPHABETICAL:if(!i&&e.name.localeCompare(t)<0||i&&e.name.localeCompare(t)>0)return!1;break;case Ne.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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=l([],h(this._channels.keys()),!1)),d(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=f(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),l.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(o),Lt={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},Rt=function(e){return p("string",e.invitedUserIds,!0)&&m("string",e.channelUrl,!0)&&m("string",e.coverUrl,!0)&&(g(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)&&p("string",e.operatorUserIds,!0)&&m("number",e.messageSurvivalSeconds,!0)},Ot={customTypes:null,includeEmpty:!1,includeFrozen:!0},kt=function(e){return p("string",e.customTypes,!0)&&m("boolean",e.includeEmpty)&&m("boolean",e.includeFrozen)},Ft={myMemberStateFilter:Et.ALL},Pt=function(e){return t(Et,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"}(It||(It={}));var xt,Ht={keys:[]},Vt={channelCustomTypesFilter:null,superChannelFilter:Ct.ALL},Gt={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.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"}(xt||(xt={}));var qt=function(e){return e.startsWith("EVENT_")||e===xt.SYNC_CHANNEL_BACKGROUND||e===xt.SYNC_CHANNEL_CHANGELOGS},Bt=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}(C),Kt=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}(C),jt=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 d(i,void 0,void 0,(function(){var s,i,a,o,u=this;return _(this,(function(c){switch(c.label){case 0:return e instanceof Bt?(s=e.channels,o=e.source,i=s.filter((function(e){return e instanceof Kr})),[4,t.upsert(i)]):[3,2];case 1:return c.sent(),this._broadcastUpdateEvent(i,o),[3,7];case 2:return e instanceof Kt?(a=e.channelUrls,o=e.source,[4,t.remove(a)]):[3,5];case 3:return c.sent(),[4,N((function(){return d(u,void 0,void 0,(function(){var e,t,s,i,o,u;return _(this,(function(c){switch(c.label){case 0:c.trys.push([0,6,7,8]),e=f(a),t=e.next(),c.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return c.sent(),[4,r.removeMessagesOfChannel(s)];case 3:c.sent(),c.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=c.sent(),o={error:i},[3,8];case 7:try{t&&!t.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))}))];case 4:return c.sent(),this._broadcastRemoveEvent(a,o),[3,7];case 5:return e instanceof Se?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:c.sent(),c.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(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=f(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}(),zt=function(){function e(e){var t=e.messageCache,n=e.unsentMessageCache,r=e.dispatcher,s=e.logger,i=this;this._observers=new Map,this._logger=null,this._logger=s,r.on((function(e){return d(i,void 0,void 0,(function(){var r,s,i,a,o,u,c=this;return _(this,(function(l){switch(l.label){case 0:return e instanceof S?(r=e.messages,u=e.source,s=r.filter((function(e){return e.messageId>0})),i=r.filter((function(e){return 0===e.messageId})),s.length>0?[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.upsert(s)];case 1:return e.sent(),[4,n.remove(s.map((function(e){return e instanceof A?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:l.sent(),this._broadcastUpdateEvent(s,u),l.label=2;case 2:return i.length>0?[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:l.sent(),this._broadcastUpdateEvent(i,u),l.label=4;case 4:return[3,9];case 5:return e instanceof M?(a=e.messageIds,u=e.source,[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return l.sent(),this._broadcastRemoveEvent(a,u),[3,9];case 7:return e instanceof b?(o=e.reqId,u=e.source,[4,N((function(){return d(c,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:l.sent(),this._broadcastRemoveUnsentEvent(o,u),l.label=9;case 9:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=f(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=f(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=f(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}(),Qt=function(t){function n(e){var n=e.userId,i=e.ts,a=e.token,o=e.filter,u=t.call(this)||this,c=s(s({},Ot),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=T.GET,u.path="".concat(U,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(I),Wt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new Kr(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(w),Yt=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=T.GET,s.path="".concat(r?D:L,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(I),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new Kr(e,n),r}return e(n,t),n}(w),Xt=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,_=e.nicknameContainsFilter,f=e.channelNameContainsFilter,p=e.channelUrlsFilter,m=e.customTypesFilter,v=e.customTypeStartsWithFilter,g=e.hiddenChannelFilter,y=e.metadataOrderKeyFilter,E=e.metadataKey,C=e.metadataValues,N=e.metadataValueStartsWith,b=e.includeFrozen,M=e.includeMetaData,S=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=T.GET,n.path="".concat(U,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:_,name_contains:f,channel_urls:p,custom_types:m,custom_type_startswith:v,hidden_mode:g,metadata_order_key:y,metadata_key:E,metadata_values:C,metadata_value_startswith:N,show_frozen:b,show_metadata:M}),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}(I),Zt=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 Kr(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(w),$t=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Et.ALL},s}return e(n,t),n}(I),en=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}(w),tn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(I),nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[It.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[It.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[It.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[It.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[It.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[It.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[It.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[It.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[It.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[It.SUPER_INVITATION_COUNT]),"number"==typeof n[It.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[It.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[It.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[It.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[It.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[It.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(w),rn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=T.GET,r.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(I),sn=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}(w),an=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=T.GET,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ct.ALL,custom_types:i},s}return e(n,t),n}(I),on=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}(w),un=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=T.GET,i.path="".concat(R,"/count"),i.params={channel_url:n,status:ln(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(I),cn=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}(w),ln=function(e){if(e){var t=[];e.forEach((function(e){switch(e){case E.PENDING:t.push(O.PENDING);break;case E.SENT:t.push(O.IN_QUEUE),t.push(O.SENT);break;case E.CANCELED:t.push(O.CANCELED);break;case E.FAILED:t.push(O.FAILED)}}))}},hn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,d=e.isBroadcast,_=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(n=t.call(this)||this).method=T.POST,n.path=L,n.params=r({user_ids:l([s],h(null!=b?b:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:d,is_exclusive:f,is_public:_,is_discoverable:p,strict:m,is_ephemeral:v,access_code:g,name:y,data:E,custom_type:C,operator_ids:M,message_survival_seconds:N}),n}return e(n,t),n}(I),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(w),_n=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=T.PUT,s.path="".concat(U,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var fn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(I),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),mn=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,l=i.users,h=void 0===l?null:l;return s.memberCount=o,s.joinedMemberCount=c,s.members=Array.isArray(h)?h.map((function(t){return new Tt(e,t)})):[new Tt(e,r.data)],s}return e(n,t),n}(ct),vn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(I);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(w);var gn=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;return s.memberCount=o,s.joinedMemberCount=c,s.member=new Tt(s._iid,r.data),s}return e(n,t),n}(ct),yn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=T.POST,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(I),En=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),Cn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,_=i.invitees,f=void 0===_?[]:_;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitees=f.map((function(t){return new Tt(e,t)})),s}return e(n,t),n}(ct),Nn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(I),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.channel.myMemberState=gt.NONE,r}return e(n,t),n}(w),Mn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,o=i.member_count,u=void 0===o?null:o,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,_=i.invitee,f=void 0===_?null:_;return s.memberCount=u,s.joinedMemberCount=l,s.inviter=d?new a(e,d):null,s.invitee=f?new Tt(e,f):null,s}return e(n,t),n}(ct),Sn=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}(k),An=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new Ut(e,r),s}return e(n,t),n}(F),Tn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=T.PUT,i.path="".concat(L,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var Un,In=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}(F),wn=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=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(I),Dn=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}(w),Ln=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}(F),Rn=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}(k),On=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(F),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}(k),Fn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new a(e,r.data),s}return e(n,t),n}(F),Pn=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}(k),xn=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,_,f,p,m,v,g,y,E,C,N,b=this;return(b=n.call(this,e,t)||this).includeEmpty=!1,b.includeFrozen=!0,b.includeMetaData=!0,b.channelUrlsFilter=null,b.customTypesFilter=null,b.customTypeStartsWithFilter=null,b.nicknameContainsFilter="",b.channelNameContainsFilter="",b.myMemberStateFilter=Et.ALL,b.unreadChannelFilter=Nt.ALL,b.superChannelFilter=Ct.ALL,b.publicChannelFilter=yt.ALL,b.hiddenChannelFilter=bt.UNHIDDEN,b.searchFilter={fields:[],query:null},b.userIdsFilter={userIds:[],includeMode:!0,queryType:St.AND},b.metadataKey=null,b.metadataValues=null,b.metadataOrderKeyFilter=null,b.metadataValueStartsWith=null,b.order=Ne.LATEST_LAST_MESSAGE,b.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r&&r,b.includeFrozen=null===(s=t.includeFrozen)||void 0===s||s,b.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,b.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,b.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,b.customTypeStartsWithFilter=null!==(u=t.customTypeStartsWithFilter)&&void 0!==u?u:"",b.nicknameContainsFilter=null!==(c=t.nicknameContainsFilter)&&void 0!==c?c:"",b.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:"",b.myMemberStateFilter=null!==(h=t.myMemberStateFilter)&&void 0!==h?h:Et.ALL,b.unreadChannelFilter=null!==(d=t.unreadChannelFilter)&&void 0!==d?d:Nt.ALL,b.superChannelFilter=null!==(_=t.superChannelFilter)&&void 0!==_?_:Ct.ALL,b.publicChannelFilter=null!==(f=t.publicChannelFilter)&&void 0!==f?f:yt.ALL,b.hiddenChannelFilter=null!==(p=t.hiddenChannelFilter)&&void 0!==p?p:bt.UNHIDDEN,b.searchFilter=null!==(m=t.searchFilter)&&void 0!==m?m:{fields:[],query:null},b.userIdsFilter=null!==(v=t.userIdsFilter)&&void 0!==v?v:{userIds:[],includeMode:!0,queryType:St.AND},b.metadataKey=null!==(g=t.metadataKey)&&void 0!==g?g:null,b.metadataValues=null!==(y=t.metadataValues)&&void 0!==y?y:null,b.metadataOrderKeyFilter=null!==(E=t.metadataOrderKeyFilter)&&void 0!==E?E:null,b.metadataValueStartsWith=null!==(C=t.metadataValueStartsWith)&&void 0!==C?C:null,b.order=null!==(N=t.order)&&void 0!==N?N:Ne.LATEST_LAST_MESSAGE,b}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)&&m("boolean",this.includeFrozen)&&m("boolean",this.includeMetaData)&&m("string",this.channelNameContainsFilter)&&p("string",this.channelUrlsFilter,!0)&&p("string",this.customTypesFilter,!0)&&m("string",this.customTypeStartsWithFilter)&&m("string",this.nicknameContainsFilter)&&t(Et,this.myMemberStateFilter)&&t(Ct,this.superChannelFilter)&&t(yt,this.publicChannelFilter)&&t(Nt,this.unreadChannelFilter)&&t(bt,this.hiddenChannelFilter)&&p(At,this.searchFilter.fields)&&m("string",this.searchFilter.query,!0)&&p("string",this.userIdsFilter.userIds)&&m("boolean",this.userIdsFilter.includeMode)&&t(St,this.userIdsFilter.queryType)&&t(Ne,this.order)&&m("string",this.metadataOrderKeyFilter,!0)&&m("string",this.metadataKey,!0)&&p("string",this.metadataValues,!0)&&m("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return P(this)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Gn.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 H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),Hn=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||U.unreadMentionCount>0)&&(U._updateUnreadCount(0,0),this._dispatcher.dispatch(new Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}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!==U.unreadMessageCount&&0!==U.unreadMentionCount||(this._dispatcher.dispatch(new Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}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 Bt({channels:[U],source:xt.EVENT_CHANNEL_READ})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),nn.label=12;case 12:return[3,71];case 13:return I=e.as(In),Z=I.channelUrl,w=I.deliveredStateUpdate,D=void 0===w?{}:w,L=this._groupChannelCache.isCachedInMemory(Z),[4,this.getChannel(Z,!0)];case 14:if(R=nn.sent(),L)for(O in D)R._updateUndeliveredMemberState(O,D[O]);return this._dispatcher.dispatch(new Bt({channels:[R],source:xt.EVENT_CHANNEL_DELIVERED})),Object.keys(D).some((function(e){return e!==tn._sdkState.userId}))&&z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(R)}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,71];case 15:return k=e.as(ft),Z=k.channelUrl,F=k.channelType,P=k.event,F!==i.GROUP?[3,18]:[4,this.getChannel(Z,!0)];case 16:return x=nn.sent(),[4,this.getMessageFromCache(P.messageId)];case 17:(G=nn.sent())&&(G.applyReactionEvent(P),this._dispatcher.dispatch(new S({messages:[G],source:Q.EVENT_MESSAGE_REACTION_UPDATED}))),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(x,P)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),nn.label=18;case 18:return[3,71];case 19:return(H=e.as(_t).event).channelType!==i.GROUP?[3,22]:[4,this.getChannel(H.channelUrl,!0)];case 20:return V=nn.sent(),[4,this.getMessageFromCache(H.targetMessageId)];case 21:(G=nn.sent())&&(G.applyThreadInfoUpdateEvent(H),this._dispatcher.dispatch(new S({messages:[G],source:Q.EVENT_MESSAGE_THREADINFO_UPDATED}))),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(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]}))}))})),nn.label=22;case 22:return[3,71];case 23:B=e.as(dt).groupChannelMemberCounts,K=[],nn.label=24;case 24:nn.trys.push([24,29,30,31]),Y=f(B),J=Y.next(),nn.label=25;case 25:return J.done?[3,28]:(X=J.value,Z=X.channelUrl,Ue=X.memberCount,Le=X.joinedMemberCount,$=X.updatedAt,[4,this.getChannelFromCache(Z)]);case 26:(ee=nn.sent())&&ee._setLatestMemberCount(Ue,Le,$)&&K.push(ee),nn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=nn.sent(),Qt={error:te},[3,31];case 30:try{J&&!J.done&&(Wt=Y.return)&&Wt.call(Y)}finally{if(Qt)throw Qt.error}return[7];case 31:return K.length>0&&(this._dispatcher.dispatch(new Bt({channels:K,source:xt.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=f(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(K)}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,71];case 32:if(!(ne=e.as(ct).event).isGroupChannelEvent)return[3,69];switch(ne.category){case lt.CHANNEL_JOIN:return[3,33];case lt.CHANNEL_LEAVE:return[3,35];case lt.CHANNEL_OPERATOR_UPDATE:return[3,39];case lt.CHANNEL_INVITE:return[3,41];case lt.CHANNEL_DECLINE_INVITE:return[3,43];case lt.TYPING_START:case lt.TYPING_END:return[3,45];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,47];case lt.USER_CHANNEL_BAN:return[3,49];case lt.USER_CHANNEL_UNBAN:return[3,53];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,55];case lt.CHANNEL_HIDE:return[3,57];case lt.CHANNEL_UNHIDE:return[3,59];case lt.CHANNEL_DELETED:return[3,61];case lt.CHANNEL_PROP_CHANGED:return[3,63];case lt.CHANNEL_META_DATA_CHANGED:return[3,65];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,67]}return[3,69];case 33:return[4,this.getChannel(ne.channelUrl,!0)];case 34:return re=nn.sent(),se=e.as(mn),ie=se.memberCount,ae=se.joinedMemberCount,oe=se.members,ue=!1,oe.forEach((function(e){re.isExclusive||re.isSuper||re.isBroadcast?ue=ue||re._setLatestMemberCount(ie,ae,ne.ts):(e.state=gt.JOINED,re.addMember(e,ne.ts),tn._updateJoinedMemberCount(re)),e.userId===tn._sdkState.userId&&(re.myMemberState=gt.JOINED)})),this._dispatcher.dispatch(new Bt({channels:[re],source:xt.EVENT_CHANNEL_JOINED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=f(oe),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(re,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}re.isBroadcast&&ue&&e.onChannelMemberCountChanged([re])})),[2]}))}))})),[3,69];case 35:return(tt=this._leftChannels.get(ne.channelUrl))?(le=tt.channel,[3,38]):[3,36];case 36:return[4,this.getChannel(ne.channelUrl,!0)];case 37:le=nn.sent(),nn.label=38;case 38:return ce=le,he=e.as(gn),Ue=he.memberCount,Le=he.joinedMemberCount,de=he.member,_e=!1,ce.isExclusive||ce.isSuper||ce.isBroadcast?_e=ce._setLatestMemberCount(Ue,Le,ne.ts):(ce.removeMember(de),this._updateJoinedMemberCount(ce)),de.userId===this._sdkState.userId?ce.isPublic?(ce.myMemberState=gt.NONE,ce.invitedAt=0,ce.joinedAt=0,ce._updateUnreadCount(0,0),this._dispatcher.dispatch(new Bt({channels:[ce],source:xt.EVENT_CHANNEL_LEFT}))):(this._markAsLeave(ce),this._dispatcher.dispatch(new Kt({channelUrls:[ce.url],source:xt.EVENT_CHANNEL_LEFT}))):this._dispatcher.dispatch(new Bt({channels:[ce],source:xt.EVENT_CHANNEL_LEFT})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ce,de),ce.isBroadcast&&_e&&e.onChannelMemberCountChanged([ce])})),[2]}))}))})),[3,69];case 39:return[4,this.getChannel(ne.channelUrl,!0)];case 40:fe=nn.sent(),pe=e.as(ht).operators,me=pe.map((function(e){return e.userId}));try{for(ve=f(fe.members),ge=ve.next();!ge.done;ge=ve.next())(et=ge.value).role=me.includes(et.userId)?n.OPERATOR:n.NONE}catch(e){Yt={error:e}}finally{try{ge&&!ge.done&&(Jt=ve.return)&&Jt.call(ve)}finally{if(Yt)throw Yt.error}}return fe.myRole=me.includes(this._sdkState.userId)?n.OPERATOR:n.NONE,this._dispatcher.dispatch(new Bt({channels:[fe],source:xt.EVENT_CHANNEL_OPERATOR_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(fe,pe)})),[2]}))}))})),[3,69];case 41:return[4,this.getChannel(ne.channelUrl,!0)];case 42:ye=nn.sent(),Ee=e.as(Cn),Ue=Ee.memberCount,Le=Ee.joinedMemberCount,Ce=Ee.inviter,(Ne=Ee.invitees).forEach((function(e){return e.state=gt.INVITED}));try{for(be=f(Ne),Me=be.next();!Me.done;Me=be.next())Se=Me.value,ye.isExclusive||ye.isSuper||ye.isBroadcast?ye._setLatestMemberCount(Ue,Le,ne.ts):ye.addMember(Se,ne.ts),this._sdkState.userId===Se.userId&&(ye.hiddenState=Vr.UNHIDDEN,ye.myMemberState!==gt.JOINED&&(ye.myMemberState=gt.INVITED),ye.invitedAt=ne.ts)}catch(e){Xt={error:e}}finally{try{Me&&!Me.done&&(Zt=be.return)&&Zt.call(be)}finally{if(Xt)throw Xt.error}}return this._dispatcher.dispatch(new Bt({channels:[ye],source:xt.EVENT_CHANNEL_INVITED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ye,Ce,Ne)})),[2]}))}))})),[3,69];case 43:return[4,this.getChannel(ne.channelUrl,!0)];case 44:return Ae=nn.sent(),Te=e.as(Mn),Ue=Te.memberCount,Le=Te.joinedMemberCount,Re=Te.inviter,Oe=Te.invitee,Ae.isExclusive||Ae.isSuper||Ae.isBroadcast?Ae._setLatestMemberCount(Ue,Le,ne.ts):Ae.removeMember(Oe),this._sdkState.userId===Oe.userId?(Ae.invitedAt=0,Ae.myMemberState=gt.NONE,Ae.isPublic?this._dispatcher.dispatch(new Bt({channels:[Ae],source:xt.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Kt({channelUrls:[Ae.url],source:xt.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Bt({channels:[Ae],source:xt.EVENT_CHANNEL_DECLINED_INVITE})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Ae,Re,Oe)})),[2]}))}))})),[3,69];case 45:return[4,this.getChannel(ne.channelUrl,!0)];case 46:return ke=nn.sent(),Fe=ne.category===lt.TYPING_START,Pe=e.as(Fe?On:Fn).user,ke._updateTypingStatus(Pe,Fe?ne.ts:0),this._dispatcher.dispatch(new Bt({channels:[ke],source:xt.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(ke)})),[2]}))}))})),[3,69];case 47:return[4,this.getChannel(ne.channelUrl,!0)];case 48:xe=nn.sent(),He=ne.category===lt.USER_CHANNEL_MUTE,(Ve=e.as(He?We:Ye).user).userId===this._sdkState.userId&&(xe.myMutedState=He?Hr.MUTED:Hr.UNMUTED);try{for(Ge=f(xe.members),qe=Ge.next();!qe.done;qe=Ge.next())if((et=qe.value).userId===Ve.userId){et.isMuted=He;break}}catch(e){$t={error:e}}finally{try{qe&&!qe.done&&(en=Ge.return)&&en.call(Ge)}finally{if($t)throw $t.error}}return this._dispatcher.dispatch(new Bt({channels:[xe],source:He?xt.EVENT_CHANNEL_MUTED:xt.EVENT_CHANNEL_UNMUTED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){He?e.onUserMuted(xe,Ve):e.onUserUnmuted(xe,Ve)})),[2]}))}))})),[3,69];case 49:return(tt=this._leftChannels.get(ne.channelUrl))?(rt=tt.channel,[3,52]):[3,50];case 50:return[4,this.getChannel(ne.channelUrl,!0)];case 51:rt=nn.sent(),nn.label=52;case 52:return nt=rt,this._markAsLeave(nt),st=e.as(Qe).user,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(nt,st)})),[2]}))}))})),[3,69];case 53:return[4,this.getChannel(ne.channelUrl,!0)];case 54:return it=nn.sent(),at=e.as(ze).user,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(it,at)})),[2]}))}))})),[3,69];case 55:return[4,this.getChannel(ne.channelUrl,!0)];case 56:return ot=nn.sent(),ut=e.as(je).freeze,ot.isFrozen=ut,this._dispatcher.dispatch(new Bt({channels:[ot],source:ut?xt.EVENT_CHANNEL_FROZEN:xt.EVENT_CHANNEL_UNFROZEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){ut?e.onChannelFrozen(ot):e.onChannelUnfrozen(ot)})),[2]}))}))})),[3,69];case 57:return[4,this.getChannel(ne.channelUrl,!0)];case 58:return vt=nn.sent(),yt=e.as(Ln),Et=yt.allowAutoUnhide,Ct=yt.hidePreviousMessages,Nt=yt.messageOffsetTimestamp,null!==Et&&(vt.hiddenState=Et?Vr.HIDDEN_ALLOW_AUTO_UNHIDE:Vr.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ct&&Ct&&vt._updateUnreadCount(0,0),null!==Nt&&(vt.messageOffsetTimestamp=Nt),this._dispatcher.dispatch(new Bt({channels:[vt],source:xt.EVENT_CHANNEL_HIDDEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(vt)})),[2]}))}))})),[3,69];case 59:return[4,this.getChannel(ne.channelUrl,!0)];case 60:return(bt=nn.sent()).hiddenState=Vr.UNHIDDEN,this._dispatcher.dispatch(new Bt({channels:[bt],source:xt.EVENT_CHANNEL_UNHIDDEN})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(bt)})),[2]}))}))})),[3,69];case 61:return[4,this.getChannel(ne.channelUrl,!0)];case 62:return Mt=nn.sent(),this._dispatcher.dispatch(new Kt({channelUrls:[ne.channelUrl],source:xt.EVENT_CHANNEL_DELETED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Mt.url,Mt.channelType)})),[2]}))}))})),[3,69];case 63:return[4,this.getChannelWithoutCache(ne.channelUrl,!0)];case 64:return St=nn.sent(),this._dispatcher.dispatch(new Bt({channels:[St],source:xt.EVENT_CHANNEL_UPDATED})),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(St)})),[2]}))}))})),[3,69];case 65:return[4,this.getChannel(ne.channelUrl,!0)];case 66:return At=nn.sent(),Tt=e.as(Ke),Ut=Tt.created,It=Tt.updated,wt=Tt.deleted,Ut&&At._upsertCachedMetaData(Ut,ne.ts),It&&At._upsertCachedMetaData(It,ne.ts),wt&&At._removeFromCachedMetaData(wt,ne.ts),z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ut&&e.onMetaDataCreated(At,Ut),It&&e.onMetaDataUpdated(At,It),wt&&e.onMetaDataDeleted(At,wt)})),[2]}))}))})),[3,69];case 67:return[4,this.getChannel(ne.channelUrl,!0)];case 68:return Dt=nn.sent(),Lt=e.as(Be),Rt=Lt.created,Ot=Lt.updated,kt=Lt.deleted,z((function(){return d(tn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Rt&&e.onMetaCounterCreated(Dt,Rt),Ot&&e.onMetaCounterUpdated(Dt,Ot),kt&&e.onMetaCounterDeleted(Dt,kt)})),[2]}))}))})),[3,69];case 69:return[3,71];case 70:switch((Ft=e.as(Ie).event).category){case we.USER_BLOCK:Pt=De.getDataAsUserBlockEvent(this._iid,Ft),Vt=Pt.blocker,Gt=Pt.blockee,this._groupChannelCache.block(Vt.userId,Gt.userId);break;case we.USER_UNBLOCK:Ht=De.getDataAsUserBlockEvent(this._iid,Ft),Vt=Ht.blocker,Gt=Ht.blockee,this._groupChannelCache.unblock(Vt.userId,Gt.userId)}return[3,71];case 71:return[3,73];case 72:if(qt=nn.sent(),j(qt))throw qt;return[3,73];case 73: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===gt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),d(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:Y(m("string",e)).throw(H.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),d(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(m("string",e)).throw(H.invalidParameters),n=new Yt({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(Jt).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case xr.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case xr.UNREAD_MENTION_COUNT_ONLY:i=0;break;case xr.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=xt.REQUEST_CHANNEL),d(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return i=new Xt(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(Zt),u=o.channels,c=o.token,this._dispatcher.dispatch(new Bt({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return d(this,void 0,void 0,(function(){return _(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=Le),d(this,void 0,void 0,(function(){return _(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.getAllFailedMessagesFromCache=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t,sendingStatus:J.FAILED})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Hn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=xt.REQUEST_CHANNEL_CHANGELOGS),d(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=s(s({},Ot),t),Y(m("string",e)&&kt(t)).throw(H.invalidParameters),i=new Qt(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:t})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(Wt),u=o.updatedChannels,c=o.deletedChannelUrls,u.length>0&&this._dispatcher.dispatch(new Bt({channels:u,source:n})),c.length>0&&this._dispatcher.dispatch(new Kt({channelUrls:c,source:n})),[2,o]}}))}))},e.prototype.getGroupChannelCount=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=s(s({},Ft),e),Y(Pt(e)).throw(H.invalidParameters),t=new $t({userId:this._sdkState.userId,filter:e}),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(en).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=s(s({},Ht),e),Y(function(e){return p(It,e.keys)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new tn({userId:n.userId,filter:e}),[4,r.send(i)];case 1:return[2,a.sent().as(nn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(sn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return d(this,void 0,void 0,(function(){var n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=s(s({},Vt),e),Y(function(e){return p("string",e.channelCustomTypesFilter)&&t(Ct,e.superChannelFilter)}(e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new an({userId:r.userId,filter:e}),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(on).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),d(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=s(s({},Gt),e),Y(function(e){return m("string",e.channelUrl,!0)&&p(E,e.scheduledStatus,!0)&&t(y,e.messageTypeFilter)}(e)).throw(H.invalidParameters),n=q.of(this._iid).requestQueue,r=new un(e),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(cn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=q.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=q.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=q.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return d(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),e.isPublic||(e.accessCode=null),t=new hn(s({userId:this._sdkState.userId},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),r=n.as(dn).channel,[4,this._groupChannelCache.upsert([r])];case 2:return i.sent(),[2,r]}}))}))},e.prototype.markAsReadAll=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=Date.now(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(H.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new _n({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=f(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._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(p("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(H.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new _n({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=f(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&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return d(this,void 0,void 0,(function(){return _(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}(),qn=new Map,Bn=new Map,Kn=new Map,jn=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],X()?(qn[this._holdersKey]||(qn[this._holdersKey]=[]),Bn[this._resolversKey]||(Bn[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return d(o,void 0,void 0,(function(){var t,n;return _(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(X())return this.numLocks-qn[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return X()?Bn[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(X())return Kn[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){X()?Kn[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,$(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),X()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),d(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){return X()?[2,new Promise((function(t){for(var r={key:Z(),resolver:function(e){return t(e)},priority:e},s=Bn[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?Bn[n._resolversKey].splice(i,0,r):Bn[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=Z(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(X()){if((t=qn[this._holdersKey].indexOf(e))>=0)return qn[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=l([],h(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(X()){if(qn[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return(r=o.sent())instanceof H&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:return t.hasNext=!1,t.nextToken=0,[3,8];case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new Qn(c,(function(e){return d(r,void 0,void 0,(function(){var t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return a.sent(),u.debug("message background next sync from",null===(r=this._metadata)||void 0===r?void 0:r.range.bottom),[4,re.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(i=null===(s=this._metadata.range)||void 0===s?void 0:s.bottom)&&void 0!==i?i:e,{prevResultSize:0,nextResultSize:100,replyType:se.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},Q.SYNC_MESSAGE_BACKGROUND)];case 2:return n=a.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 3:return a.sent(),[2,t]}}))}))}))}return e.of=function(t,n){if(Jn[t]||(Jn[t]={}),!Jn[t][n.url]){var r=Jn[t][n.url]=new e({_iid:t,channel:n});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)r.resume();else r.pause()}))}return Jn[t][n.url]},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,l([],h(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,l([],h(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,q.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new Hn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){var e,t,n,r;q.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(){q.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),Zn={},$n=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=q.of(this._iid).sdkState;this._metadataKey=(s=a.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var o=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(a.userId,this._channel.url);this._sync=new Qn(o,(function(){return d(r,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,re.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:se.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includePollDetails:!0},Q.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[3,8];case 5:return(s=i.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return e.of=function(t,n){if(Zn[t]||(Zn[t]={}),!Zn[t][n.url]){var r=Zn[t][n.url]=new e({_iid:t,channel:n});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)r.resume();else r.pause()}))}return Zn[t][n.url]},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=q.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),er=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=T.GET,c.path="".concat(ie(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({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!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u}),c}return e(n,t),n}(I),tr=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 ae(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 ae(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(w),nr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},rr=function(e,t,n){if(e.length>0){var r=nr(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:sr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},sr=function(e,t,n){switch(n){case Ne.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 Ne.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ne.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},ir=function(e,t){if(t instanceof A)return e.findIndex((function(e){return e instanceof A&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},ar=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};!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(zn||(zn={}));var or,ur,cr,lr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;z((function(){return d(r,void 0,void 0,(function(){return _(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}(),hr=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._iid=e,this._key="mc-".concat(Z()),this.filter=null!=r?r:new Re,this._channel=n,this._syncRange=new Hn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||Le;var o=Gn.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=nr(e,a._channel);if(o>=0)switch(z((function(){return d(a,void 0,void 0,(function(){var n;return _(this,(function(r){return n=new Wn(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case xt.EVENT_CHANNEL_UPDATED:var u=!1;for(var c in a._messages){if((g=a._messages[c]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var l=parseInt(c);if(l>0){var h=a._messages.splice(0,l);a._removeMessagesFromView(h.map((function(e){return e.messageId})),Q.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),Q.EVENT_MESSAGE_OFFSET_UPDATED);break;case xt.EVENT_CHANNEL_READ:var p=[];try{for(var m=f(a._messages),v=m.next();!v.done;v=m.next()){var g=v.value;if((C=a._readReceiptMap.get(g.messageId))>0)C!==a._channel.getUnreadMemberCount(g)&&p.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}p.length>0&&a._updateMessagesToView(p,Q.EVENT_MESSAGE_READ);break;case xt.EVENT_CHANNEL_DELIVERED:p=[];try{for(var y=f(a._messages),E=y.next();!E.done;E=y.next()){var C;g=E.value;if((C=a._deliveryReceiptMap.get(g.messageId))>0)C!==a._channel.getUndeliveredMemberCount(g)&&p.push(g)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(i=y.return)&&i.call(y)}finally{if(s)throw s.error}}p.length>0&&a._updateMessagesToView(p,Q.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&z((function(){return d(a,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),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=f(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(oe(t)){if(s.length>0)switch(t){case Q.EVENT_MESSAGE_SENT_FAILED:case Q.EVENT_MESSAGE_SENT_SUCCESS:case Q.EVENT_MESSAGE_UPDATED:case Q.EVENT_MESSAGE_THREADINFO_UPDATED:case Q.EVENT_MESSAGE_REACTION_UPDATED:case Q.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case Q.EVENT_MESSAGE_SENT_PENDING:case Q.EVENT_MESSAGE_RECEIVED:case Q.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)}});var u=q.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&Xn.of(this._iid,this._channel).resume(),$n.of(this._iid,this._channel).resume(),this._prevFill=new Qn(this._key,(function(e){return d(a,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:Q.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,l([],h(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,l([],h(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 c=q.of(this._iid),p=c.dispatcher,m=c.logger;p.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)m.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 l([],h(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===J.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===J.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,l(l([],h(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,l(l([],h(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){var t=this;return e.filter((function(e){return e.createdAt>=t._channel.messageOffsetTimestamp}))},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=f(i),c=u.next();!c.done;c=u.next()){var p=c.value;if(p.messageId>0){if((y=ir(this._messages,p))<0){var m=ir(this._unsentMessages,p);m<0?a.push(p):(this._unsentMessages.splice(m,1),o.push(p));var v=ar(this._messages,p);this._messages.splice(v,0,p)}else o.push(p),this._messages[y]=p;if(this._readReceiptMap.set(p.messageId,this._channel.getUnreadMemberCount(p)),this._deliveryReceiptMap.set(p.messageId,this._channel.getUndeliveredMemberCount(p)),p.updatedAt>0){var g=this._updateChildMessagesInView(p);o.push.apply(o,l([],h(g),!1))}}else{var y;if(p instanceof A)(y=ir(this._unsentMessages,p))<0?ir(this._messages,p)<0&&(this._unsentMessages.push(p),a.push(p)):(o.push(p),this._unsentMessages[y]=p)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}oe(t)&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=f(e),o=a.next();!o.done;o=a.next()){var u,c=o.value;if(c.messageId>0)if((u=ir(this._messages,c))>=0)i.push(c),this._messages[u]=c;else{var l=ir(this._unsentMessages,c);if(l>=0){i.push(c),this._unsentMessages.splice(l,1);var h=ar(this._messages,c);this._messages.splice(h,0,c)}}else if(c instanceof A)(u=ir(this._unsentMessages,c))>=0&&(i.push(c),this._unsentMessages[u]=c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return oe(t)&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return oe(t)&&i.length>0&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Yn(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 d(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return _(this,(function(d){switch(d.label){case 0:return t=Gn.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=d.sent(),[3,3];case 2:s=[],d.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=d.sent(),[3,6];case 5:o=[],d.label=6;case 6:if(a=o,n.length>0&&a.length)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,l(l([],h(n),!1),h(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,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?Q.REQUEST_MESSAGE:o;return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(i){switch(i.label){case 0:return t=re.of(this._iid),r>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,c,f,p=this;return _(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,(i=Gn.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,n,r)];case 2:return o=m.sent(),[4,ue((function(){return d(p,void 0,void 0,(function(){var i,u,c,f,p,m,v,g,y,E,C,N,b,M,A,T,U,I=this;return _(this,(function(w){switch(w.label){case 0:return i=q.of(this._iid),u=i.dispatcher,c=i.requestQueue,f=new er(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:n,nextEnd:r,nextCount:o},this.filter)),[4,c.send(f)];case 1:return p=w.sent(),m=p.as(tr),v=m.isHugeGap,g=m.prevMessages,y=void 0===g?[]:g,E=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?z((function(){return d(I,void 0,void 0,(function(){return _(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=b,M=this.viewTop,A=this.viewBottom,T=Math.min.apply(Math,l([Number.MAX_SAFE_INTEGER],h(y.map((function(e){return e.createdAt}))),!1)),U=Math.max.apply(Math,l([0],h(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new S({messages:y,source:Q.SYNC_MESSAGE_FILL})),u.dispatch(new S({messages:N,source:Q.SYNC_MESSAGE_FILL})),this._syncRange.extends(T,U),MU&&this._nextFill.start(U)),[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:Q.SYNC_MESSAGE_FILL})];case 5:(c=m.sent()).length>0&&((f=this._syncRange).extends.apply(f,l([],h(c.map((function(e){return e.createdAt}))),!1)),c.length0&&((s=t._syncRange).extends.apply(s,l([],h(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,Q.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(j(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,N((function(){return d(s,void 0,void 0,(function(){var n;return _(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 i.sent(),n=Xn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,N((function(){return d(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,l([],h(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Q.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,l([],h(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Q.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,N((function(){return d(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=Xn.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,N((function(){return d(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,l([],h(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,Q.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,l([],h(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,Q.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,Gn.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=Gn.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),dr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},_r={hidePreviousMessages:!1,allowAutoUnhide:!0},fr=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,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=T.GET,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(I),pr=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 Tt(e,t)}))),r}return e(n,t),n}(w);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(or||(or={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(ur||(ur={})),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"}(cr||(cr={}));var mr=function(n){function r(e,t,r){var s,a,o,u,c=this;return(c=n.call(this,e,t,i.GROUP,r)||this).mutedMemberFilter=or.ALL,c.memberStateFilter=cr.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Mt.ALL,c.order=ur.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:or.ALL,c.memberStateFilter=null!==(a=r.memberStateFilter)&&void 0!==a?a:cr.ALL,c.nicknameStartsWithFilter=null!==(o=r.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=r.order)&&void 0!==u?u:ur.MEMBER_NICKNAME_ALPHABETICAL,c}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&t(or,this.mutedMemberFilter)&&t(cr,this.memberStateFilter)&&(m("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&t(Mt,this.operatorFilter)&&t(ur,this.order)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new fr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(pr),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(ce),vr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(I),gr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r.channel.myMemberState=gt.JOINED,r}return e(n,t),n}(w),yr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,_=e.customType,f=e.operatorUserIds,p=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:_,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:p}),n}return e(n,t),n}(I),Er=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new Kr(e,n),r}return e(n,t),n}(w),Cr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.DELETE,n.path="".concat(L,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(I);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(w);var Nr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.DELETE,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(I);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(w);var br=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=T.PUT,i.path="".concat(U,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(I),Mr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=xr[n.count_preference],r}return e(n,t),n}(w),Sr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=T.PUT,n.path="".concat(L,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(I),Ar=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}(w),Tr=s(s({},et),{scheduledAt:null}),Ur=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl;return r.method=T.POST,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages"),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new B(e,n),r}return e(n,t),n}(w),wr=s(s({},nt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Dr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl;return r.method=T.POST,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages"),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return fe.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Lr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new K(e,n),r}return e(n,t),n}(w),Rr=s(s({},st),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Or=s(s({},at),{scheduledAt:null}),kr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=T.PUT,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes.map((function(e){return fe.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new K(e,n),r}return e(n,t),n}(w),Pr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===le.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=T.PUT,r.path="".concat(ie(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:he.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 de.payloadify(e)})),apple_critical_alert_options:_e.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(I);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new B(e,n),r}e(n,t)}(w);var xr,Hr,Vr,Gr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=T.DELETE,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(I),qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=T.POST,n.path="".concat(ie(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(I);!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"}(xr||(xr={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(Hr||(Hr={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Vr||(Vr={}));var Br,Kr=function(o){function u(e,r){var u,c,d,_,f,p,v,g,y,E,C,N,b,M,S,A,T,U,I=this;return(I=o.call(this,e,r)||this)._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=Vr.UNHIDDEN,I.lastMessage=null,I.messageOffsetTimestamp=0,I.messageSurvivalSeconds=-1,I.myMemberState=gt.NONE,I.myRole=n.NONE,I.myMutedState=Hr.UNMUTED,I.myLastRead=0,I.myCountPreference=xr.ALL,I.myPushTriggerOption=ke.DEFAULT,I.inviter=null,I.invitedAt=0,I.joinedAt=0,I.channelType=i.GROUP,I.isDistinct=null!==(c=r.is_distinct)&&void 0!==c&&c,I.isSuper=null!==(d=r.is_super)&&void 0!==d&&d,I.isBroadcast=null!==(_=r.is_broadcast)&&void 0!==_&&_,I.isExclusive=null!==(f=r.is_exclusive)&&void 0!==f&&f,I.isPublic=null!==(p=r.is_public)&&void 0!==p&&p,I.isDiscoverable=null!==(v=r.is_discoverable)&&void 0!==v?v:I.isPublic,I.isAccessCodeRequired=null!==(g=r.is_access_code_required)&&void 0!==g&&g,I.isPushEnabled=null!==(y=r.is_push_enabled)&&void 0!==y&&y,Array.isArray(r.members)&&(u=I.members).push.apply(u,l([],h(r.members.map((function(e){return new Tt(I._iid,e)}))),!1)),I.memberCount=null!==(E=r.member_count)&&void 0!==E?E:0,I.joinedMemberCount=null!==(C=r.joined_member_count)&&void 0!==C?C:0,I.hiddenState=t(Vr,r.hidden_state)?r.hidden_state:Vr.UNHIDDEN,I.messageOffsetTimestamp=null!==(N=r.ts_message_offset)&&void 0!==N?N:0,I.messageSurvivalSeconds=null!==(b=r.message_survival_seconds)&&void 0!==b?b:-1,I.lastMessage=r.last_message?ae(I._iid,s({channel_type:I.channelType},r.last_message)):null,r.read_receipt&&Object.keys(r.read_receipt).forEach((function(e){m("number",r.read_receipt[e])&&I._updateUnreadMemberState(e,r.read_receipt[e])})),r.delivery_receipt&&Object.keys(r.delivery_receipt).forEach((function(e){m("number",r.delivery_receipt[e])&&I._updateUndeliveredMemberState(e,r.delivery_receipt[e])})),I.myMemberState=t(gt,r.member_state)?r.member_state:gt.NONE,I.myRole=t(n,r.my_role)?r.my_role:n.NONE,t(Hr,r.is_muted)?I.myMutedState=r.is_muted:m("boolean",r.is_muted)?I.myMutedState=r.is_muted?Hr.MUTED:Hr.UNMUTED:I.myMutedState=Hr.UNMUTED,I.myCountPreference=t(xr,r.count_preference)?r.count_preference:xr.ALL,I.myPushTriggerOption=t(ke,r.push_trigger_option)?r.push_trigger_option:ke.ALL,I.myLastRead=null!==(M=r.user_last_read)&&void 0!==M?M:0,I.inviter=r.inviter?new a(I._iid,r.inviter):null,I.invitedAt=null!==(S=r.invited_at)&&void 0!==S?S:0,I.joinedAt=null!==(A=r.joined_ts)&&void 0!==A?A:0,I._updateUnreadCount(null!==(T=r.unread_message_count)&&void 0!==T?T:0,null!==(U=r.unread_mention_count)&&void 0!==U?U:0),I}return e(u,o),Object.defineProperty(u.prototype,"isHidden",{get:function(){return this.hiddenState!==Vr.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=h(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(u.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=f(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=h(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}),u.payloadify=function(e){return e?r(s(s({},o.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 Tt.payloadify(e)})),last_message:pe(e.lastMessage),inviter:e.inviter?a.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},u.prototype._updateUnreadCount=function(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===xr.ALL||this.myCountPreference===xr.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=q.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===xr.ALL||this.myCountPreference===xr.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},u.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},u.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},u.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},u.prototype.isReadMessage=function(e){var t=q.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},u.prototype.serialize=function(){var e=this;return P(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},u.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new hr(this._iid,s({channel:this},e))},u.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new mr(this._iid,this.url,e)},u.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===gt.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)}},u.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},u.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof A&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=q.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=f(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===gt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},u.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=q.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},u.prototype.refresh=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new Yt({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(Jt).channel,n.dispatch(new Bt({channels:[i],source:xt.REQUEST_CHANNEL})),[2,i]}}))}))},u.prototype.freeze=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,o.prototype.freeze.call(this)];case 1:return e.sent(),q.of(this._iid).dispatcher.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},u.prototype.unfreeze=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,o.prototype.unfreeze.call(this)];case 1:return e.sent(),q.of(this._iid).dispatcher.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},u.prototype.updateChannel=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=s(s({},dr),e),Y(function(e){return m("string",e.coverUrl,!0)&&(g(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)&&p("string",e.operatorUserIds,!0)&&m("number",e.messageSurvivalSeconds,!0)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new yr(s({channelUrl:this.url},e)),[4,r.send(i)];case 1:return a=u.sent(),o=a.as(Er).channel,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_UPDATED})),[2,o]}}))}))},u.prototype.invite=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(e.every((function(e){return e instanceof a}))).throw(H.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},u.prototype.inviteWithUserIds=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(p("string",e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new yn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(En).channel,n.dispatch(new Bt({channels:[a],source:xt.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},u.prototype.join=function(e){return void 0===e&&(e=null),d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(m("string",e)||null===e).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new fn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(pn).channel).myMemberState=gt.JOINED,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},u.prototype.leave=function(e){return void 0===e&&(e=!1),d(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new vn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},u.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(m("string",e)||null===e).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new vr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(gr).channel).myMemberState=gt.JOINED,n.dispatch(new Bt({channels:[o],source:xt.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},u.prototype.declineInvitation=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(bn).channel).myMemberState=gt.NONE,[2,i]}}))}))},u.prototype.sendUserMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype.sendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendUserMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype._autoResendUserMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.sendFileMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype.sendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype._autoResendFileMessage=function(e){var t=this,n=new me,r=q.of(this._iid).dispatcher,s=Oe.of(this._iid);return o.prototype._autoResendFileMessage.call(this,e).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var i=Gn.of(t._iid);s.completeCurrentAndProcessNextAutoResend(e),t.lastMessage=e,i.handlers.map((function(e){return e.onChannelChanged(t)})),r.dispatch(new Bt({channels:[t],source:xt.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},u.prototype.deleteMessage=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,o.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&q.of(this._iid).dispatcher.dispatch(new b({reqId:e.reqId,source:Q.EVENT_MESSAGE_DELETED})),[2]}}))}))},u.prototype.hide=function(e){return d(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return e=s(s({},_r),e),Y(function(e){return m("boolean",e.hidePreviousMessages)&&m("boolean",e.allowAutoUnhide)}(e)).throw(H.invalidParameters),t=q.of(this._iid),n=t.dispatcher,r=t.sdkState,i=t.requestQueue,a=new wn(s({channelUrl:this.url,userId:r.userId},e)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(Dn).messageOffsetTimestamp,this.hiddenState=e.allowAutoUnhide?Vr.HIDDEN_ALLOW_AUTO_UNHIDE:Vr.HIDDEN_PREVENT_AUTO_UNHIDE,e.hidePreviousMessages&&this._updateUnreadCount(0,0),u&&(this.messageOffsetTimestamp=u),n.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},u.prototype.unhide=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Nr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=Vr.UNHIDDEN,t.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},u.prototype.delete=function(){return d(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=q.of(this._iid).requestQueue,t=new Cr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.markAsRead=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Sn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(An).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Gn.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_READ})),[2]}}))}))},u.prototype.markAsDelivered=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Tn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},u.prototype.startTyping=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=q.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new Rn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},u.prototype.endTyping=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=q.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]}))}))},u.prototype.createScheduledUserMessage=function(e){return d(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return e=s(s({},Tr),e),Y(function(e){return tt(e)&&m("number",e.scheduledAt,!0)}(e)).throw(H.invalidParameters),t=q.of(this._iid).requestQueue,n=new Ur(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e)),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Ir).message]}}))}))},u.prototype.updateScheduledUserMessage=function(e,t){return d(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=s(s({},Or),t),Y(function(e){return ot(e)&&m("number",e.scheduledAt,!0)}(t)).throw(H.invalidParameters),n=q.of(this._iid).requestQueue,r=new Pr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t)),[4,n.send(r)];case 1:return i=a.sent(),[2,i.as(Ir).message]}}))}))},u.prototype.createScheduledFileMessage=function(e){return d(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=s(s({},wr),e),Y(function(e){return rt(e)&&m("number",e.scheduledAt)&&(g(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(H.invalidParameters),g(e.file)?[4,this._uploadFileAndUpdateParams(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return t=new Dr(s(s({reqId:this._generateRequestId(),channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth})),[4,q.of(this._iid).requestQueue.send(t)];case 3:return n=r.sent(),[2,n.as(Lr).message]}}))}))},u.prototype.updateScheduledFileMessage=function(e,t){return d(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return t=s(s({},Rr),t),Y(function(e){return it(e)&&m("number",e.scheduledAt,!0)&&(g(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})))}(t)).throw(H.invalidParameters),g(t.file)?[4,this._uploadFileAndUpdateParams(t)]:[3,2];case 1:i.sent(),i.label=2;case 2:return n=new kr(s(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},t),{fileUrl:t.fileUrl,requireAuth:t.requireAuth})),[4,q.of(this._iid).requestQueue.send(n)];case 3:return r=i.sent(),[2,r.as(Fr).message]}}))}))},u.prototype.cancelScheduledMessage=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Gr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,q.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.sendScheduledMessageNow=function(e){return d(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,q.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},u.prototype.getMyPushTriggerOption=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(Fe).pushTriggerOption]}}))}))},u.prototype.setMyPushTriggerOption=function(e){return d(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(t(ke,e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.sdkState,s=n.requestQueue,i=new He({userId:r.userId,pushTriggerOption:e}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(xe).pushTriggerOption]}}))}))},u.prototype.setMyCountPreference=function(e){return d(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(t(xr,e)).throw(H.invalidParameters),n=q.of(this._iid),r=n.dispatcher,s=n.sdkState,i=n.requestQueue,a=new br({channelUrl:this.url,userId:s.userId,countPreference:e}),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(Mr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},u.prototype.resetMyHistory=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=q.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Sr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Ar).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Bt({channels:[this],source:xt.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},u.prototype._uploadFileAndUpdateParams=function(e){return d(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return g(e.file)?(t=q.of(this._iid).requestQueue,n=new ge({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(ve),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},u}(ut),jr={},zr=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadata=null,this._iid=t;var r,s=q.of(this._iid),i=s.sdkState,a=s.logger;this._metadataKey=(r=i.userId,"sendbird:".concat(r,"@groupchannel/sync.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(i.userId);this._sync=new Qn(o,(function(){return d(n,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(o){switch(o.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(o.sent(),a.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];o.label=2;case 2:return o.trys.push([2,5,,8]),[4,Gn.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:Ne.CHRONOLOGICAL},100,xt.SYNC_CHANNEL_BACKGROUND)];case 3:return t=o.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,l([],h(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,a.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return(s=o.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:o.sent(),o.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",o.label=10;case 10:return[2,e]}}))}))}))}return e.of=function(t){if(!jr[t]){var n=jr[t]=new e({_iid:t});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)n.resume();else n.pause()}))}return jr[t]},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 d(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,q.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Hn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,q.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.resume=function(){var e,t;q.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(){q.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e}(),Qr={},Wr=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=q.of(this._iid).sdkState;this._metadataKey=(r=s.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var i=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(s.userId);this._sync=new Qn(i,(function(){return d(n,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,8]),[4,Gn.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},xt.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=i.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return i.sent(),[3,8];case 5:return(s=i.sent())instanceof H&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:i.sent(),i.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return e.of=function(t){if(!Qr[t]){var n=Qr[t]=new e({_iid:t});q.of(t).dispatcher.on((function(e){if(e instanceof te)if(e.stateType===ne.CONNECTED)n.resume();else n.pause()}))}return Qr[t]},e.prototype.loadMetadata=function(){return d(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=q.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,q.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 d(this,void 0,void 0,(function(){return _(this,(function(e){return q.of(this._iid).cacheContext.preference.remove(this._metadataKey),[2]}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Yr=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._iid=e,this._key="gcc-".concat(Z()),this.filter=null!=n?n:new wt,this.order=null!=r?r:Ne.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Me;var a=q.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&zr.of(e).resume(),Wr.of(e).resume(),Gn.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=f(e),c=u.next();!c.done;c=u.next()){var l=c.value,h=rr(this.channels,l,this.order),p=h.place;if(h.contains)switch(o.push(l),t){case xt.EVENT_CHANNEL_UPDATED:case xt.EVENT_MESSAGE_RECEIVED:this.channels.splice(p,1);var m=rr(this.channels,l,this.order).place;this.channels.splice(m,0,l);break;default:this.channels[p]=l}else if(p===this.channels.length){var v=zr.of(this._iid);(n||v.completed)&&(a.push(l),this.channels.push(l))}else a.push(l),this.channels.splice(p,0,l)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}qt(t)&&z((function(){return d(i,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),a.length>0&&this._handler.onChannelsAdded(e,a),o.length>0&&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=f(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return qt(t)&&i.length>0&&z((function(){return d(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new Wn(t),this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,Gn.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return d(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return[4,Gn.of(this._iid).getMyGroupChannels(this._token,s(s({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,[2,t]}}))}))},e.prototype.loadMore=function(){return d(this,void 0,void 0,(function(){var e,t=this;return _(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,N((function(){return d(t,void 0,void 0,(function(){return _(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,N((function(){return d(t,void 0,void 0,(function(){return _(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,xt.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){Gn.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Jr=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,c=e.channelNameContainsFilter,l=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,_=e.superChannelFilter,f=e.metadataOrderKeyFilter,p=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=T.GET,n.path=L,n.params=r({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:yt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:_,metadata_order_key:f,metadata_key:p,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(I),Xr=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 Kr(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(w);!function(e){e.ALL="all",e.JOINED="joined"}(Br||(Br={}));var Zr=function(n){function r(e,t){var r,s,i,a,o,u,c,l,h,d,_,f,p,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.nicknameContainsFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=Br.ALL,v.superChannelFilter=Ct.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=Ve.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!==(c=t.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=t.membershipFilter)&&void 0!==l?l:Br.ALL,v.superChannelFilter=null!==(h=t.superChannelFilter)&&void 0!==h?h:Ct.ALL,v.metadataKey=null!==(d=t.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(_=t.metadataValues)&&void 0!==_?_:null,v.metadataOrderKeyFilter=null!==(f=t.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(p=t.metadataValueStartsWith)&&void 0!==p?p:null,v.order=null!==(m=t.order)&&void 0!==m?m:Ve.CHRONOLOGICAL,v}return e(r,n),r.prototype._validate=function(){return n.prototype._validate.call(this)&&m("boolean",this.includeEmpty)&&m("boolean",this.includeFrozen)&&m("boolean",this.includeMetaData)&&m("string",this.channelNameContainsFilter,!0)&&p("string",this.channelUrlsFilter,!0)&&p("string",this.customTypesFilter,!0)&&m("string",this.customTypeStartsWithFilter,!0)&&t(Br,this.membershipFilter)&&t(Ct,this.superChannelFilter)&&t(Ve,this.order)&&m("string",this.metadataOrderKeyFilter,!0)&&m("string",this.metadataKey,!0)&&p("string",this.metadataValues,!0)&&m("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=q.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new Jr(s(s({},this),{token:this._token})),[4,n.send(i)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(Xr),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,r.dispatch(new Bt({channels:u,source:xt.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),$r=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=ye,e.onUserLeft=ye,e.onUserReceivedInvitation=ye,e.onUserDeclinedInvitation=ye,e.onChannelHidden=ye,e.onUnreadMemberStatusUpdated=ye,e.onUndeliveredMemberStatusUpdated=ye,e.onTypingStatusUpdated=ye,e}return e(n,t),n}(vt)),es=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,c=e.messageTypeFilter,l=e.scheduledStatus;return(n=t.call(this)||this).method=T.GET,n.path="".concat(R),n.params=r({limit:i,reverse:o,channel_url:u,order:a,status:l}),s&&(n.params.token=s),c&&(n.params.message_type_filter=c),n}return e(n,t),n}(I),ts=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 ae(e,t)})),r}return e(n,t),n}(w),ns=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)&&m("string",this.channelUrl,!0)&&(t(Ge,this.order)||null===this.order)&&m("boolean",this.reverse)&&(p(E,this.scheduledStatus)||null===this.scheduledStatus)&&t(y,this.messageTypeFilter)},r.prototype.next=function(){return d(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new es(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(ts),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw H.queryInProgress;case 4:return[3,6];case 5:throw H.invalidParameters;case 6:return[2]}}))}))},r}(x),rs=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,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new Gn(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Yr(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Zr(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ns(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(m("string",e)&&t instanceof $r).throw(H.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(m("string",e)).throw(H.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 d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(m("string",e)).throw(H.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(m("string",e)).throw(H.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t=s(s({},Ot),t),Y(m("string",e)&&kt(t)).throw(H.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return d(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t=s(s({},Ot),t),Y(m("number",e)&&kt(t)).throw(H.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Ft),e),Y(Pt(e)).throw(H.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(e){return d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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 d(this,void 0,void 0,(function(){return _(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={}),d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return e=s(s({},Lt),e),Y(Rt(e)).throw(H.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,i,a){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=""),void 0===a&&(a=""),d(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=s(s({},Lt),{invitedUserIds:e,isDistinct:t,name:n,data:i,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return d(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){return Y(p("string",e)).throw(H.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return d(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return Y(m("string",e)).throw(H.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(Ee);export{xr as CountPreference,Kr as GroupChannel,Yr as GroupChannelCollection,Wn as GroupChannelEventContext,xt as GroupChannelEventSource,wt as GroupChannelFilter,$r as GroupChannelHandler,xn as GroupChannelListQuery,rs as GroupChannelModule,At as GroupChannelSearchField,bt as HiddenChannelFilter,Vr as HiddenState,Tt as Member,ur as MemberListOrder,mr as MemberListQuery,gt as MemberState,cr as MemberStateFilter,Br as MembershipFilter,hr as MessageCollection,lr as MessageCollectionInitHandler,zn as MessageCollectionInitPolicy,Yn as MessageEventContext,Hr as MutedState,Et as MyMemberStateFilter,Mt as OperatorFilter,yt as PublicChannelFilter,Zr as PublicGroupChannelListQuery,St as QueryType,Ut as ReadStatus,Ct as SuperChannelFilter,Nt as UnreadChannelFilter}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index d229671..5d5ef9c 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -1364,7 +1364,7 @@ export declare interface GroupChannelCollectionEventHandler { onChannelsDeleted: (context: GroupChannelEventContext, channelUrls: string[]) => void; } -declare interface GroupChannelCollectionParams { +export declare interface GroupChannelCollectionParams { filter?: GroupChannelFilter; order?: GroupChannelListOrder; limit?: number; @@ -1486,7 +1486,7 @@ export declare class GroupChannelListQuery extends BaseListQuery { next(): Promise; } -declare interface GroupChannelListQueryParams extends BaseListQueryParams, GroupChannelListParams {} +export declare interface GroupChannelListQueryParams extends BaseListQueryParams, GroupChannelListParams {} export declare class GroupChannelModule extends Module { name: 'groupChannel'; @@ -1601,7 +1601,7 @@ export declare class PublicGroupChannelListQuery extends BaseListQuery { next(): Promise; } -declare interface PublicGroupChannelListQueryParams extends BaseListQueryParams { +export declare interface PublicGroupChannelListQueryParams extends BaseListQueryParams { includeEmpty?: boolean; includeFrozen?: boolean; includeMetaData?: boolean; diff --git a/message.js b/message.js index 3b69b97..d6ff4a2 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{aR as AdminMessage,aa as AppleCriticalAlertOptions,av as BaseMessage,Y as FileMessage,a7 as MentionType,a8 as MessageMetaArray,G as MessageModule,an as MessageRequestHandler,aV as MessageSearchOrder,M as MessageSearchQuery,O as MessageType,N as MessageTypeFilter,aW as OGImage,aX as OGMetaData,aj as PreviousMessageListQuery,a9 as PushNotificationDeliveryOption,aY as Reaction,ah as ReactionEvent,aZ as ReactionEventOperation,T as ReplyType,ak as Sender,a0 as SendingStatus,a_ as ThreadInfo,aS as ThreadInfoUpdateEvent,aM as Thumbnail,X as UserMessage}from"./__bundle-e580e568.js"; +export{aR as AdminMessage,aa as AppleCriticalAlertOptions,av as BaseMessage,Y as FileMessage,a7 as MentionType,a8 as MessageMetaArray,G as MessageModule,an as MessageRequestHandler,aV as MessageSearchOrder,M as MessageSearchQuery,O as MessageType,N as MessageTypeFilter,aW as OGImage,aX as OGMetaData,aj as PreviousMessageListQuery,a9 as PushNotificationDeliveryOption,aY as Reaction,ah as ReactionEvent,aZ as ReactionEventOperation,T as ReplyType,ak as Sender,a0 as SendingStatus,a_ as ThreadInfo,aS as ThreadInfoUpdateEvent,aM as Thumbnail,X as UserMessage}from"./__bundle-26bafa9e.js"; diff --git a/openChannel.js b/openChannel.js index 872dea9..4fbcca2 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as n,b as e,c as t,I as r,l as a,a as i,i as s,A as o,aT as u,aU as c,f as l,h,e as d,ae as p,U as f,W as C,a2 as v,a3 as _,o as y,s as m,am as g,t as U,J as E,aG as w,u as T,S as N,g as H,ac as M,V as I,aF as O,Z as b,n as D,B as x,aQ as A}from"./__bundle-e580e568.js";import{U as P,g as L,h as R,k,j as F,l as S,m as q,D as Q,n as z,o as K,p as G,a as W}from"./__bundle-fecd47ae.js";import{a as B,O as j,C as X,M as Z,T as V,R as J,U as Y,A as $,B as nn}from"./__bundle-d77a472f.js";var en=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),tn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},rn=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),an=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new gn(n,t),r}return n(t,e),t}(h),sn=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 gn(n,t),r}n(t,e)}(h);var on=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),un=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",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}(C),cn=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),ln=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}(C),hn={},dn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(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}}}})),hn[n]=this}return n.of=function(n){return hn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new gn(e._iid,gn.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,H,M,I,O,b,D,x,A,W,nn,en,tn,rn,an,sn,on,cn,hn,dn,pn,fn,Cn,vn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,Mn,In,On,bn,Dn,xn,An,Pn,Ln=this;return t(this,(function(Rn){switch(Rn.label){case 0:switch(Rn.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(G):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==E.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Rn.sent(),U((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]}))}))})),Rn.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(Y)),s?(o=s.message).channelType!==E.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=Rn.sent(),U((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(u.url)&&r.onMessageUpdated(u,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]}))}))})),Rn.label=6;case 6:return[3,50];case 7:return c=n.as(Q),I=c.channelUrl,p=c.channelType,l=c.messageId,p!==E.OPEN?[3,9]:[4,this.getChannel(I,!0)];case 8:h=Rn.sent(),U((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(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=9;case 9:return[3,50];case 10:return d=n.as(J),I=d.channelUrl,p=d.channelType,f=d.event,p!==E.OPEN?[3,12]:[4,this.getChannel(I,!0)];case 11:C=Rn.sent(),U((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.onReactionUpdated(C,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=12;case 12:return[3,50];case 13:return(v=n.as(V).event).channelType!==E.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Rn.sent(),U((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.onThreadInfoUpdated(_,v)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=15;case 15:return[3,50];case 16:m=n.as(Z).openChannelMemberCounts,T=[],Rn.label=17;case 17:Rn.trys.push([17,22,23,24]),N=y(m),H=N.next(),Rn.label=18;case 18:return H.done?[3,21]:(M=H.value,I=M.channelUrl,an=M.participantCount,O=M.updatedAt,[4,this.getChannelFromCache(I)]);case 19:(b=Rn.sent())&&b._updateParticipantCount(an,O)&&T.push(b),Rn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return D=Rn.sent(),An={error:D},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:Rn.sent(),U((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(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=26;case 26:return[3,50];case 27:if(!(x=n.as(X).event).isOpenChannelEvent)return[3,49];switch(x.category){case B.CHANNEL_ENTER:return[3,28];case B.CHANNEL_EXIT:return[3,30];case B.CHANNEL_OPERATOR_UPDATE:return[3,32];case B.USER_CHANNEL_MUTE:case B.USER_CHANNEL_UNMUTE:return[3,34];case B.USER_CHANNEL_BAN:case B.USER_CHANNEL_UNBAN:return[3,36];case B.CHANNEL_FREEZE:case B.CHANNEL_UNFREEZE:return[3,38];case B.CHANNEL_DELETED:return[3,40];case B.CHANNEL_PROP_CHANGED:return[3,43];case B.CHANNEL_META_DATA_CHANGED:return[3,45];case B.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(x.channelUrl,!0)];case 29:return A=Rn.sent(),W=n.as(un),an=W.participantCount,nn=W.user,en=A._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(x.channelUrl,!0)];case 31:return tn=Rn.sent(),rn=n.as(ln),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(x.channelUrl,!0)];case 33:return cn=Rn.sent(),hn=n.as(j).operators,cn.operators=hn,this.upsertChannelsToCache([cn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(cn,hn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(x.channelUrl,!0)];case 35:return dn=Rn.sent(),pn=x.category===B.USER_CHANNEL_MUTE,fn=n.as(pn?S:q).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(x.channelUrl,!0)];case 37:return Cn=Rn.sent(),vn=x.category===B.USER_CHANNEL_BAN,_n=n.as(vn?k:F).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){vn?n.onUserBanned(Cn,_n):n.onUserUnbanned(Cn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(x.channelUrl,!0)];case 39:return yn=Rn.sent(),mn=n.as(R).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(x.channelUrl,!0)];case 41:return gn=Rn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(x.channelUrl,!0)];case 44:return Un=Rn.sent(),U((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(x.channelUrl,!0)];case 46:return En=Rn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,x.ts),Nn&&En._upsertCachedMetaData(Nn,x.ts),Hn&&En._removeFromCachedMetaData(Hn,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(x.channelUrl,!0)];case 48:return Mn=Rn.sent(),In=n.as(P),On=In.created,bn=In.updated,Dn=In.deleted,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(Mn,On),bn&&n.onMetaCounterUpdated(Mn,bn),Dn&&n.onMetaCounterDeleted(Mn,Dn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(xn=Rn.sent(),g(xn))throw xn;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 rn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(an).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;return t(this,(function(t){switch(t.label){case 0:return n=H(H({},tn),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)}(n)).throw(N.invalidParameters),e=new sn(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),o=r.as(an).channel,this.upsertChannelsToCache([o]),[2,o]}}))}))},n}(),pn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},fn=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),Cn=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 f(n,e)})),r}return n(t,e),t}(h),vn=function(r){function a(n,e,t){return r.call(this,n,e,E.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 fn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Cn),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}(M),_n=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),yn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}return n(t,e),t}(h),mn=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 gn=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=E.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(H(H({},W.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return O(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 vn(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,dn.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 on({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(un),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.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 cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(ln),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.of(this._iid).setExitedToCache(this),b.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;return t(this,(function(t){switch(t.label){case 0:return n=H(H({},pn),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)}(n)).throw(N.invalidParameters),e=I.of(this._iid).requestQueue,r=new _n(H({channelUrl:this.url},n)),[4,e.send(r)];case 1:return o=t.sent(),u=o.as(yn).channel,[4,dn.of(this._iid).upsertChannelsToCache([u])];case 2:return t.sent(),[2,u]}}))}))},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=H(H({},pn),{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 mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,dn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o}(W),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}(nn)),En=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),wn=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 gn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Tn=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 En(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(wn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,dn.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),Nn=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 dn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Tn(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=H({},tn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{gn as OpenChannel,Un as OpenChannelHandler,Tn as OpenChannelListQuery,Nn as OpenChannelModule,vn as ParticipantListQuery}; +import{_ as n,b as e,c as t,I as r,l as a,a as i,i as s,A as o,aT as u,aU as c,f as l,h,e as d,ae as p,U as f,W as C,a2 as v,a3 as _,o as y,s as m,am as g,t as U,J as E,aG as w,u as T,S as N,g as H,ac as M,V as b,aF as I,Z as O,n as D,B as x,aQ as A}from"./__bundle-26bafa9e.js";import{U as P,g as L,h as R,k,j as F,l as S,m as q,D as Q,n as z,o as K,p as G,a as W}from"./__bundle-f79aa272.js";import{a as B,O as j,C as X,M as Z,T as V,R as J,U as Y,A as $,B as nn}from"./__bundle-9ac5dba1.js";var en=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),tn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},rn=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),an=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new gn(n,t),r}return n(t,e),t}(h),sn=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 gn(n,t),r}n(t,e)}(h);var on=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),un=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",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}(C),cn=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),ln=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}(C),hn={},dn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(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}}}})),hn[n]=this}return n.of=function(n){return hn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new gn(e._iid,gn.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,H,M,b,I,O,D,x,A,W,nn,en,tn,rn,an,sn,on,cn,hn,dn,pn,fn,Cn,vn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,Mn,bn,In,On,Dn,xn,An,Pn,Ln=this;return t(this,(function(Rn){switch(Rn.label){case 0:switch(Rn.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(G):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==E.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Rn.sent(),U((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]}))}))})),Rn.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(Y)),s?(o=s.message).channelType!==E.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=Rn.sent(),U((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(u.url)&&r.onMessageUpdated(u,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]}))}))})),Rn.label=6;case 6:return[3,50];case 7:return c=n.as(Q),b=c.channelUrl,p=c.channelType,l=c.messageId,p!==E.OPEN?[3,9]:[4,this.getChannel(b,!0)];case 8:h=Rn.sent(),U((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(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=9;case 9:return[3,50];case 10:return d=n.as(J),b=d.channelUrl,p=d.channelType,f=d.event,p!==E.OPEN?[3,12]:[4,this.getChannel(b,!0)];case 11:C=Rn.sent(),U((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.onReactionUpdated(C,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=12;case 12:return[3,50];case 13:return(v=n.as(V).event).channelType!==E.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Rn.sent(),U((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.onThreadInfoUpdated(_,v)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=15;case 15:return[3,50];case 16:m=n.as(Z).openChannelMemberCounts,T=[],Rn.label=17;case 17:Rn.trys.push([17,22,23,24]),N=y(m),H=N.next(),Rn.label=18;case 18:return H.done?[3,21]:(M=H.value,b=M.channelUrl,an=M.participantCount,I=M.updatedAt,[4,this.getChannelFromCache(b)]);case 19:(O=Rn.sent())&&O._updateParticipantCount(an,I)&&T.push(O),Rn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return D=Rn.sent(),An={error:D},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:Rn.sent(),U((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(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=26;case 26:return[3,50];case 27:if(!(x=n.as(X).event).isOpenChannelEvent)return[3,49];switch(x.category){case B.CHANNEL_ENTER:return[3,28];case B.CHANNEL_EXIT:return[3,30];case B.CHANNEL_OPERATOR_UPDATE:return[3,32];case B.USER_CHANNEL_MUTE:case B.USER_CHANNEL_UNMUTE:return[3,34];case B.USER_CHANNEL_BAN:case B.USER_CHANNEL_UNBAN:return[3,36];case B.CHANNEL_FREEZE:case B.CHANNEL_UNFREEZE:return[3,38];case B.CHANNEL_DELETED:return[3,40];case B.CHANNEL_PROP_CHANGED:return[3,43];case B.CHANNEL_META_DATA_CHANGED:return[3,45];case B.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(x.channelUrl,!0)];case 29:return A=Rn.sent(),W=n.as(un),an=W.participantCount,nn=W.user,en=A._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(x.channelUrl,!0)];case 31:return tn=Rn.sent(),rn=n.as(ln),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(x.channelUrl,!0)];case 33:return cn=Rn.sent(),hn=n.as(j).operators,cn.operators=hn,this.upsertChannelsToCache([cn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(cn,hn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(x.channelUrl,!0)];case 35:return dn=Rn.sent(),pn=x.category===B.USER_CHANNEL_MUTE,fn=n.as(pn?S:q).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(x.channelUrl,!0)];case 37:return Cn=Rn.sent(),vn=x.category===B.USER_CHANNEL_BAN,_n=n.as(vn?k:F).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){vn?n.onUserBanned(Cn,_n):n.onUserUnbanned(Cn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(x.channelUrl,!0)];case 39:return yn=Rn.sent(),mn=n.as(R).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(x.channelUrl,!0)];case 41:return gn=Rn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(x.channelUrl,!0)];case 44:return Un=Rn.sent(),U((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(x.channelUrl,!0)];case 46:return En=Rn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,x.ts),Nn&&En._upsertCachedMetaData(Nn,x.ts),Hn&&En._removeFromCachedMetaData(Hn,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(x.channelUrl,!0)];case 48:return Mn=Rn.sent(),bn=n.as(P),In=bn.created,On=bn.updated,Dn=bn.deleted,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){In&&n.onMetaCounterCreated(Mn,In),On&&n.onMetaCounterUpdated(Mn,On),Dn&&n.onMetaCounterDeleted(Mn,Dn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(xn=Rn.sent(),g(xn))throw xn;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 rn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(an).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;return t(this,(function(t){switch(t.label){case 0:return n=H(H({},tn),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)}(n)).throw(N.invalidParameters),e=new sn(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),o=r.as(an).channel,this.upsertChannelsToCache([o]),[2,o]}}))}))},n}(),pn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},fn=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),Cn=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 f(n,e)})),r}return n(t,e),t}(h),vn=function(r){function a(n,e,t){return r.call(this,n,e,E.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 fn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Cn),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}(M),_n=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),yn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}return n(t,e),t}(h),mn=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 gn=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=E.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(H(H({},W.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 vn(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,dn.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 on({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(un),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.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 cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(ln),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.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;return t(this,(function(t){switch(t.label){case 0:return n=H(H({},pn),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)}(n)).throw(N.invalidParameters),e=b.of(this._iid).requestQueue,r=new _n(H({channelUrl:this.url},n)),[4,e.send(r)];case 1:return o=t.sent(),u=o.as(yn).channel,[4,dn.of(this._iid).upsertChannelsToCache([u])];case 2:return t.sent(),[2,u]}}))}))},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=H(H({},pn),{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 mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,dn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o}(W),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}(nn)),En=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),wn=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 gn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Tn=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 En(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(wn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,dn.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),Nn=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 dn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Tn(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=H({},tn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{gn as OpenChannel,Un as OpenChannelHandler,Tn as OpenChannelListQuery,Nn as OpenChannelModule,vn as ParticipantListQuery}; diff --git a/package.json b/package.json index 8da3ff2..d36c2eb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.1", + "version": "4.0.2", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/sendbird.js b/sendbird.js index 099d238..35004e5 100644 --- a/sendbird.js +++ b/sendbird.js @@ -1 +1 @@ -import{i as e,a as t,n,_ as r,I as i,E as s,b as u,c as h,A as f,d as p,e as v,f as _,U as m,g as y,h as g,j as I,k as w,l as E,B as k,S as N,V as T,m as x,o as A,p as D,D as F,q as j,v as H,r as V,C as W,u as Q,M as G,s as Y,W as X,t as Z,w as $,x as ee,y as te,z as ne,F as re,G as ie,H as se}from"./__bundle-e580e568.js";export{J as ChannelType,C as ConnectionState,L as LogLevel,P as Plugin,R as Role,z as SendbirdChatOptions,S as SendbirdError,U as User,K as UserOnlineState}from"./__bundle-e580e568.js";import{N as oe,a as ae,g as ue,G as ce,b as le,c as he,d as de,M as fe,e as pe,f as ve,P as _e,A as me,U as ye,h as be,i as ge,D as Ie,j as we,k as Ee,l as ke,m as Ne,n as Oe,S as Te,o as Se,p as xe,q as Ce}from"./__bundle-c65b6359.js";export{q as PushTemplate,l as PushTokenRegistrationState,P as PushTokenType,o as PushTriggerOption}from"./__bundle-c65b6359.js";export{B as BannedUserListQuery,a as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,b as RestrictedUser,c as RestrictionInfo,d as RestrictionType}from"./__bundle-fecd47ae.js";var Re={profileImage:null,profileUrl:null,nickname:null},Le=function(){this.onSessionExpired=n,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=n,this.onSessionRefreshed=n,this.onSessionClosed=n},Pe=function(){this.onConnected=n,this.onReconnectStarted=n,this.onReconnectSucceeded=n,this.onReconnectFailed=n,this.onDisconnected=n},Ae=function(){this.onFriendsDiscovered=n,this.onTotalUnreadMessageCountUpdated=n};!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(i);var De=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._pauseDelayTimer=null,t._currentState="visible",t}return r(t,e),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener},enumerable:!1,configurable:!0}),t.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},t.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},t.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},t}(s),Me=function(){function e(e){var t=e.logger,n=e.connectionDelegate;this.logger=t,this.connectionDelegate=n,this._onlineWorker=this._onlineWorker.bind(this),this._offlineWorker=this._offlineWorker.bind(this)}return Object.defineProperty(e.prototype,"isAvailable",{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._onlineWorker=function(){this.connectionDelegate.reconnect()},e.prototype._offlineWorker=function(){this.connectionDelegate.disconnect()},e.prototype.start=function(){this.isAvailable&&(window.addEventListener("online",this._onlineWorker),window.addEventListener("offline",this._offlineWorker))},e.prototype.stop=function(){this.isAvailable&&(window.removeEventListener("online",this._onlineWorker,!1),window.removeEventListener("offline",this._offlineWorker,!1))},e.prototype.isOnline=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){return this.isAvailable?[2,navigator.onLine]:[2,new Promise((function(e,t){fetch("https://www.google.com",{method:f.GET}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Ue=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,o=void 0===s?null:s,a=t.profileImage,u=void 0===a?null:a,c=t.preferredLanguages,l=void 0===c?null:c,h=e.call(this)||this;return h.method=f.PUT,h.path="".concat(p,"/").concat(encodeURIComponent(n)),h.params=v({nickname:i,profile_url:o,profile_file:u,preferred_languages:l}),h}return r(t,e),t}(_),qe=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new m(t,y({},n)),r}return r(t,e),t}(g),Be=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Fe=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Ke=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r}r(t,e)}(g);var je=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r}r(t,e)}(g);var He=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.DELETE,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Ve=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.DELETE,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var We=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=f.GET,o.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return r(t,e),t}(_),ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(g),Qe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(_),Ge=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Ye=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(_),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Xe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(_),Ze=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),$e=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=f.PUT,c.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return r(t,e),t}(_),et=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),tt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(_),nt=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),rt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=f.PUT,o.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return r(t,e),t}(_),it=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),st=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,n),r}r(t,e)}(g);var ot=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var at=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(_),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),ct=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(_),lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),ht=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.GET,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(_),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new m(t,e)})),updatedUsers:n.updated.map((function(e){return new m(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(g),ft=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(_),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(g),vt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var _t=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(_),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r}return r(t,e),t}(g),yt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var bt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(_),gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(g),It=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var wt,Et=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},kt=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 Et(e)})):[]},Nt=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 kt(e)})):[]},Ot=function(e){function t(){var t=e.call(this)||this;return t.method=f.GET,t.path=I,t}return r(t,e),t}(_),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Nt(n),r}return r(t,e),t}(g),St=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(I,"/").concat(n),r}return r(t,e),t}(_),xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new kt(n),r}return r(t,e),t}(g),Ct=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(w,"/").concat(n),r}return r(t,e),t}(_),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Et(n),r}return r(t,e),t}(g),Lt=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=f.GET,u.path=p,u.params=v({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return r(t,e),t}(_),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),At=function(e){function n(t,n){var r,i,s,o=this;return(o=e.call(this,t,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 r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&E("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Lt(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Pt),i=r.users,s=r.next,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]}}))}))},n}(k),Dt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=f.GET,o.path="".concat(p,"/").concat(n,"/block"),o.params=v({limit:r,token:i,user_ids:s}),o}return r(t,e),t}(_),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),Ut=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)},t.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dt(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(Mt),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},t}(k),qt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=f.GET,s.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return r(t,e),t}(_),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),Ft=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt(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(Bt),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 N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},t}(k),Kt={},jt=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 Kt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Kt[t]=this),Kt[t]}return e.get=function(e){return Kt[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"}(wt||(wt={}));var Ht,Vt=function(e){function t(n){var r=n.code,i=void 0===r?wt.UNKNOWN_ERROR:r,s=n.message,o=void 0===s?"Unknown error occurred.":s,a=e.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,t.prototype),a}return r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:wt.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:wt.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:wt.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:wt.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:wt.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:wt.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:wt.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:wt.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:wt.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:wt.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:wt.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:wt.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:wt.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:wt.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:wt.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:wt.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:wt.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:wt.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:wt.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:wt.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:wt.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ht||(Ht={}));var Wt,zt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Vt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return zt(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=zt(e[r],t);return t.delete(e),n}return e},Qt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Vt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Gt=function(e,t){for(var n=0,r=0;r>>0)%t},Yt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Jt=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Jt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Jt(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((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(!(Qt(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(Qt(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(Qt(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(Qt(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)},Xt=function(){},Zt=function(){return Promise.resolve()},$t=function(e){return e},en=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Wt||(Wt={}));var tn,nn,rn,sn=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?$t:o,u=e.backward,c=void 0===u?Zt:u,l=e.forward,h=void 0===l?Zt:l,d=e.complete,f=void 0===d?Xt: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 u(this,void 0,void 0,(function(){var e,t,n;return h(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 u(this,void 0,void 0,(function(){var e,t,n;return h(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}(),on=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*Qt(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*Qt(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;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===rn.PERSISTENT&&(r.state=nn.PERSISTENT),t!==rn.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)vn.includes(this._items[r].state)&&vn.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===nn.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=A(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===nn.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!==nn.VOLATILE}))},e}(),yn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(cn(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(cn(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=[]),u(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,D([],x(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 u(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return h(this,(function(h){switch(h.label){case 0:n=mn.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=h.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return h.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(h.sent(),o=mn.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=bn.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 u(this,void 0,void 0,(function(){var t;return h(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 u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return n=jt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,mn.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?bn.createFromCacheItem(s):new bn({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 u(this,void 0,void 0,(function(){var t;return h(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 u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return e=hn(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=mn.get(this.dbname);try{for(i=A(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),In=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=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(cn(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(tn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(tn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=x(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=x(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=A(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 Vt.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=Qt(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 u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,d,f,p,v,_,m;return h(this,(function(h){switch(h.label){case 0:return[4,(e=mn.get(this.dbname)).find(this._store,this.indexerKey,rn.PERSISTENT)];case 1:return(t=h.sent())?[3,11]:(n=hn(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),h.label=3;case 3:h.trys.push([3,8,9,10]),i=A(r),s=i.next(),h.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,rn.NO_CACHE)]:[3,6];case 5:a=h.sent(),u=bn.createFromCacheItem(a);try{for(_=void 0,c=A(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}h.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return f=h.sent(),p={error:f},[3,10];case 9:try{s&&!s.done&&(v=i.return)&&v.call(i)}finally{if(p)throw p.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=zt(this._origin),h.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return mn.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return u(this,void 0,void 0,(function(){return h(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=zt(this._origin)},e.prototype.abort=function(){this._table=zt(this._origin)},e}(),wn="undefined"!=typeof document&&"undefined"!=typeof navigator;wn&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var En=wn&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");wn&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),wn&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),wn&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var kn,Nn,On=wn&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Tn=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"}(kn||(kn={})),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"}(Nn||(Nn={}));var Sn,xn={},Cn=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=kn.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],xn[e]&&!t.forceCreate||(this.nodeId=Tn(),this.key=e,wn&&(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 Nn.NEWNODE:n._sendSync();break;case Nn.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Nn.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:Nn.REQUEST_LOCK,ts:e.ts})};try{for(var p=A(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 Nn.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 Nn.REQUEST_LOCK:n._requestLock(i);break;case Nn.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case Nn.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Nn.REMOVENODE)}))),xn[e]=this),xn[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==kn.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:Tn(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return wn&&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(Nn.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(Nn.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(Nn.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 u(this,void 0,void 0,(function(){var e=this;return h(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=kn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Nn.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Nn.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Nn.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}(),Rn=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=Ht.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=D([[r]],x(s.filter((function(e){return In.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Cn(function(e,t){return"".concat(cn(e,t),".lock")}(t,n)),this._blobContainer=new pn({dbname:t,collectionName:n,store:o}),this._transaction=new yn({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return r=ln(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Ht.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,f,p,v,_=this;return h(this,(function(h){switch(h.label){case 0:return[4,this._mutex.lock()];case 1:h.sent(),h.label=2;case 2:return h.trys.push([2,9,,10]),t=jt.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=h.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:h.sent(),this._blockManager=new gn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=D([],x(this.indexes),!1),i=[],s=r.map((function(e){return In.createKey(e)})),o=n?n.indexes.map((function(e){return In.createKey(e)})):[];try{for(a=A(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(In.parseKey(c))}catch(e){p={error:e}}finally{try{u&&!u.done&&(v=a.return)&&v.call(a)}finally{if(p)throw p.error}}return(l=[]).push.apply(l,D([],x(r.map((function(e){var t=new In({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,D([],x(i.map((function(e){return new In({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return h.sent(),[4,this._transaction.commit()];case 6:return h.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(d=ln(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata,generation:1})]);case 7:h.sent(),h.label=8;case 8:return this._state=Ht.READY,this._mutex.unlock(),[3,10];case 9:throw f=h.sent(),this._mutex.unlock(),f;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ht.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=In.createKey(e);try{for(var i=A(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===In.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 u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return e=ln(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 u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(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=A(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 Vt.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,f,p;return h(this,(function(h){switch(h.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=h.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return h.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return h.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:h.sent(),h.label=5;case 5:h.trys.push([5,10,11,12]),r=A(this._indexers),i=r.next(),h.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:h.sent(),h.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=h.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.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:h.sent(),h.label=15;case 15:h.trys.push([15,21,22,23]),o=A(this._indexers),a=o.next(),h.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 h.sent(),[4,u.addItem(e)];case 18:h.sent(),h.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=h.sent(),f={error:c},[3,23];case 22:try{a&&!a.done&&(p=o.return)&&p.call(o)}finally{if(f)throw f.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return h(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=A(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 u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(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=A(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 u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(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=A(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 u(this,void 0,void 0,(function(){var t,n;return h(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,zt(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Vt.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new an({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestInsert(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return h(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 Vt.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=A(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(zt(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 Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestUpsert(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return h(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 Vt.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=A(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(zt(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 Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestUpdate(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return u(this,void 0,void 0,(function(){var n,r,i,s,o,a,c,l,d,f,p,v,_,m,y=this;return h(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:b.sent(),b.label=2;case 2:return b.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,c=[],[4,new on({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return u(y,void 0,void 0,(function(){var n,i;return h(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Jt(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);c.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),l=A(c),d=l.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestUpdate(zt(f))]);case 6:b.sent(),b.label=7;case 7:return d=l.next(),[3,5];case 8:return[3,11];case 9:return p=b.sent(),_={error:p},[3,11];case 10:try{d&&!d.done&&(m=l.return)&&m.call(l)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,c];case 13:return v=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),v;case 15:return[3,17];case 16:throw this._transaction.clear(),Vt.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,c,l,d,f,p,v,_,m=this;return h(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 on({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return u(m,void 0,void 0,(function(){var t,r;return h(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Jt(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]),c=A(a),l=c.next(),y.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestRemove(d)]);case 6:y.sent(),y.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return f=y.sent(),v={error:f},[3,11];case 10:try{l&&!l.done&&(_=c.return)&&_.call(c)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw p=y.sent(),this._mutex.unlock(),p;case 14:return[3,16];case 15:throw this._transaction.clear(),Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return u(this,void 0,void 0,(function(){var e;return h(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return u(this,void 0,void 0,(function(){return h(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),u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Ln={},Pn=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?F:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Ln[this.dbname]},set:function(e){Ln[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return u(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:this.dbname=e,Ln[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(j.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(j.value))throw Vt.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(j)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){return[2,Object.keys(Ln[this.dbname]).filter((function(e){return e!==j.key}))]}))}))},e.prototype.get=function(e){return u(this,void 0,void 0,(function(){var t,n;return h(this,(function(r){switch(r.label){case 0:return[4,Yt(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Ln[this.dbname][e]?this._encryption.decrypt(Ln[this.dbname][e]):null]}}))}))},e.prototype.set=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return[4,Yt(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===j.key||o.lengtha.ts){if(a.all!==t.all&&(c=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var d in t.customTypes)a.customTypes[d]!==t.customTypes[d]&&(c=!0),a.customTypes[d]=t.customTypes[d];c=c&&a.ts>0,a.ts=l}c&&Z((function(){return u(r,void 0,void 0,(function(){return h(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof ee&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),te.payloadify(t.userProfile))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,o=void 0===s?[]:s,a=e.options,u=void 0===a?new ne:a,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,m=void 0!==_&&_,y=e.localCacheEncryption,b=e.useAsyncStorageStore,g=void 0===b?null:b;if(!Bn||p){var I="su-".concat(re()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},E=new Pn({encryption:w});l||(E=g?new Dn({AsyncStorage:g,encryption:w}):new An({encryption:w})),new T(I,{appId:t,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:E,encryption:w,logLevel:v,localCacheEnabled:m,debugMode:l});var k=new n(I,u,D(D([],x(o),!1),[new ie],!1));return Bn||(Bn=k),k}return Bn},Object.defineProperty(n,"instance",{get:function(){return Bn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return H},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return T.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return T.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=T.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return T.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return T.of(this._iid).logger.level},set:function(e){T.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return T.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return V(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=T.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=T.of(this._iid).connectionManager;return e.isConnected?W.OPEN:e.isConnecting?W.CONNECTING:W.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=T.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=T.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Pn?n.store:null;throw N.debugModeRequired},n.prototype.addExtension=function(e,t){var n=T.of(this._iid).sdkState;["sb_uikit","sb_syncmanager"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.initializeCache=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return t=T.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,6]:[4,i.logout()];case 1:return c.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==Sn.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new qn({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:oe,keyName:ae,index:[ue(ce.LATEST_LAST_MESSAGE),ue(ce.CHRONOLOGICAL),ue(ce.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:le,keyName:he,index:[de(fe.CHANNEL_LATEST),de(fe.NEWEST_CHILD_MESSAGE)]},{collectionName:pe,keyName:ve,index:[de(fe.CHANNEL_LATEST),de(fe.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,6];case 2:c.sent(),s.dispatch(new Ie(this._iid,{userId:e})),c.label=3;case 3:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 4:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 5:(u=c.sent())&&new te(this._iid,u).apply(),c.label=6;case 6:return[2]}}))}))},n.prototype.clearCachedData=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return(e=T.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return u(this,void 0,void 0,(function(){var t,n;return h(this,(function(r){return Q(E("string",e)).throw(N.invalidParameters),t=we.of(this._iid),n=Ee.of(this._iid),[2,Promise.all(e.map((function(e){t.removeMessagesOfChannel(e),n.removeMessagesOfChannel(e)})))]}))}))},n.prototype.connect=function(e,t){return void 0===t&&(t=null),u(this,void 0,void 0,(function(){var n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:n=T.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return c.sent(),[3,4];case 3:return c.sent(),a=T.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 c.sent(),[4,s.connect(t)];case 6:return c.sent(),this._appStateChangeDetector.start(),[4,null==(u=me.of(this._iid))?void 0:u.processNonAutoResendRegisteredPendingMessages()];case 7:return c.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=T.of(this._iid),t=e.connectionManager,n=e.sessionManager.auth.hasSession;return n&&t.resetAndReconnect().catch((function(){})),n},n.prototype.disconnect=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},n.prototype.setBackgroundState=function(){var e=T.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())},n.prototype.setForegroundState=function(){var e=T.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())},n.prototype.setSessionHandler=function(e){Q(e instanceof Le).throw(N.invalidParameters),T.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){Q(t("string",e)&&n instanceof Ae).throw(N.invalidParameters),T.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){T.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){T.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){Q(t("string",e)&&n instanceof Pe).throw(N.invalidParameters),T.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){T.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){T.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new At(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Ut(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ft(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new G(this._iid,e)},n.prototype.buildUserFromSerializedData=function(e){var t=Y(e);return new m(this._iid,m.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return n=y(y({},Re),n),Q(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(n)).throw(N.invalidParameters),this.currentUser?(r=T.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new Ue(y({userId:i.userId},n)),[4,s.send(o)]):[3,2];case 1:return a=c.sent(),u=a.as(qe).user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=u.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=u.profileUrl)),[2,u];case 2:throw N.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),this.currentUser?(t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ue({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(qe).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw N.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Fe({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new je({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ve({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Be({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ke({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new He({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Qe({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Ge).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(t("boolean",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ye({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(Je).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xe({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ze).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,s,o){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=""),u(this,void 0,void 0,(function(){var a,u,c,l,d;return h(this,(function(h){switch(h.label){case 0:return Q(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",s)&&t("string",o)).throw(N.invalidParameters),a=T.of(this._iid),u=a.sdkState,c=a.requestQueue,l=new $e({userId:u.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:s,timezone:o}),[4,c.send(l)];case 1:return d=h.sent(),[2,d.as(et).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new tt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(nt).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),u(this,void 0,void 0,(function(){var i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return Q(t("boolean",e)&&t("number",n)&&t("number",r)).throw(N.invalidParameters),i=T.of(this._iid),s=i.sdkState,o=i.requestQueue,a=new rt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(it).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return u(this,void 0,void 0,(function(){var r,i,s,o,a;return h(this,(function(u){switch(u.label){case 0:return Q(t("string",e)&&se(_e,n)).throw(N.invalidParameters),r=T.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new We({userId:i.userId,type:n,token:e}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(ze).pushTokens]}}))}))},n.prototype.getPushTriggerOption=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Oe({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ne).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(se(Se,e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xe({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Te).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new at({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ut).name]}}))}))},n.prototype.setPushTemplate=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(se(Ce,e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ct({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(lt).name]}}))}))},n.prototype.blockUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(e instanceof m||t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new st({userId:r.userId,blockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(e instanceof m||t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ot({userId:r.userId,unblockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ht({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(dt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.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,i.as(gt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(t("boolean",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new It({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ft({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(pt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new _t({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(mt).users]}}))}))},n.prototype.deleteFriend=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return u(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(r){switch(r.label){case 0:return e=T.of(this._iid).requestQueue,t=new Ot,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Tt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return u(this,void 0,void 0,(function(){var t,n,r;return h(this,(function(i){switch(i.label){case 0:return t=T.of(this._iid).requestQueue,n=new St({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(xt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return u(this,void 0,void 0,(function(){var t,n,r;return h(this,(function(i){switch(i.label){case 0:return t=T.of(this._iid).requestQueue,n=new Ct({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Rt).emoji]}}))}))},n}();export{At as ApplicationUserListQuery,Ut as BlockedUserListQuery,Pe as ConnectionHandler,Et as Emoji,kt as EmojiCategory,Nt as EmojiContainer,Ft as FriendListQuery,Pn as MemoryStore,Le as SessionHandler,Ae as UserEventHandler,Fn as default}; +import{i as e,a as t,n,_ as r,I as i,E as s,b as u,c as h,A as f,d as p,e as v,f as _,U as m,g as y,h as g,j as I,k as w,l as E,B as k,S as N,V as T,m as x,o as A,p as D,D as F,q as j,v as H,r as V,C as W,u as Q,M as G,s as Y,W as X,t as Z,w as $,x as ee,y as te,z as ne,F as re,G as ie,H as se}from"./__bundle-26bafa9e.js";export{J as ChannelType,C as ConnectionState,L as LogLevel,P as Plugin,R as Role,z as SendbirdChatOptions,S as SendbirdError,U as User,K as UserOnlineState}from"./__bundle-26bafa9e.js";import{N as oe,a as ae,g as ue,G as ce,b as le,c as he,d as de,M as fe,e as pe,f as ve,P as _e,A as me,U as ye,h as be,i as ge,D as Ie,j as we,k as Ee,l as ke,m as Ne,n as Oe,S as Te,o as Se,p as xe,q as Ce}from"./__bundle-ae9e1003.js";export{q as PushTemplate,l as PushTokenRegistrationState,P as PushTokenType,o as PushTriggerOption}from"./__bundle-ae9e1003.js";export{B as BannedUserListQuery,a as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,b as RestrictedUser,c as RestrictionInfo,d as RestrictionType}from"./__bundle-f79aa272.js";var Re={profileImage:null,profileUrl:null,nickname:null},Le=function(){this.onSessionExpired=n,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=n,this.onSessionRefreshed=n,this.onSessionClosed=n},Pe=function(){this.onConnected=n,this.onReconnectStarted=n,this.onReconnectSucceeded=n,this.onReconnectFailed=n,this.onDisconnected=n},Ae=function(){this.onFriendsDiscovered=n,this.onTotalUnreadMessageCountUpdated=n};!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(i);var De=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._pauseDelayTimer=null,t._currentState="visible",t}return r(t,e),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener},enumerable:!1,configurable:!0}),t.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},t.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},t.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState.bind(this),{capture:!0})},t}(s),Me=function(){function e(e){var t=e.logger,n=e.connectionDelegate;this.logger=t,this.connectionDelegate=n,this._onlineWorker=this._onlineWorker.bind(this),this._offlineWorker=this._offlineWorker.bind(this)}return Object.defineProperty(e.prototype,"isAvailable",{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._onlineWorker=function(){this.connectionDelegate.reconnect()},e.prototype._offlineWorker=function(){this.connectionDelegate.disconnect()},e.prototype.start=function(){this.isAvailable&&(window.addEventListener("online",this._onlineWorker),window.addEventListener("offline",this._offlineWorker))},e.prototype.stop=function(){this.isAvailable&&(window.removeEventListener("online",this._onlineWorker,!1),window.removeEventListener("offline",this._offlineWorker,!1))},e.prototype.isOnline=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){return this.isAvailable?[2,navigator.onLine]:[2,new Promise((function(e,t){fetch("https://www.google.com",{method:f.GET}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Ue=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,o=void 0===s?null:s,a=t.profileImage,u=void 0===a?null:a,c=t.preferredLanguages,l=void 0===c?null:c,h=e.call(this)||this;return h.method=f.PUT,h.path="".concat(p,"/").concat(encodeURIComponent(n)),h.params=v({nickname:i,profile_url:o,profile_file:u,preferred_languages:l}),h}return r(t,e),t}(_),qe=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new m(t,y({},n)),r}return r(t,e),t}(g),Be=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Fe=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Ke=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r}r(t,e)}(g);var je=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r}r(t,e)}(g);var He=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.DELETE,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var Ve=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.DELETE,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,r.user=new m(t,n.user),r}r(t,e)}(g);var We=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=f.GET,o.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return r(t,e),t}(_),ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_e[n.type.toLowerCase()]:_e.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(g),Qe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(_),Ge=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Ye=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(_),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Xe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(_),Ze=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),$e=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=f.PUT,c.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return r(t,e),t}(_),et=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),tt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(_),nt=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),rt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=f.PUT,o.path="".concat(p,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return r(t,e),t}(_),it=function(e){function t(t,n){var r=e.call(this,t,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 r(t,e),t}(g),st=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,n),r}r(t,e)}(g);var ot=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var at=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(_),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),ct=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(_),lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),ht=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=f.GET,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(_),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new m(t,e)})),updatedUsers:n.updated.map((function(e){return new m(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(g),ft=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(_),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(g),vt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var _t=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=f.POST,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(_),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r}return r(t,e),t}(g),yt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=f.DELETE,i.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var bt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(p,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(_),gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(g),It=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=f.PUT,i.path="".concat(p,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var wt,Et=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},kt=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 Et(e)})):[]},Nt=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 kt(e)})):[]},Ot=function(e){function t(){var t=e.call(this)||this;return t.method=f.GET,t.path=I,t}return r(t,e),t}(_),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Nt(n),r}return r(t,e),t}(g),St=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(I,"/").concat(n),r}return r(t,e),t}(_),xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new kt(n),r}return r(t,e),t}(g),Ct=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=f.GET,r.path="".concat(w,"/").concat(n),r}return r(t,e),t}(_),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Et(n),r}return r(t,e),t}(g),Lt=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=f.GET,u.path=p,u.params=v({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return r(t,e),t}(_),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),At=function(e){function n(t,n){var r,i,s,o=this;return(o=e.call(this,t,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 r(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&E("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Lt(y(y({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Pt),i=r.users,s=r.next,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]}}))}))},n}(k),Dt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=f.GET,o.path="".concat(p,"/").concat(n,"/block"),o.params=v({limit:r,token:i,user_ids:s}),o}return r(t,e),t}(_),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),Ut=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)},t.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dt(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(Mt),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},t}(k),qt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=f.GET,s.path="".concat(p,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return r(t,e),t}(_),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return r(t,e),t}(g),Ft=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt(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(Bt),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 N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},t}(k),Kt={},jt=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 Kt[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Kt[t]=this),Kt[t]}return e.get=function(e){return Kt[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"}(wt||(wt={}));var Ht,Vt=function(e){function t(n){var r=n.code,i=void 0===r?wt.UNKNOWN_ERROR:r,s=n.message,o=void 0===s?"Unknown error occurred.":s,a=e.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,t.prototype),a}return r(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:wt.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:wt.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:wt.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:wt.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:wt.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:wt.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:wt.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:wt.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:wt.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:wt.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:wt.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:wt.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:wt.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:wt.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:wt.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:wt.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:wt.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:wt.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:wt.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:wt.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:wt.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:wt.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ht||(Ht={}));var Wt,zt=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Vt.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return zt(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=zt(e[r],t);return t.delete(e),n}return e},Qt=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Vt.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Gt=function(e,t){for(var n=0,r=0;r>>0)%t},Yt=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Jt=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!Jt(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Jt(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((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(!(Qt(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(Qt(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(Qt(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(Qt(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)},Xt=function(){},Zt=function(){return Promise.resolve()},$t=function(e){return e},en=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Wt||(Wt={}));var tn,nn,rn,sn=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?$t:o,u=e.backward,c=void 0===u?Zt:u,l=e.forward,h=void 0===l?Zt:l,d=e.complete,f=void 0===d?Xt: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 u(this,void 0,void 0,(function(){var e,t,n;return h(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 u(this,void 0,void 0,(function(){var e,t,n;return h(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}(),on=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*Qt(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*Qt(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;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===rn.PERSISTENT&&(r.state=nn.PERSISTENT),t!==rn.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)vn.includes(this._items[r].state)&&vn.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===nn.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=A(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===nn.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!==nn.VOLATILE}))},e}(),yn=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(cn(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(cn(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=[]),u(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,D([],x(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 u(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return h(this,(function(h){switch(h.label){case 0:n=mn.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=h.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return h.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(h.sent(),o=mn.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=bn.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 u(this,void 0,void 0,(function(){var t;return h(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 u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return n=jt.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,mn.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?bn.createFromCacheItem(s):new bn({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 u(this,void 0,void 0,(function(){var t;return h(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 u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return e=hn(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=mn.get(this.dbname);try{for(i=A(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),In=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=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(cn(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(tn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(tn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=x(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=x(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=A(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 Vt.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=Qt(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 u(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,d,f,p,v,_,m;return h(this,(function(h){switch(h.label){case 0:return[4,(e=mn.get(this.dbname)).find(this._store,this.indexerKey,rn.PERSISTENT)];case 1:return(t=h.sent())?[3,11]:(n=hn(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=h.sent(),h.label=3;case 3:h.trys.push([3,8,9,10]),i=A(r),s=i.next(),h.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,rn.NO_CACHE)]:[3,6];case 5:a=h.sent(),u=bn.createFromCacheItem(a);try{for(_=void 0,c=A(u.items),l=c.next();!l.done;l=c.next())d=l.value,this._addItem(d)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}h.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return f=h.sent(),p={error:f},[3,10];case 9:try{s&&!s.done&&(v=i.return)&&v.call(i)}finally{if(p)throw p.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=zt(this._origin),h.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return mn.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return u(this,void 0,void 0,(function(){return h(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=zt(this._origin)},e.prototype.abort=function(){this._table=zt(this._origin)},e}(),wn="undefined"!=typeof document&&"undefined"!=typeof navigator;wn&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var En=wn&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");wn&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),wn&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),wn&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var kn,Nn,On=wn&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Tn=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"}(kn||(kn={})),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"}(Nn||(Nn={}));var Sn,xn={},Cn=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=kn.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],xn[e]&&!t.forceCreate||(this.nodeId=Tn(),this.key=e,wn&&(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 Nn.NEWNODE:n._sendSync();break;case Nn.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Nn.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:Nn.REQUEST_LOCK,ts:e.ts})};try{for(var p=A(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 Nn.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 Nn.REQUEST_LOCK:n._requestLock(i);break;case Nn.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case Nn.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Nn.REMOVENODE)}))),xn[e]=this),xn[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==kn.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:Tn(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return wn&&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(Nn.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(Nn.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(Nn.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 u(this,void 0,void 0,(function(){var e=this;return h(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=kn.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Nn.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Nn.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Nn.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}(),Rn=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=Ht.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=D([[r]],x(s.filter((function(e){return In.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Cn(function(e,t){return"".concat(cn(e,t),".lock")}(t,n)),this._blobContainer=new pn({dbname:t,collectionName:n,store:o}),this._transaction=new yn({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return r=ln(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Ht.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,f,p,v,_=this;return h(this,(function(h){switch(h.label){case 0:return[4,this._mutex.lock()];case 1:h.sent(),h.label=2;case 2:return h.trys.push([2,9,,10]),t=jt.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=h.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:h.sent(),this._blockManager=new gn({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=D([],x(this.indexes),!1),i=[],s=r.map((function(e){return In.createKey(e)})),o=n?n.indexes.map((function(e){return In.createKey(e)})):[];try{for(a=A(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(In.parseKey(c))}catch(e){p={error:e}}finally{try{u&&!u.done&&(v=a.return)&&v.call(a)}finally{if(p)throw p.error}}return(l=[]).push.apply(l,D([],x(r.map((function(e){var t=new In({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,D([],x(i.map((function(e){return new In({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return h.sent(),[4,this._transaction.commit()];case 6:return h.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(d=ln(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:d,value:this._metadata,generation:1})]);case 7:h.sent(),h.label=8;case 8:return this._state=Ht.READY,this._mutex.unlock(),[3,10];case 9:throw f=h.sent(),this._mutex.unlock(),f;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ht.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=In.createKey(e);try{for(var i=A(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===In.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 u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return e=ln(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 u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(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=A(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 Vt.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,d,f,p;return h(this,(function(h){switch(h.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=h.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return h.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return h.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:h.sent(),h.label=5;case 5:h.trys.push([5,10,11,12]),r=A(this._indexers),i=r.next(),h.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:h.sent(),h.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=h.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(d=r.return)&&d.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:h.sent(),h.label=15;case 15:h.trys.push([15,21,22,23]),o=A(this._indexers),a=o.next(),h.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 h.sent(),[4,u.addItem(e)];case 18:h.sent(),h.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=h.sent(),f={error:c},[3,23];case 22:try{a&&!a.done&&(p=o.return)&&p.call(o)}finally{if(f)throw f.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return h(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=A(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 u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(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=A(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 u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(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=A(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 u(this,void 0,void 0,(function(){var t,n;return h(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,zt(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Vt.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new an({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestInsert(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return h(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 Vt.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=A(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(zt(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 Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestUpsert(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return h(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 Vt.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=A(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(zt(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 Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionKeyNotGiven;return[4,this._requestUpdate(zt(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return u(this,void 0,void 0,(function(){var n,r,i,s,o,a,c,l,d,f,p,v,_,m,y=this;return h(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:b.sent(),b.label=2;case 2:return b.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,c=[],[4,new on({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return u(y,void 0,void 0,(function(){var n,i;return h(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Jt(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);c.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),l=A(c),d=l.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestUpdate(zt(f))]);case 6:b.sent(),b.label=7;case 7:return d=l.next(),[3,5];case 8:return[3,11];case 9:return p=b.sent(),_={error:p},[3,11];case 10:try{d&&!d.done&&(m=l.return)&&m.call(l)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,c];case 13:return v=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),v;case 15:return[3,17];case 16:throw this._transaction.clear(),Vt.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return u(this,void 0,void 0,(function(){var t;return h(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,c,l,d,f,p,v,_,m=this;return h(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 on({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return u(m,void 0,void 0,(function(){var t,r;return h(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Jt(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]),c=A(a),l=c.next(),y.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestRemove(d)]);case 6:y.sent(),y.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return f=y.sent(),v={error:f},[3,11];case 10:try{l&&!l.done&&(_=c.return)&&_.call(c)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw p=y.sent(),this._mutex.unlock(),p;case 14:return[3,16];case 15:throw this._transaction.clear(),Vt.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return u(this,void 0,void 0,(function(){var e;return h(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 Vt.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return u(this,void 0,void 0,(function(){return h(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),u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(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 u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Ln={},Pn=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?F:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Ln[this.dbname]},set:function(e){Ln[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return u(this,void 0,void 0,(function(){var t;return h(this,(function(n){switch(n.label){case 0:this.dbname=e,Ln[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(j.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(j.value))throw Vt.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(j)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){return[2,Object.keys(Ln[this.dbname]).filter((function(e){return e!==j.key}))]}))}))},e.prototype.get=function(e){return u(this,void 0,void 0,(function(){var t,n;return h(this,(function(r){switch(r.label){case 0:return[4,Yt(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Ln[this.dbname][e]?this._encryption.decrypt(Ln[this.dbname][e]):null]}}))}))},e.prototype.set=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return[4,Yt(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===j.key||o.lengtha.ts){if(a.all!==t.all&&(c=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var d in t.customTypes)a.customTypes[d]!==t.customTypes[d]&&(c=!0),a.customTypes[d]=t.customTypes[d];c=c&&a.ts>0,a.ts=l}c&&Z((function(){return u(r,void 0,void 0,(function(){return h(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof ee&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),te.payloadify(t.userProfile))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,o=void 0===s?[]:s,a=e.options,u=void 0===a?new ne:a,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,m=void 0!==_&&_,y=e.localCacheEncryption,b=e.useAsyncStorageStore,g=void 0===b?null:b;if(!Bn||p){var I="su-".concat(re()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},E=new Pn({encryption:w});l||(E=g?new Dn({AsyncStorage:g,encryption:w}):new An({encryption:w})),new T(I,{appId:t,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:E,encryption:w,logLevel:v,localCacheEnabled:m,debugMode:l});var k=new n(I,u,D(D([],x(o),!1),[new ie],!1));return Bn||(Bn=k),k}return Bn},Object.defineProperty(n,"instance",{get:function(){return Bn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return H},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return T.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return T.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=T.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return T.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return T.of(this._iid).logger.level},set:function(e){T.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return T.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return V(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=T.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=T.of(this._iid).connectionManager;return e.isConnected?W.OPEN:e.isConnecting?W.CONNECTING:W.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=T.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=T.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Pn?n.store:null;throw N.debugModeRequired},n.prototype.addExtension=function(e,t){var n=T.of(this._iid).sdkState;["sb_uikit","sb_syncmanager"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.initializeCache=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return t=T.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,6]:[4,i.logout()];case 1:return c.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==Sn.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new qn({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:oe,keyName:ae,index:[ue(ce.LATEST_LAST_MESSAGE),ue(ce.CHRONOLOGICAL),ue(ce.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:le,keyName:he,index:[de(fe.CHANNEL_LATEST),de(fe.NEWEST_CHILD_MESSAGE)]},{collectionName:pe,keyName:ve,index:[de(fe.CHANNEL_LATEST),de(fe.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,6];case 2:c.sent(),s.dispatch(new Ie(this._iid,{userId:e})),c.label=3;case 3:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 4:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 5:(u=c.sent())&&new te(this._iid,u).apply(),c.label=6;case 6:return[2]}}))}))},n.prototype.clearCachedData=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return(e=T.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return u(this,void 0,void 0,(function(){var t,n;return h(this,(function(r){return Q(E("string",e)).throw(N.invalidParameters),t=we.of(this._iid),n=Ee.of(this._iid),[2,Promise.all(e.map((function(e){t.removeMessagesOfChannel(e),n.removeMessagesOfChannel(e)})))]}))}))},n.prototype.connect=function(e,t){return void 0===t&&(t=null),u(this,void 0,void 0,(function(){var n,r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:n=T.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return c.sent(),[3,4];case 3:return c.sent(),a=T.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 c.sent(),[4,s.connect(t)];case 6:return c.sent(),this._appStateChangeDetector.start(),[4,null==(u=me.of(this._iid))?void 0:u.processNonAutoResendRegisteredPendingMessages()];case 7:return c.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=T.of(this._iid),t=e.connectionManager,n=e.sessionManager.auth.hasSession;return n&&t.resetAndReconnect().catch((function(){})),n},n.prototype.disconnect=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},n.prototype.setBackgroundState=function(){var e=T.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())},n.prototype.setForegroundState=function(){var e=T.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())},n.prototype.setSessionHandler=function(e){Q(e instanceof Le).throw(N.invalidParameters),T.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){Q(t("string",e)&&n instanceof Ae).throw(N.invalidParameters),T.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){T.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){T.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){Q(t("string",e)&&n instanceof Pe).throw(N.invalidParameters),T.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){T.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){T.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new At(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Ut(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ft(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new G(this._iid,e)},n.prototype.buildUserFromSerializedData=function(e){var t=Y(e);return new m(this._iid,m.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var r,i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return n=y(y({},Re),n),Q(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(n)).throw(N.invalidParameters),this.currentUser?(r=T.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new Ue(y({userId:i.userId},n)),[4,s.send(o)]):[3,2];case 1:return a=c.sent(),u=a.as(qe).user,this.currentUser&&(n.nickname&&(this.currentUser.nickname=u.nickname),(n.profileUrl||n.profileImage)&&(this.currentUser.plainProfileUrl=u.profileUrl)),[2,u];case 2:throw N.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),this.currentUser?(t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ue({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(qe).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw N.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Fe({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new je({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ve({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Be({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:if(Q(t("string",e)).throw(N.invalidParameters),!this.currentUser)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ke({userId:r.userId,token:e}),[4,i.send(s)];case 2:return o.sent(),this._fcmPushToken="",[2,ke.SUCCESS];case 3:return o.sent(),[2,ke.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,ke.PENDING];case 6:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new He({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Qe({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Ge).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(t("boolean",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ye({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(Je).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xe({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ze).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,s,o){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=""),u(this,void 0,void 0,(function(){var a,u,c,l,d;return h(this,(function(h){switch(h.label){case 0:return Q(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",s)&&t("string",o)).throw(N.invalidParameters),a=T.of(this._iid),u=a.sdkState,c=a.requestQueue,l=new $e({userId:u.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:s,timezone:o}),[4,c.send(l)];case 1:return d=h.sent(),[2,d.as(et).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new tt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(nt).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),u(this,void 0,void 0,(function(){var i,s,o,a,u;return h(this,(function(c){switch(c.label){case 0:return Q(t("boolean",e)&&t("number",n)&&t("number",r)).throw(N.invalidParameters),i=T.of(this._iid),s=i.sdkState,o=i.requestQueue,a=new rt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(a)];case 1:return u=c.sent(),[2,u.as(it).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return u(this,void 0,void 0,(function(){var r,i,s,o,a;return h(this,(function(u){switch(u.label){case 0:return Q(t("string",e)&&se(_e,n)).throw(N.invalidParameters),r=T.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new We({userId:i.userId,type:n,token:e}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(ze).pushTokens]}}))}))},n.prototype.getPushTriggerOption=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Oe({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ne).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(se(Se,e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xe({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Te).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return u(this,void 0,void 0,(function(){var e,t,n,r;return h(this,(function(i){switch(i.label){case 0:return e=T.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new at({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(ut).name]}}))}))},n.prototype.setPushTemplate=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(se(Ce,e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ct({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(lt).name]}}))}))},n.prototype.blockUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(e instanceof m||t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new st({userId:r.userId,blockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(e instanceof m||t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ot({userId:r.userId,unblockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s,o;return h(this,(function(a){switch(a.label){case 0:return Q(t("string",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ht({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(dt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return u(this,void 0,void 0,(function(){var e,t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return e=T.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,i.as(gt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return u(this,void 0,void 0,(function(){var n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(t("boolean",e)).throw(N.invalidParameters),n=T.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new It({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ft({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(pt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,s;return h(this,(function(o){switch(o.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new _t({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(mt).users]}}))}))},n.prototype.deleteFriend=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i;return h(this,(function(s){switch(s.label){case 0:return Q(E("string",e)).throw(N.invalidParameters),t=T.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return u(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(r){switch(r.label){case 0:return e=T.of(this._iid).requestQueue,t=new Ot,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Tt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return u(this,void 0,void 0,(function(){var t,n,r;return h(this,(function(i){switch(i.label){case 0:return t=T.of(this._iid).requestQueue,n=new St({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(xt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return u(this,void 0,void 0,(function(){var t,n,r;return h(this,(function(i){switch(i.label){case 0:return t=T.of(this._iid).requestQueue,n=new Ct({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Rt).emoji]}}))}))},n}();export{At as ApplicationUserListQuery,Ut as BlockedUserListQuery,Pe as ConnectionHandler,Et as Emoji,kt as EmojiCategory,Nt as EmojiContainer,Ft as FriendListQuery,Pn as MemoryStore,Le as SessionHandler,Ae as UserEventHandler,Fn as default};