From be6c08b556209765203292727687b3ab9f9c8327 Mon Sep 17 00:00:00 2001 From: sendbird-sdk-deployment Date: Mon, 5 Jun 2023 04:29:47 +0000 Subject: [PATCH] Release - 4.9.1 --- CHANGELOG.md | 4 ++++ groupChannel.js | 2 +- index.js | 2 +- lib/__bundle-199cda92.js | 1 - lib/{__bundle-b3187dac.js => __bundle-6bc4500a.js} | 2 +- lib/{__bundle-2cf2dbb7.js => __bundle-a8f5769e.js} | 2 +- lib/{__bundle-e902ed46.js => __bundle-ad6d760f.js} | 2 +- lib/{__bundle-b2746c15.js => __bundle-d67b9997.js} | 2 +- lib/{__bundle-7ad2ae44.js => __bundle-e21f40c4.js} | 2 +- lib/{__bundle-6d9f318a.js => __bundle-ed97dd0a.js} | 2 +- lib/__bundle-f20da9a5.js | 1 + message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.min.js | 2 +- 16 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 lib/__bundle-199cda92.js rename lib/{__bundle-b3187dac.js => __bundle-6bc4500a.js} (99%) rename lib/{__bundle-2cf2dbb7.js => __bundle-a8f5769e.js} (99%) rename lib/{__bundle-e902ed46.js => __bundle-ad6d760f.js} (52%) rename lib/{__bundle-b2746c15.js => __bundle-d67b9997.js} (99%) rename lib/{__bundle-7ad2ae44.js => __bundle-e21f40c4.js} (95%) rename lib/{__bundle-6d9f318a.js => __bundle-ed97dd0a.js} (71%) create mode 100644 lib/__bundle-f20da9a5.js diff --git a/CHANGELOG.md b/CHANGELOG.md index c45fc26..da76ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.9.1 (Jun 05, 2023) +### **Features** +### **Improvements** +- Fixed a bug where the name, size, and type of FileMessage's PendingMessage were set to default values ## v4.9.0 (Jun 01, 2023) ### **Features** ### MultipleFilesMessage diff --git a/groupChannel.js b/groupChannel.js index e930db5..a149fe1 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,e as r,g as s,K as i,T as a,O as o,U as u,$ as c,aE as h,q as d,r as _,b as f,c as m,J as v,m as g,a as y,i as C,a6 as E,I as b,aD as M,aF as N,aw as S,aG as U,aj as T,ai as I,A,d as w,f as D,h as L,aH as k,ag as x,aI as R,a9 as F,W as O,a2 as H,B as V,S as q,t as B,V as j,Q as z,aC as Q,y as W,ah as K,s as Y,ac as J,aJ as X,E as Z,w as $,x as ee,af as te,aa as ne,aK as re,aL as se,aM as ie,u as ae,a4 as oe,aN as ue,al as ce,a3 as le,aB as he,ad as de,M as pe,n as _e,am as fe}from"./lib/__bundle-2cf2dbb7.js";export{ah as MessageEventSource}from"./lib/__bundle-2cf2dbb7.js";import{g as me,N as ve,p as ge,q as ye,r as Ce,t as Ee,u as be,w as Me,x as Ne,y as Se,P as Ue,z as Te,A as Ie,C as Ae,E as we,D as De,G as Le,H as ke,I as Pe,J as xe,f as Re,K as Fe,L as Oe}from"./lib/__bundle-e902ed46.js";import{G as He,g as Ge,D as Ve,l as qe,m as Be,n as je,j as ze,i as Qe,o as We,R as Ke,p as Ye,k as Je,U as Xe,e as Ze,f as $e,s as et,d as tt,S as nt,v as rt,q as st,r as it,P as at,t as ot}from"./lib/__bundle-b2746c15.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-b2746c15.js";import{C as ut,a as ct,O as lt,P as ht,M as dt,T as pt,R as _t,U as ft,A as mt,B as vt}from"./lib/__bundle-7ad2ae44.js";import{l as gt,S as yt,I as Ct,p as Et,U as bt,F as Mt,m as Nt,c as St,T as Ut,d as Tt,A as It,n as At,g as wt,h as Dt,o as Lt,q as kt}from"./lib/__bundle-199cda92.js";export{l as ScheduledStatus}from"./lib/__bundle-199cda92.js";import{b as Pt}from"./lib/__bundle-b3187dac.js";var xt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(xt||(xt={}));var Rt,Ft,Ot,Ht,Gt,Vt,qt,Bt,jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=i(xt,n.state)?n.state:null,r.role=i(a,n.role)?n.role:null,Object.prototype.hasOwnProperty.call(n,"is_muted")&&(r.isMuted=n.is_muted),Object.prototype.hasOwnProperty.call(n,"is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),Object.prototype.hasOwnProperty.call(n,"is_blocking_me")&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return e?r(s(s({},t.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},n}(me),zt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:o.GROUP,i.reader=new u(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Rt||(Rt={})),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"}(Ft||(Ft={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ht||(Ht={})),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"}(Gt||(Gt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Vt||(Vt={})),function(e){e.AND="AND",e.OR="OR"}(qt||(qt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Bt||(Bt={}));var Qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ft.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ot.ALL,this.publicChannelFilter=Rt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ht.ALL,this.hiddenChannelFilter=Gt.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=qt.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 Bt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Bt.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,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case qt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case qt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,c))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 l=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(l)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ft.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ft.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ft.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ft.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gt.HIDDEN:if(!e.isHidden)return!1;break;case Gt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ht.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Rt.PUBLIC:if(!e.isPublic)return!1;break;case Rt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ot.SUPER:if(!e.isSuper)return!1;break;case Ot.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Kt=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(ve):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 er.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],_(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===e.url)return!1;break;case He.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:m.sent(),m.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return f(this,void 0,void 0,(function(){return m(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 f(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],_(this._channels.keys()),!1)),f(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=v(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}(c),Yt={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},Jt=function(e){return g("string",e.invitedUserIds,!0)&&y("string",e.channelUrl,!0)&&y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isSuper,!0)&&y("boolean",e.isBroadcast,!0)&&y("boolean",e.isExclusive,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isStrict,!0)&&y("boolean",e.isDiscoverable,!0)&&y("boolean",e.isEphemeral,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)},Xt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Zt=function(e){return g("string",e.customTypes,!0)&&y("boolean",e.includeEmpty)&&y("boolean",e.includeFrozen)},$t={myMemberStateFilter:Ft.ALL},en=function(e){return i(Ft,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"}(Qt||(Qt={}));var tn={keys:[]},nn={channelCustomTypesFilter:null,superChannelFilter:Ot.ALL},rn={channelUrl:null,scheduledStatus:null,messageTypeFilter:E.ALL},sn=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 f(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,_,g,y,C=this;return m(this,(function(E){switch(E.label){case 0:if(!(e instanceof Be))return[3,10];s=e.channels,_=e.source,i=e.data,a=s.filter((function(e){return e instanceof os})),o=t.filterOffsetChanged(a),E.label=1;case 1:E.trys.push([1,6,7,8]),u=v(o),c=u.next(),E.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:E.sent(),E.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=E.sent(),g={error:h},[3,8];case 7:try{c&&!c.done&&(y=u.return)&&y.call(u)}finally{if(g)throw g.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=E.sent(),this._broadcastUpdateEvent(d,_,i),[3,15];case 10:return e instanceof qe?(p=e.channelUrls,_=e.source,[4,t.remove(p)]):[3,13];case 11:return E.sent(),[4,b((function(){return f(C,void 0,void 0,(function(){var e,t,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(p),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return E.sent(),this._broadcastRemoveEvent(p,_),[3,15];case 13:return e instanceof Ve?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:E.sent(),E.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=v(this._observers.values()),a=i.next();!a.done;a=i.next()){a.value.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),an=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return f(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,_,v,g=this;return m(this,(function(y){switch(y.label){case 0:return e instanceof I?(t=e.messages,_=e.source,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof yt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:y.sent(),this._broadcastUpdateEvent(s,_),y.label=2;case 2:return i.length>0?[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:y.sent(),this._broadcastUpdateEvent(i,_),y.label=4;case 4:return[3,21];case 5:return e instanceof T?(a=e.messageIds,_=e.source,[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return y.sent(),this._broadcastRemoveEvent(a,_),[3,21];case 7:return e instanceof U?(o=e.reqId,_=e.source,[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return y.sent(),this._broadcastRemoveUnsentEvent(o,_),[3,21];case 9:return e instanceof S?(u=e.polls,_=e.source,this._cacheContext.localCacheEnabled?(c=u.map((function(e){return e.messageId})),[4,Promise.all(c.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(l=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=l.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(l)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,_),[3,21];case 13:return e instanceof N?(h=e.event,_=e.source,[4,n.get(h.messageId)]):[3,17];case 14:return(d=y.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(h)?[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:y.sent(),y.label=16;case 16:return this._broadcastPollUpdateEvent(h,_),[3,21];case 17:return e instanceof M?(p=e.event,_=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,b((function(){return f(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:y.sent(),y.label=20;case 20:this._broadcastPollVoteEvent(p,_),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(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=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=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({},Xt),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=A.GET,u.path="".concat(w,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(D),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new os(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(L),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(r?k:x,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(D),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new os(e,n),r}return e(n,t),n}(L),hn=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,p=e.nicknameContainsFilter,_=e.nicknameStartsWithFilter,f=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,S=e.includeFrozen,U=e.includeMetaData,T=e.searchFilter,I=e.userIdsFilter;return(n=t.call(this)||this).method=A.GET,n.path="".concat(w,"/").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:p,members_nickname_startswith:_,members_nickname:f,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:S,show_metadata:U}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),I&&I.userIds&&I.userIds.length>0&&(I.includeMode?(n.params.members_include_in=I.userIds,n.params.query_type=I.queryType.toUpperCase()):n.params.members_exactly_in=I.userIds),n}return e(n,t),n}(D),dn=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 os(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(L),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ft.ALL},s}return e(n,t),n}(D),_n=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}(L),fn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(D),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(L),vn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=A.GET,r.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(D),gn=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}(L),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ot.ALL,custom_types:i},s}return e(n,t),n}(D),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(L),En=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=A.GET,i.path="".concat(R,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(D),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(L),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case gt.PENDING:t.push(Ct.PENDING);break;case gt.SENT:t.push(Ct.IN_QUEUE),t.push(Ct.SENT);break;case gt.CANCELED:t.push(Ct.CANCELED);break;case gt.FAILED:t.push(Ct.FAILED)}})),t}},Nn=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,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,f=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=A.POST,n.path=x,n.params=r({user_ids:d([s],_(null!=M?M:[]),!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:l,is_exclusive:p,is_public:h,is_discoverable:f,strict:m,is_ephemeral:v,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(D),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(L),Un=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=A.PUT,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Tn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),An=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 jt(e,t)})):[new jt(e,r.data)],s}return e(n,t),n}(ut),wn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Dn=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 jt(s._iid,r.data),s}return e(n,t),n}(ut),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=A.POST,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(D),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pn=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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitees,_=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitees=_.map((function(t){return new jt(e,t)})),s}return e(n,t),n}(ut),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.NONE,r}e(n,t)}(L);var Rn=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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitee,_=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitee=_?new jt(e,_):null,s}return e(n,t),n}(ut),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(F),On=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new zt(e,r),s}return e(n,t),n}(O),Hn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=A.PUT,i.path="".concat(x,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Gn,Vn=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}(O),qn=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=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(D),Bn=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}(L),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(O),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(F),Qn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Wn=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}(F),Kn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Yn=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}(F),Jn=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,_,f,m,v,g,y,C,E,b,M,N,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Ft.ALL,S.unreadChannelFilter=Ht.ALL,S.superChannelFilter=Ot.ALL,S.publicChannelFilter=Rt.ALL,S.hiddenChannelFilter=Gt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=He.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,S.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,S.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,S.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",S.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,S.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,S.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,S.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ft.ALL,S.unreadChannelFilter=null!==(_=n.unreadChannelFilter)&&void 0!==_?_:Ht.ALL,S.superChannelFilter=null!==(f=n.superChannelFilter)&&void 0!==f?f:Ot.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Rt.ALL,S.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Gt.UNHIDDEN,S.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},S.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,S.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,S.order=null!==(N=n.order)&&void 0!==N?N:He.LATEST_LAST_MESSAGE,S}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter)&&y("string",this.nicknameContainsFilter,!0)&&y("string",this.nicknameStartsWithFilter,!0)&&y("string",this.nicknameExactMatchFilter,!0)&&i(Ft,this.myMemberStateFilter)&&i(Ot,this.superChannelFilter)&&i(Rt,this.publicChannelFilter)&&i(Ht,this.unreadChannelFilter)&&i(Gt,this.hiddenChannelFilter)&&g(Bt,this.searchFilter.fields)&&y("string",this.searchFilter.query,!0)&&g("string",this.userIdsFilter.userIds)&&y("boolean",this.userIdsFilter.includeMode)&&i(qt,this.userIdsFilter.queryType)&&i(He,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return H(this)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,er.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 q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Xn=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||w.unreadMentionCount>0)&&(w._updateUnreadCount(0,0),this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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!==w.unreadMessageCount&&0!==w.unreadMentionCount||(this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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 Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),bn.label=12;case 12:return[3,79];case 13:return D=e.as(Vn),ue=D.channelUrl,L=D.deliveredStateUpdate,k=void 0===L?{}:L,P=this._groupChannelCache.isCachedInMemory(ue),[4,this.getChannel(ue,!0)];case 14:if(x=bn.sent(),P)for(R in k)x._updateUndeliveredMemberState(R,k[R]);return Object.keys(k).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new Be({channels:[x],source:je.EVENT_CHANNEL_DELIVERED})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(x)}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,79];case 15:return F=e.as(_t),ue=F.channelUrl,ce=F.channelType,O=F.event,ce!==o.GROUP?[3,18]:[4,this.getChannel(ue,!0)];case 16:return H=bn.sent(),[4,this.getMessageFromCache(O.messageId)];case 17:(q=bn.sent())&&(q.applyReactionEvent(O),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_REACTION_UPDATED}))),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(H,O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=18;case 18:return[3,79];case 19:return(G=e.as(pt).event).channelType!==o.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return V=bn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(q=bn.sent())&&(q.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_THREADINFO_UPDATED}))),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(V,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=22;case 22:return[3,79];case 23:B=e.as(dt).groupChannelMemberCounts,z=[],bn.label=24;case 24:bn.trys.push([24,29,30,31]),Y=v(B),J=Y.next(),bn.label=25;case 25:return J.done?[3,28]:(Z=J.value,ue=Z.channelUrl,nt=Z.memberCount,rt=Z.joinedMemberCount,$=Z.updatedAt,[4,this.getChannelFromCache(ue)]);case 26:(ee=bn.sent())&&ee._setLatestMemberCount(nt,rt,$)&&z.push(ee),bn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=bn.sent(),pn={error:te},[3,31];case 30:try{J&&!J.done&&(_n=Y.return)&&_n.call(Y)}finally{if(pn)throw pn.error}return[7];case 31:return z.length>0&&(this._dispatcher.dispatch(new Be({channels:z,source:je.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(z)}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,79];case 32:return ne=e.as(ht),re=ne.event,se=ne.status,ue=ne.channelUrl,ce=ne.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,34];case 33:ie=bn.sent(),this._dispatcher.dispatch(new N({event:re,source:K.EVENT_POLL_UPDATED})),W(se===X?function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(ie,re.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(ie,re)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),bn.label=34;case 34:return[3,79];case 35:return ae=e.as(Ue),oe=ae.event,ue=ae.channelUrl,ce=ae.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,37];case 36:le=bn.sent(),this._dispatcher.dispatch(new M({event:oe,source:K.EVENT_POLL_VOTED})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(le,oe)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=37;case 37:return[3,79];case 38:if(!(he=e.as(ut).event).isGroupChannelEvent)return[3,77];switch(he.category){case ct.CHANNEL_JOIN:return[3,39];case ct.CHANNEL_LEAVE:return[3,41];case ct.CHANNEL_OPERATOR_UPDATE:return[3,45];case ct.CHANNEL_INVITE:return[3,47];case ct.CHANNEL_DECLINE_INVITE:return[3,49];case ct.TYPING_START:case ct.TYPING_END:return[3,51];case ct.USER_CHANNEL_MUTE:case ct.USER_CHANNEL_UNMUTE:return[3,53];case ct.USER_CHANNEL_BAN:return[3,55];case ct.USER_CHANNEL_UNBAN:return[3,59];case ct.CHANNEL_FREEZE:case ct.CHANNEL_UNFREEZE:return[3,61];case ct.CHANNEL_HIDE:return[3,63];case ct.CHANNEL_UNHIDE:return[3,65];case ct.CHANNEL_DELETED:return[3,67];case ct.CHANNEL_PROP_CHANGED:return[3,69];case ct.CHANNEL_META_DATA_CHANGED:return[3,71];case ct.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case ct.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(he.channelUrl,!0)];case 40:return de=bn.sent(),pe=e.as(An),_e=pe.memberCount,fe=pe.joinedMemberCount,me=pe.members,ve=!1,me.forEach((function(e){de.isExclusive||de.isSuper||de.isBroadcast?ve=ve||de._setLatestMemberCount(_e,fe,he.ts):(e.state=xt.JOINED,de.addMember(e,he.ts),En._updateJoinedMemberCount(de)),e.userId===En._sdkState.userId&&(de.myMemberState=xt.JOINED)})),this._dispatcher.dispatch(new Be({channels:[de],source:je.EVENT_CHANNEL_JOINED})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=v(me),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(de,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}de.isBroadcast&&ve&&e.onChannelMemberCountChanged([de])})),[2]}))}))})),[3,77];case 41:return(Ut=this._leftChannels.get(he.channelUrl))?(De=Ut.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(he.channelUrl,!0)];case 43:De=bn.sent(),bn.label=44;case 44:return ge=De,Le=e.as(Dn),nt=Le.memberCount,rt=Le.joinedMemberCount,ke=Le.member,Pe=!1,xe=j.of(this._iid).appInfo,ge.isExclusive||ge.isSuper||ge.isBroadcast?Pe=ge._setLatestMemberCount(nt,rt,he.ts):(xe.enabledChannelMemberShipHistory?(ge.members.find((function(e){return e.userId===ke.userId})).state=xt.LEFT,ge.memberCount=nt):ge.removeMember(ke),this._updateJoinedMemberCount(ge)),ke.userId===this._sdkState.userId?(ge.myMemberState=xt.NONE,ge.invitedAt=0,ge.joinedAt=0,ge._updateUnreadCount(0,0),ge.isPublic?this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ge),this._dispatcher.dispatch(new qe({channelUrls:[ge.url],source:je.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ge,ke),ge.isBroadcast&&Pe&&e.onChannelMemberCountChanged([ge])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(he.channelUrl,!0)];case 46:Re=bn.sent(),Fe=e.as(lt).operators,Oe=Fe.map((function(e){return e.userId}));try{for(He=v(Re.members),Ge=He.next();!Ge.done;Ge=He.next())(St=Ge.value).role=Oe.includes(St.userId)?a.OPERATOR:a.NONE}catch(e){fn={error:e}}finally{try{Ge&&!Ge.done&&(mn=He.return)&&mn.call(He)}finally{if(fn)throw fn.error}}return Re.myRole=Oe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new Be({channels:[Re],source:je.EVENT_CHANNEL_OPERATOR_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Re,Fe)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(he.channelUrl,!0)];case 48:Ve=bn.sent(),ze=e.as(Pn),nt=ze.memberCount,rt=ze.joinedMemberCount,Qe=ze.inviter,(We=ze.invitees).forEach((function(e){return e.state=xt.INVITED}));try{for(Ke=v(We),Ye=Ke.next();!Ye.done;Ye=Ke.next())Je=Ye.value,Ve.isExclusive||Ve.isSuper||Ve.isBroadcast?Ve._setLatestMemberCount(nt,rt,he.ts):Ve.addMember(Je,he.ts),this._sdkState.userId===Je.userId&&(Ve.hiddenState=ts.UNHIDDEN,Ve.myMemberState!==xt.JOINED&&(Ve.myMemberState=xt.INVITED),Ve.invitedAt=he.ts)}catch(e){vn={error:e}}finally{try{Ye&&!Ye.done&&(gn=Ke.return)&&gn.call(Ke)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new Be({channels:[Ve],source:je.EVENT_CHANNEL_INVITED})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ve,Qe,We)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(he.channelUrl,!0)];case 50:return et=bn.sent(),tt=e.as(Rn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,it=tt.invitee,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(nt,rt,he.ts):et.removeMember(it),this._sdkState.userId===it.userId?(et.invitedAt=0,et.myMemberState=xt.NONE,et.isPublic?this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new qe({channelUrls:[et.url],source:je.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(et,st,it)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(he.channelUrl,!0)];case 52:return at=bn.sent(),ot=he.category===ct.TYPING_START,vt=e.as(ot?Qn:Kn).user,at._updateTypingStatus(vt,ot?he.ts:0),this._dispatcher.dispatch(new Be({channels:[at],source:je.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(at)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(he.channelUrl,!0)];case 54:gt=bn.sent(),Ct=he.category===ct.USER_CHANNEL_MUTE,(Et=e.as(Ct?Ne:Se).user).userId===this._sdkState.userId&&(gt.myMutedState=Ct?es.MUTED:es.UNMUTED,gt._myMutedRemainingTime=Et.restrictionInfo.remainingDuration);try{for(bt=v(gt.members),Mt=bt.next();!Mt.done;Mt=bt.next())if((St=Mt.value).userId===Et.userId){St.isMuted=Ct;break}}catch(e){yn={error:e}}finally{try{Mt&&!Mt.done&&(Cn=bt.return)&&Cn.call(bt)}finally{if(yn)throw yn.error}}return this._dispatcher.dispatch(new Be({channels:[gt],source:Ct?je.EVENT_CHANNEL_MUTED:je.EVENT_CHANNEL_UNMUTED,data:Et.userId})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted(gt,Et):e.onUserUnmuted(gt,Et)})),[2]}))}))})),[3,77];case 55:return(Ut=this._leftChannels.get(he.channelUrl))?(It=Ut.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(he.channelUrl,!0)];case 57:It=bn.sent(),bn.label=58;case 58:return Tt=It,this._markAsLeave(Tt),At=e.as(Me).user,W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Tt,At)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(he.channelUrl,!0)];case 60:return wt=bn.sent(),Dt=e.as(be).user,W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(wt,Dt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(he.channelUrl,!0)];case 62:return Lt=bn.sent(),kt=e.as(Ee).freeze,Lt.isFrozen=kt,this._dispatcher.dispatch(new Be({channels:[Lt],source:kt?je.EVENT_CHANNEL_FROZEN:je.EVENT_CHANNEL_UNFROZEN})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen(Lt):e.onChannelUnfrozen(Lt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(he.channelUrl,!0)];case 64:return Pt=bn.sent(),Rt=e.as(jn),Ft=Rt.allowAutoUnhide,Ot=Rt.hidePreviousMessages,Ht=Rt.messageOffsetTimestamp,null!==Ft&&(Pt.hiddenState=Ft?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ot&&Ot&&Pt._updateUnreadCount(0,0),null!==Ht&&(Pt.messageOffsetTimestamp=Ht),this._dispatcher.dispatch(new Be({channels:[Pt],source:je.EVENT_CHANNEL_HIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Pt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(he.channelUrl,!0)];case 66:return(Gt=bn.sent()).hiddenState=ts.UNHIDDEN,this._dispatcher.dispatch(new Be({channels:[Gt],source:je.EVENT_CHANNEL_UNHIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Gt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(he.channelUrl,!0)];case 68:return Vt=bn.sent(),this._dispatcher.dispatch(new qe({channelUrls:[he.channelUrl],source:je.EVENT_CHANNEL_DELETED})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Vt.url,Vt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(he.channelUrl,!0)];case 70:return qt=bn.sent(),this._dispatcher.dispatch(new Be({channels:[qt],source:je.EVENT_CHANNEL_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(he.channelUrl,!0)];case 72:return Bt=bn.sent(),jt=e.as(Ce),zt=jt.created,Qt=jt.updated,Wt=jt.deleted,zt&&Bt._upsertCachedMetaData(zt,he.ts),Qt&&Bt._upsertCachedMetaData(Qt,he.ts),Wt&&Bt._removeFromCachedMetaData(Wt,he.ts),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated(Bt,zt),Qt&&e.onMetaDataUpdated(Bt,Qt),Wt&&e.onMetaDataDeleted(Bt,Wt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(he.channelUrl,!0)];case 74:return Kt=bn.sent(),Yt=e.as(ye),Jt=Yt.created,Xt=Yt.updated,Zt=Yt.deleted,W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Jt&&e.onMetaCounterCreated(Kt,Jt),Xt&&e.onMetaCounterUpdated(Kt,Xt),Zt&&e.onMetaCounterDeleted(Kt,Zt)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(he.channelUrl,!0)];case 76:return $t=bn.sent(),en=e.as(Zn),tn=en.pinnedMessageIds,nn=en.latestPinnedMessage,(rn=en.ts)>$t._pinnedMessagesUpdatedAt&&($t.pinnedMessageIds=tn,$t.lastPinnedMessage=nn,$t._pinnedMessagesUpdatedAt=rn,this._dispatcher.dispatch(new Be({channels:[$t],source:je.EVENT_PINNED_MESSAGE_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged($t)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),W((function(){return f(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated($t)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((sn=e.as(Xe).event).category){case Ze.USER_BLOCK:an=$e.getDataAsUserBlockEvent(this._iid,sn),un=an.blocker,cn=an.blockee,this._groupChannelCache.block(un.userId,cn.userId);break;case Ze.USER_UNBLOCK:on=$e.getDataAsUserBlockEvent(this._iid,sn),un=on.blocker,cn=on.blockee,this._groupChannelCache.unblock(un.userId,cn.userId)}return[3,79];case 79:return[3,81];case 80:if(ln=bn.sent(),Q(ln))throw ln;return[3,81];case 81: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===xt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),f(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:Y(y("string",e)).throw(q.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),f(this,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(ln).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case $r.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case $r.UNREAD_MENTION_COUNT_ONLY:i=0;break;case $r.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return[2,o.sent()[0]]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=je.REFRESH_CHANNEL),f(this,void 0,void 0,(function(){var r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(ln).channel).myMemberState!==xt.NONE?[3,2]:(this._dispatcher.dispatch(new qe({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new Be({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==J.NON_AUTHORIZED&&o.code!==J.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new qe({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=je.REQUEST_CHANNEL),f(this,void 0,void 0,(function(){var i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return i=new hn(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(dn),u=o.channels,c=o.token,this._dispatcher.dispatch(new Be({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return f(this,void 0,void 0,(function(){return m(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=De),f(this,void 0,void 0,(function(){return m(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=De),f(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return f(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return f(this,void 0,void 0,(function(){return m(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 f(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Xn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=je.REQUEST_CHANNEL_CHANGELOGS),f(this,void 0,void 0,(function(){var i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return i=s(s({},Xt),t),Y((y("string",e)||y("number",e))&&Zt(i)).throw(q.invalidParameters),a=new on(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:i})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(un),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new Be({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new qe({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r;return m(this,(function(i){switch(i.label){case 0:return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(_n).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return f(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h,d,p,_,f,v,y,C;return m(this,(function(m){switch(m.label){case 0:return t=s(s({},tn),e),Y(function(e){return g(Qt,e.keys)}(t)).throw(q.invalidParameters),n=j.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new fn({userId:i.userId,filter:t}),[4,a.send(o)];case 1:return u=m.sent(),c=u.as(mn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,_=c.superGroupChannelUnreadMessageCount,f=c.superGroupChannelInvitationCount,v=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,C=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:_,superGroupChannelInvitationCount:f,nonSuperGroupChannelUnreadMentionCount:v,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:C})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(gn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},nn),e),Y(function(e){return g("string",e.channelCustomTypesFilter,!0)&&i(Ot,e.superChannelFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.sdkState,a=n.requestQueue,o=new yn({userId:r.userId,filter:t}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t,n,r,a;return m(this,(function(o){switch(o.label){case 0:return t=s(s({},rn),e),Y(function(e){return y("string",e.channelUrl,!0)&&g(gt,e.scheduledStatus,!0)&&i(E,e.messageTypeFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid).requestQueue,r=new En(t),[4,n.send(r)];case 1:return a=o.sent(),[2,a.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=j.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=j.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=j.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i;return m(this,(function(a){switch(a.label){case 0:return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),i=r.as(Sn).channel,[4,this.upsertChannelsToCache([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return e=Date.now(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Un({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=v(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(g("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Un({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=v(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.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var tr,nr=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return f(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],_(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],_(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],_(r),!1)),bottom:Math.max.apply(Math,d([],_(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,t.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return u.sent(),[3,6];case 5:throw s=u.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ir[t]||(ir[t]={}),ir[t][n.url]||(ir[t][n.url]=new e({_iid:t,channel:n})),ir[t][n.url].ref++,ir[t][n.url]},e.clear=function(e,t){ir[e]&&ir[e][t]&&(ir[e][t].close(),delete ir[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],_(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return f(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof q&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=j.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new nr(h,(function(){return f(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return m(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=j.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Pt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof q&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.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 f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){j.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=A.GET,c.path="".concat(ne(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,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(D),dr=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return Et(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return Et(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(L),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},_r=function(e,t,n){if(e.length>0){for(var r=pr(e,t),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,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:fr(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},fr=function(e,t,n){switch(n){case He.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 He.CHRONOLOGICAL:return t.createdAt-e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r}},mr=function(e,t){return t instanceof yt?e.findIndex((function(e){return e instanceof yt&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},gr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(tr||(tr={}));var Cr,Er,br,Mr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;W((function(){return f(r,void 0,void 0,(function(){return m(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}(),Nr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=e,this._key="mc-".concat(ae()),this.filter=null!=r?r:new Ye,this._channel=n,this._syncRange=new Xn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+yr,this._limit=i||De;var o=er.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=pr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case je.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED);break;case je.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case je.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case je.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}W((function(){return f(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),et(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),W((function(){return f(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=v(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(re(t)){if(s.length>0)switch(t){case K.EVENT_MESSAGE_SENT_FAILED:case K.EVENT_MESSAGE_SENT_SUCCESS:case K.EVENT_MESSAGE_UPDATED:case K.EVENT_MESSAGE_THREADINFO_UPDATED:case K.EVENT_MESSAGE_REACTION_UPDATED:case K.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case K.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case K.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case K.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=j.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=ar.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new nr(this._key,(function(e){return f(a,void 0,void 0,(function(){var t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)switch(e.stateType){case ee.CONNECTED:a._refreshChannel(je.SYNC_CHANNEL_CHANGELOGS),b((function(){return f(a,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),a._checkHugeGap();break;case ee.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],_(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],_(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=v(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===K.SYNC_MESSAGE_FILL){if(l.messageId>0){if((y=mr(this._messages,l))<0){mr(this._unsentMessages,l)<0&&a.push(l);var h=gr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof yt){(y=mr(this._unsentMessages,l))<0&&mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((y=mr(this._messages,l))<0){var p=mr(this._unsentMessages,l);p<0?a.push(l):(this._unsentMessages.splice(p,1),o.push(l));h=gr(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[y]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],_(g),!1))}}else if(l instanceof yt){var y;(y=mr(this._unsentMessages,l))<0?mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[y]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=v(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=v(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=mr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=mr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof yt)(c=mr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return re(t)&&a.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return f(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=er.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)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,d(d([],_(n),!1),_(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?K.REQUEST_MESSAGE:o,c=t.reverse,l=void 0!==c&&c,h=t.checkingContinuousMessages,d=void 0!==h&&h;return f(this,void 0,void 0,(function(){var t,n;return m(this,(function(i){switch(i.label){case 0:return t=St.of(this._iid),r>0||a>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),u,d)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,h,p,v,g,y,C,E,b,M,N,S,U=this;return m(this,(function(T){switch(T.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=er.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=T.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,i)];case 2:return u=T.sent(),[4,ue((function(){return f(U,void 0,void 0,(function(){var e,a,c,l,h,p,v,g,y,C,E,b,M,N,S,U,T,A,w,D,L,k=this;return m(this,(function(P){switch(P.label){case 0:return e=j.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new hr(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:i,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return p=P.sent(),v=p.as(dr),g=v.isHugeGap,y=v.prevMessages,C=void 0===y?[]:y,E=v.prevHasMore,b=v.isContinuousPrevMessages,M=v.nextMessages,N=void 0===M?[]:M,S=v.nextHasmore,U=v.isContinuousNextMessages,g?W((function(){return f(k,void 0,void 0,(function(){var e;return m(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=S,T=this.viewTop,A=this.viewBottom,w=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],_(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,d([0,A],_(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new I({messages:C,source:K.SYNC_MESSAGE_FILL})),a.dispatch(new I({messages:N,source:K.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||U)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),TD&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return T.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),T.label=5;case 5:return T.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(p=T.sent(),v=p.messages,g=p.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),C=0,E=0,b=0;b=h&&E++;this._hasPrevious=C>=l,this._hasNext=E>=l,(S=this._syncRange).extends.apply(S,d([],_(y),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,K.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(N=T.sent())instanceof q&&N.code===J.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return f(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,er.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+yr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){er.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return f(t,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=null,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=es.UNMUTED,n=new rr(je.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)},e.prototype.initialize=function(e){var t=this,n=new Mr;this._messages=[],this._unsentMessages=[],this._syncRange=new Xn({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(je.REFRESH_CHANNEL),b((function(){return f(t,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===tr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return f(t,void 0,void 0,(function(){var t;return m(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,K.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Q(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=j.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,p=0;p=t._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,d([],_(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,K.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(Q(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return f(this,void 0,void 0,(function(){var e,t,n,r=this;return m(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return f(r,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,b((function(){return f(r,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],_(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,K.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,d([],_(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,K.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,s=this;return m(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,b((function(){return f(s,void 0,void 0,(function(){var e;return m(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,b((function(){return f(s,void 0,void 0,(function(){var e,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,d([],_(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,K.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,K.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return f(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return[4,er.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=er.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ur={hidePreviousMessages:!1,allowAutoUnhide:!0},Tr=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=A.GET,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(D),Ir=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 jt(e,t)}))),r}return e(n,t),n}(L);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Cr||(Cr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Er||(Er={})),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"}(br||(br={}));var Ar=function(t){function n(e,n,r){var s,i,a,u,c=this;return(c=t.call(this,e,n,o.GROUP,r)||this).mutedMemberFilter=Cr.ALL,c.memberStateFilter=br.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Vt.ALL,c.order=Er.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Cr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:br.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(u=r.order)&&void 0!==u?u:Er.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&i(Cr,this.mutedMemberFilter)&&i(br,this.memberStateFilter)&&(y("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&i(Vt,this.operatorFilter)&&i(Er,this.order)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new Tr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ir),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce),wr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),Dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.JOINED,r}return e(n,t),n}(L),Lr=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,p=e.customType,_=e.operatorUserIds,f=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:_,message_survival_seconds:f}),n}return e(n,t),n}(D),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Rr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(D),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(L),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(D),Hr=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}(L),Gr=s(s({},Le),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Vr=s(s({},Pe),{scheduledAt:null}),qr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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?e.thumbnailSizes.map((function(e){return Ut.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}return e(n,t),n}(L),jr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new bt(e,n),r}e(n,t)}(L);var zr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.DELETE,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(D),Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.POST,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(D),Wr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(D),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(D),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Xr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.POST,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Zr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.DELETE,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var $r,es,ts,ns=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=Et(e,n.message),r}return e(n,t),n}(c),rs=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=A.GET,n.path="".concat(ne(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(D),ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.hasMore=null,r.token=null;var s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ns(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(L),is=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeMetaArray,!0)&&y("boolean",this.includeReactions,!0)&&y("boolean",this.includeParentMessageInfo,!0)&&y("boolean",this.includeThreadInfo,!0)&&y("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return m(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new rs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(ss),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce);!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"}($r||($r={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(es||(es={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ts||(ts={}));var as,os=function(t){function n(e,n){var r,c,l,h,p,f,m,v,g,C,E,b,M,N,S,U,T,I,A,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ts.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=xt.NONE,w.myRole=a.NONE,w.myMutedState=es.UNMUTED,w.myLastRead=0,w.myCountPreference=$r.ALL,w.myPushTriggerOption=pe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=o.GROUP,w.isDistinct=null!==(c=n.is_distinct)&&void 0!==c&&c,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(h=n.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(p=n.is_exclusive)&&void 0!==p&&p,w.isPublic=null!==(f=n.is_public)&&void 0!==f&&f,w.isDiscoverable=null!==(m=n.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=n.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,d([],_(n.members.map((function(e){return new jt(w._iid,e)}))),!1)),w.memberCount=null!==(C=n.member_count)&&void 0!==C?C:0,w.joinedMemberCount=null!==(E=n.joined_member_count)&&void 0!==E?E:0,w.hiddenState=i(ts,n.hidden_state)?n.hidden_state:ts.UNHIDDEN,w.messageOffsetTimestamp=null!==(b=n.ts_message_offset)&&void 0!==b?b:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?Et(w._iid,s({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){y("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){y("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=i(xt,n.member_state)?n.member_state:xt.NONE,w.myRole=i(a,n.my_role)?n.my_role:a.NONE,i(es,n.is_muted)?w.myMutedState=n.is_muted:y("boolean",n.is_muted)?w.myMutedState=n.is_muted?es.MUTED:es.UNMUTED:w.myMutedState=es.UNMUTED,w.myCountPreference=i($r,n.count_preference)?n.count_preference:$r.ALL,w.myPushTriggerOption=i(pe,n.push_trigger_option)?n.push_trigger_option:pe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new u(w._iid,n.inviter):null,w.invitedAt=null!==(S=n.invited_at)&&void 0!==S?S:0,w.joinedAt=null!==(U=n.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(I=n.unread_mention_count)&&void 0!==I?I:0),w.pinnedMessageIds=null!==(A=n.pinned_message_ids)&&void 0!==A?A:[],w.lastPinnedMessage=n.latest_pinned_message?Et(w._iid,s({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==ts.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=_(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=_(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),n.payloadify=function(e){return e?r(s(s({},t.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 jt.payloadify(e)})),last_message:At(e.lastMessage),inviter:e.inviter?u.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:At(e.lastPinnedMessage)})):null},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof yt&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=j.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===$r.ALL||this.myCountPreference===$r.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.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},n.prototype.isReadMessage=function(e){var t=j.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return H(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Nr(this._iid,s({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ar(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,this.url,this.channelType,e)},n.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===xt.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)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof jt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof yt&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=v(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===xt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=j.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof yt?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(ln).channel,this._update(i),n.dispatch(new Be({channels:[i],source:je.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},n.prototype.unfreeze=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},n.prototype.updateChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},Sr),e),Y(function(e){return y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isDiscoverable,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Lr(s({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(kr).channel,this._update(u),r.dispatch(new Be({channels:[u],source:je.EVENT_CHANNEL_UPDATED})),[2,this]}}))}))},n.prototype.invite=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(t){return Y(e.every((function(e){return e instanceof u}))).throw(q.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(g("string",e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Ln({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(kn).channel,this._update(a),n.dispatch(new Be({channels:[a],source:je.EVENT_CHANNEL_INVITED})),[2,this]}}))}))},n.prototype.join=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Tn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),f(this,void 0,void 0,(function(){var t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=xt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new wr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Dr).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=xt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===ts.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=ts.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),er.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new wt,s=j.of(this._iid).dispatcher;return t.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})).onFileUploaded((function(e,t,n,s){r._triggerOnFileUploaded(e,t,n,s)})),r},n.prototype.updateFileMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof yt&&j.of(this._iid).dispatcher.dispatch(new U({reqId:e.reqId,source:K.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=s(s({},Ur),e),Y(function(e){return y("boolean",e.hidePreviousMessages)&&y("boolean",e.allowAutoUnhide)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new qn(s({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Bn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},n.prototype.unhide=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ts.UNHIDDEN,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},n.prototype.delete=function(){return f(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Pr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(On).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Hn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=s(s({},nt),e),Y(rt(e)).throw(q.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return n=s(s({},Vr),t),Y(function(e){return xe(e)&&y("number",e.scheduledAt,!0)}(n)).throw(q.invalidParameters),r=j.of(this._iid).requestQueue,i=new jr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(Fe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},st),e),Y(it(e)).throw(q.invalidParameters);var n=Date.now(),r=this._generateRequestId(),i=new Dt;return de(Oe).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);W((function(){return f(t,void 0,void 0,(function(){return m(this,(function(e){return[2,i._trigger(null,s)]}))}))}))})),C(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,r,n)})):this._createScheduledFileMessage(e,i,r,n),i},n.prototype.updateScheduledFileMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i;return m(this,(function(a){switch(a.label){case 0:return n=s(s({},Gr),t),Y(function(e){return ke(e)&&y("number",e.scheduledAt,!0)&&(C(e.file)||y("string",e.fileUrl))&&y("string",e.fileName,!0)&&y("string",e.mimeType,!0)&&y("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return y("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(q.invalidParameters),C(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new qr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return i=a.sent(),[2,i.as(Br).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return f(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return f(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Jr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i(pe,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Wr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Kr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i($r,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Rr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Or({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Hr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Xr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Zr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return C(e.file)?(t=j.of(this._iid).requestQueue,n=new kt({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(Lt),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]}}))}))},n}(Re),us={},cs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=j.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new nr(l,(function(){return f(s,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(a.sent(),c.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:He.CHRONOLOGICAL},this._limit,je.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,d([],_(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),c.debug("channel background sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return us[t]||(us[t]=new e({_iid:t})),us[t].ref++,us[t]},e.clear=function(e){us[e]&&(us[e].close(),delete us[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Xn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n=j.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){j.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete us[this._iid])},e}(),ls={},hs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=j.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new nr(u,(function(){return f(n,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),i.debug("channel changelog sync from",this._metadata.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},je.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),i.debug("channel changelog sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(ae()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Wt,this.order=null!=r?r:He.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ge;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=cs.of(e),this._backgroundSync.resume()),this._changelogSync=hs.of(e),this._changelogSync.resume(),er.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(et(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)}}),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof $&&(e.stateType===ee.CONNECTED?i._isGetRemoteChannelsSucceeded||f(i,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===ee.LOGOUT&&i.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&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,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=v(e),d=h.next();!d.done;d=h.next()){var p=d.value,_=_r(this.channels,p,this.order),g=_.place,y=_.oldPosition;if(-1===y)g===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(g,0,p));else switch(t){case je.EVENT_CHANNEL_UPDATED:case je.EVENT_MESSAGE_RECEIVED:case je.SYNC_CHANNEL_CHANGELOGS:case je.EVENT_MESSAGE_SENT:g!==y?this._hasMore&&g===this.channels.length?l.push(p):(this.channels.splice(y,1),this.channels.splice(y0)try{for(var C=v(l),E=C.next();!E.done;E=C.next()){p=E.value;var b=pr(this.channels,p);-1!==b&&this.channels.splice(b,1)}}catch(e){i={error:e}}finally{try{E&&!E.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}et(t)&&W((function(){return f(o,void 0,void 0,(function(){var e,n,r,s;return m(this,(function(i){return e=new rr(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[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=v(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 et(t)&&i.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return f(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case He.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case He.CHRONOLOGICAL:return e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:null)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return f(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return[4,er.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,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return f(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,je.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return f(this,void 0,void 0,(function(){var e,t,n=this;return m(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new q({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,b((function(){return f(n,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,2]):[3,6];case 1:return r.sent(),this._hasMore=t.length>=this._limit,[3,5];case 2:return r.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return t=r.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return r.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(t,je.REQUEST_CHANNEL,!0),[2,t];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),er.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),ps=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,p=e.superChannelFilter,_=e.metadataOrderKeyFilter,f=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=A.GET,n.path=x,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:Rt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:_,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(D),_s=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 os(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(L);!function(e){e.ALL="all",e.JOINED="joined"}(as||(as={}));var fs=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,_,f,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=as.ALL,v.superChannelFilter=Ot.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=at.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:as.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ot.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(_=n.metadataOrderKeyFilter)&&void 0!==_?_:null,v.metadataValueStartsWith=null!==(f=n.metadataValueStartsWith)&&void 0!==f?f:null,v.order=null!==(m=n.order)&&void 0!==m?m:at.CHRONOLOGICAL,v}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter,!0)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter,!0)&&i(as,this.membershipFilter)&&i(Ot,this.superChannelFilter)&&i(at,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=j.of(this._iid),n=t.requestQueue,t.dispatcher,r=new ps(s(s({},this),{token:this._token})),[4,n.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(_s),o=a.channels,u=a.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),ms=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=_e,e.onUserLeft=_e,e.onUserReceivedInvitation=_e,e.onUserDeclinedInvitation=_e,e.onChannelHidden=_e,e.onUnreadMemberStatusUpdated=_e,e.onUndeliveredMemberStatusUpdated=_e,e.onTypingStatusUpdated=_e,e.onPollUpdated=_e,e.onPollVoted=_e,e.onPollDeleted=_e,e.onPinnedMessageUpdated=_e,e}return e(n,t),n}(vt)),vs=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=A.GET,n.path="".concat(R),n.params=r({token:s,limit:i,reverse:o,channel_url:u,order:a,message_type:c,status:l}),n}return e(n,t),n}(D),gs=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 Et(e,t)})),r}return e(n,t),n}(L),ys=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=E.ALL,u.channelUrl=null!==(r=n.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=n.order)&&void 0!==s?s:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:E.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("string",this.channelUrl,!0)&&(i(ot,this.order)||null===this.order)&&y("boolean",this.reverse)&&(g(gt,this.scheduledStatus)||null===this.scheduledStatus)&&i(E,this.messageTypeFilter)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new vs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(gs),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Cs=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 er(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new ds(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Jn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new fs(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ys(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(y("string",e)&&t instanceof ms).throw(q.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(y("string",e)).throw(q.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 f(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("string",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("number",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){return m(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 f(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){return m(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={}),f(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},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=""),f(this,void 0,void 0,(function(){var o;return m(this,(function(u){return o=s(s({},Yt),{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 f(this,void 0,void 0,(function(){return m(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(t){return Y(g("string",e)).throw(q.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return f(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(fe);export{$r as CountPreference,os as GroupChannel,ds as GroupChannelCollection,rr as GroupChannelEventContext,Wt as GroupChannelFilter,ms as GroupChannelHandler,Jn as GroupChannelListQuery,Cs as GroupChannelModule,Bt as GroupChannelSearchField,Gt as HiddenChannelFilter,ts as HiddenState,jt as Member,Er as MemberListOrder,Ar as MemberListQuery,xt as MemberState,br as MemberStateFilter,as as MembershipFilter,Nr as MessageCollection,Mr as MessageCollectionInitHandler,tr as MessageCollectionInitPolicy,sr as MessageEventContext,Cr as MutedMemberFilter,es as MutedState,Ft as MyMemberStateFilter,Vt as OperatorFilter,ns as PinnedMessage,is as PinnedMessageListQuery,Rt as PublicChannelFilter,fs as PublicGroupChannelListQuery,qt as QueryType,zt as ReadStatus,ys as ScheduledMessageListQuery,Ot as SuperChannelFilter,Ht as UnreadChannelFilter,Qt as UnreadItemKey}; +import{_ as e,e as r,g as s,K as i,T as a,O as o,U as u,$ as c,aE as h,q as d,r as f,b as _,c as m,J as v,m as g,a as y,i as C,a6 as E,I as b,aD as M,aF as N,aw as S,aG as U,aj as T,ai as I,A,d as w,f as D,h as L,aH as k,ag as x,aI as R,a9 as F,W as O,a2 as H,B as V,S as q,t as B,V as j,Q as z,aC as Q,y as W,ah as K,s as Y,ac as J,aJ as X,E as Z,w as $,x as ee,af as te,aa as ne,aK as re,aL as se,aM as ie,u as ae,a4 as oe,aN as ue,al as ce,a3 as le,aB as he,ad as de,M as pe,n as fe,am as _e}from"./lib/__bundle-a8f5769e.js";export{ah as MessageEventSource}from"./lib/__bundle-a8f5769e.js";import{g as me,N as ve,p as ge,q as ye,r as Ce,t as Ee,u as be,w as Me,x as Ne,y as Se,P as Ue,z as Te,A as Ie,C as Ae,E as we,D as De,G as Le,H as ke,I as Pe,J as xe,f as Re,K as Fe,L as Oe}from"./lib/__bundle-ad6d760f.js";import{G as He,g as Ge,D as Ve,l as qe,m as Be,n as je,j as ze,i as Qe,o as We,R as Ke,p as Ye,k as Je,U as Xe,e as Ze,f as $e,s as et,d as tt,S as nt,v as rt,q as st,r as it,P as at,t as ot}from"./lib/__bundle-d67b9997.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-d67b9997.js";import{C as ut,a as ct,O as lt,P as ht,M as dt,T as pt,R as ft,U as _t,A as mt,B as vt}from"./lib/__bundle-e21f40c4.js";import{l as gt,S as yt,I as Ct,p as Et,U as bt,F as Mt,m as Nt,c as St,T as Ut,d as Tt,A as It,n as At,g as wt,h as Dt,o as Lt,q as kt}from"./lib/__bundle-f20da9a5.js";export{l as ScheduledStatus}from"./lib/__bundle-f20da9a5.js";import{b as Pt}from"./lib/__bundle-6bc4500a.js";var xt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(xt||(xt={}));var Rt,Ft,Ot,Ht,Gt,Vt,qt,Bt,jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=i(xt,n.state)?n.state:null,r.role=i(a,n.role)?n.role:null,Object.prototype.hasOwnProperty.call(n,"is_muted")&&(r.isMuted=n.is_muted),Object.prototype.hasOwnProperty.call(n,"is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),Object.prototype.hasOwnProperty.call(n,"is_blocking_me")&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return e?r(s(s({},t.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},n}(me),zt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:o.GROUP,i.reader=new u(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Rt||(Rt={})),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"}(Ft||(Ft={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ht||(Ht={})),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"}(Gt||(Gt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Vt||(Vt={})),function(e){e.AND="AND",e.OR="OR"}(qt||(qt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Bt||(Bt={}));var Qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ft.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ot.ALL,this.publicChannelFilter=Rt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ht.ALL,this.hiddenChannelFilter=Gt.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=qt.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 Bt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Bt.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,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case qt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case qt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,c))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 l=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(l)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ft.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ft.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ft.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ft.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gt.HIDDEN:if(!e.isHidden)return!1;break;case Gt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ht.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Rt.PUBLIC:if(!e.isPublic)return!1;break;case Rt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ot.SUPER:if(!e.isSuper)return!1;break;case Ot.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Kt=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(ve):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 er.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],f(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===e.url)return!1;break;case He.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:m.sent(),m.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},n.prototype.unblock=function(e,t){return _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],f(this._channels.keys()),!1)),_(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=v(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}(c),Yt={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},Jt=function(e){return g("string",e.invitedUserIds,!0)&&y("string",e.channelUrl,!0)&&y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isSuper,!0)&&y("boolean",e.isBroadcast,!0)&&y("boolean",e.isExclusive,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isStrict,!0)&&y("boolean",e.isDiscoverable,!0)&&y("boolean",e.isEphemeral,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)},Xt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Zt=function(e){return g("string",e.customTypes,!0)&&y("boolean",e.includeEmpty)&&y("boolean",e.includeFrozen)},$t={myMemberStateFilter:Ft.ALL},en=function(e){return i(Ft,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"}(Qt||(Qt={}));var tn={keys:[]},nn={channelCustomTypesFilter:null,superChannelFilter:Ot.ALL},rn={channelUrl:null,scheduledStatus:null,messageTypeFilter:E.ALL},sn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return _(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,f,g,y,C=this;return m(this,(function(E){switch(E.label){case 0:if(!(e instanceof Be))return[3,10];s=e.channels,f=e.source,i=e.data,a=s.filter((function(e){return e instanceof os})),o=t.filterOffsetChanged(a),E.label=1;case 1:E.trys.push([1,6,7,8]),u=v(o),c=u.next(),E.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:E.sent(),E.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=E.sent(),g={error:h},[3,8];case 7:try{c&&!c.done&&(y=u.return)&&y.call(u)}finally{if(g)throw g.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=E.sent(),this._broadcastUpdateEvent(d,f,i),[3,15];case 10:return e instanceof qe?(p=e.channelUrls,f=e.source,[4,t.remove(p)]):[3,13];case 11:return E.sent(),[4,b((function(){return _(C,void 0,void 0,(function(){var e,t,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(p),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return E.sent(),this._broadcastRemoveEvent(p,f),[3,15];case 13:return e instanceof Ve?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:E.sent(),E.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=v(this._observers.values()),a=i.next();!a.done;a=i.next()){a.value.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),an=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return _(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,f,v,g=this;return m(this,(function(y){switch(y.label){case 0:return e instanceof I?(t=e.messages,f=e.source,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof yt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:y.sent(),this._broadcastUpdateEvent(s,f),y.label=2;case 2:return i.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:y.sent(),this._broadcastUpdateEvent(i,f),y.label=4;case 4:return[3,21];case 5:return e instanceof T?(a=e.messageIds,f=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return y.sent(),this._broadcastRemoveEvent(a,f),[3,21];case 7:return e instanceof U?(o=e.reqId,f=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return y.sent(),this._broadcastRemoveUnsentEvent(o,f),[3,21];case 9:return e instanceof S?(u=e.polls,f=e.source,this._cacheContext.localCacheEnabled?(c=u.map((function(e){return e.messageId})),[4,Promise.all(c.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(l=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=l.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(l)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,f),[3,21];case 13:return e instanceof N?(h=e.event,f=e.source,[4,n.get(h.messageId)]):[3,17];case 14:return(d=y.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(h)?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:y.sent(),y.label=16;case 16:return this._broadcastPollUpdateEvent(h,f),[3,21];case 17:return e instanceof M?(p=e.event,f=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:y.sent(),y.label=20;case 20:this._broadcastPollVoteEvent(p,f),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(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=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=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({},Xt),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=A.GET,u.path="".concat(w,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(D),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new os(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(L),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(r?k:x,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(D),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new os(e,n),r}return e(n,t),n}(L),hn=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,p=e.nicknameContainsFilter,f=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,S=e.includeFrozen,U=e.includeMetaData,T=e.searchFilter,I=e.userIdsFilter;return(n=t.call(this)||this).method=A.GET,n.path="".concat(w,"/").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:p,members_nickname_startswith:f,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:S,show_metadata:U}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),I&&I.userIds&&I.userIds.length>0&&(I.includeMode?(n.params.members_include_in=I.userIds,n.params.query_type=I.queryType.toUpperCase()):n.params.members_exactly_in=I.userIds),n}return e(n,t),n}(D),dn=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 os(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(L),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ft.ALL},s}return e(n,t),n}(D),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(L),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(D),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(L),vn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=A.GET,r.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(D),gn=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}(L),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ot.ALL,custom_types:i},s}return e(n,t),n}(D),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(L),En=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=A.GET,i.path="".concat(R,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(D),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(L),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case gt.PENDING:t.push(Ct.PENDING);break;case gt.SENT:t.push(Ct.IN_QUEUE),t.push(Ct.SENT);break;case gt.CANCELED:t.push(Ct.CANCELED);break;case gt.FAILED:t.push(Ct.FAILED)}})),t}},Nn=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,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=A.POST,n.path=x,n.params=r({user_ids:d([s],f(null!=M?M:[]),!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:l,is_exclusive:p,is_public:h,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(D),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(L),Un=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=A.PUT,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Tn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),An=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 jt(e,t)})):[new jt(e,r.data)],s}return e(n,t),n}(ut),wn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Dn=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 jt(s._iid,r.data),s}return e(n,t),n}(ut),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=A.POST,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(D),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pn=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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitees,f=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitees=f.map((function(t){return new jt(e,t)})),s}return e(n,t),n}(ut),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.NONE,r}e(n,t)}(L);var Rn=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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitee,f=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitee=f?new jt(e,f):null,s}return e(n,t),n}(ut),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(F),On=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new zt(e,r),s}return e(n,t),n}(O),Hn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=A.PUT,i.path="".concat(x,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Gn,Vn=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}(O),qn=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=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(D),Bn=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}(L),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(O),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(F),Qn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Wn=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}(F),Kn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Yn=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}(F),Jn=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v,g,y,C,E,b,M,N,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Ft.ALL,S.unreadChannelFilter=Ht.ALL,S.superChannelFilter=Ot.ALL,S.publicChannelFilter=Rt.ALL,S.hiddenChannelFilter=Gt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=He.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,S.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,S.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,S.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",S.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,S.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,S.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,S.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ft.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Ht.ALL,S.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ot.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Rt.ALL,S.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Gt.UNHIDDEN,S.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},S.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,S.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,S.order=null!==(N=n.order)&&void 0!==N?N:He.LATEST_LAST_MESSAGE,S}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter)&&y("string",this.nicknameContainsFilter,!0)&&y("string",this.nicknameStartsWithFilter,!0)&&y("string",this.nicknameExactMatchFilter,!0)&&i(Ft,this.myMemberStateFilter)&&i(Ot,this.superChannelFilter)&&i(Rt,this.publicChannelFilter)&&i(Ht,this.unreadChannelFilter)&&i(Gt,this.hiddenChannelFilter)&&g(Bt,this.searchFilter.fields)&&y("string",this.searchFilter.query,!0)&&g("string",this.userIdsFilter.userIds)&&y("boolean",this.userIdsFilter.includeMode)&&i(qt,this.userIdsFilter.queryType)&&i(He,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return H(this)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,er.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 q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Xn=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||w.unreadMentionCount>0)&&(w._updateUnreadCount(0,0),this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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!==w.unreadMessageCount&&0!==w.unreadMentionCount||(this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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 Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),bn.label=12;case 12:return[3,79];case 13:return D=e.as(Vn),ue=D.channelUrl,L=D.deliveredStateUpdate,k=void 0===L?{}:L,P=this._groupChannelCache.isCachedInMemory(ue),[4,this.getChannel(ue,!0)];case 14:if(x=bn.sent(),P)for(R in k)x._updateUndeliveredMemberState(R,k[R]);return Object.keys(k).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new Be({channels:[x],source:je.EVENT_CHANNEL_DELIVERED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(x)}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,79];case 15:return F=e.as(ft),ue=F.channelUrl,ce=F.channelType,O=F.event,ce!==o.GROUP?[3,18]:[4,this.getChannel(ue,!0)];case 16:return H=bn.sent(),[4,this.getMessageFromCache(O.messageId)];case 17:(q=bn.sent())&&(q.applyReactionEvent(O),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_REACTION_UPDATED}))),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(H,O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=18;case 18:return[3,79];case 19:return(G=e.as(pt).event).channelType!==o.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return V=bn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(q=bn.sent())&&(q.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_THREADINFO_UPDATED}))),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(V,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=22;case 22:return[3,79];case 23:B=e.as(dt).groupChannelMemberCounts,z=[],bn.label=24;case 24:bn.trys.push([24,29,30,31]),Y=v(B),J=Y.next(),bn.label=25;case 25:return J.done?[3,28]:(Z=J.value,ue=Z.channelUrl,nt=Z.memberCount,rt=Z.joinedMemberCount,$=Z.updatedAt,[4,this.getChannelFromCache(ue)]);case 26:(ee=bn.sent())&&ee._setLatestMemberCount(nt,rt,$)&&z.push(ee),bn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=bn.sent(),pn={error:te},[3,31];case 30:try{J&&!J.done&&(fn=Y.return)&&fn.call(Y)}finally{if(pn)throw pn.error}return[7];case 31:return z.length>0&&(this._dispatcher.dispatch(new Be({channels:z,source:je.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(z)}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,79];case 32:return ne=e.as(ht),re=ne.event,se=ne.status,ue=ne.channelUrl,ce=ne.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,34];case 33:ie=bn.sent(),this._dispatcher.dispatch(new N({event:re,source:K.EVENT_POLL_UPDATED})),W(se===X?function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(ie,re.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(ie,re)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),bn.label=34;case 34:return[3,79];case 35:return ae=e.as(Ue),oe=ae.event,ue=ae.channelUrl,ce=ae.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,37];case 36:le=bn.sent(),this._dispatcher.dispatch(new M({event:oe,source:K.EVENT_POLL_VOTED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(le,oe)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=37;case 37:return[3,79];case 38:if(!(he=e.as(ut).event).isGroupChannelEvent)return[3,77];switch(he.category){case ct.CHANNEL_JOIN:return[3,39];case ct.CHANNEL_LEAVE:return[3,41];case ct.CHANNEL_OPERATOR_UPDATE:return[3,45];case ct.CHANNEL_INVITE:return[3,47];case ct.CHANNEL_DECLINE_INVITE:return[3,49];case ct.TYPING_START:case ct.TYPING_END:return[3,51];case ct.USER_CHANNEL_MUTE:case ct.USER_CHANNEL_UNMUTE:return[3,53];case ct.USER_CHANNEL_BAN:return[3,55];case ct.USER_CHANNEL_UNBAN:return[3,59];case ct.CHANNEL_FREEZE:case ct.CHANNEL_UNFREEZE:return[3,61];case ct.CHANNEL_HIDE:return[3,63];case ct.CHANNEL_UNHIDE:return[3,65];case ct.CHANNEL_DELETED:return[3,67];case ct.CHANNEL_PROP_CHANGED:return[3,69];case ct.CHANNEL_META_DATA_CHANGED:return[3,71];case ct.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case ct.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(he.channelUrl,!0)];case 40:return de=bn.sent(),pe=e.as(An),fe=pe.memberCount,_e=pe.joinedMemberCount,me=pe.members,ve=!1,me.forEach((function(e){de.isExclusive||de.isSuper||de.isBroadcast?ve=ve||de._setLatestMemberCount(fe,_e,he.ts):(e.state=xt.JOINED,de.addMember(e,he.ts),En._updateJoinedMemberCount(de)),e.userId===En._sdkState.userId&&(de.myMemberState=xt.JOINED)})),this._dispatcher.dispatch(new Be({channels:[de],source:je.EVENT_CHANNEL_JOINED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=v(me),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(de,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}de.isBroadcast&&ve&&e.onChannelMemberCountChanged([de])})),[2]}))}))})),[3,77];case 41:return(Ut=this._leftChannels.get(he.channelUrl))?(De=Ut.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(he.channelUrl,!0)];case 43:De=bn.sent(),bn.label=44;case 44:return ge=De,Le=e.as(Dn),nt=Le.memberCount,rt=Le.joinedMemberCount,ke=Le.member,Pe=!1,xe=j.of(this._iid).appInfo,ge.isExclusive||ge.isSuper||ge.isBroadcast?Pe=ge._setLatestMemberCount(nt,rt,he.ts):(xe.enabledChannelMemberShipHistory?(ge.members.find((function(e){return e.userId===ke.userId})).state=xt.LEFT,ge.memberCount=nt):ge.removeMember(ke),this._updateJoinedMemberCount(ge)),ke.userId===this._sdkState.userId?(ge.myMemberState=xt.NONE,ge.invitedAt=0,ge.joinedAt=0,ge._updateUnreadCount(0,0),ge.isPublic?this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ge),this._dispatcher.dispatch(new qe({channelUrls:[ge.url],source:je.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ge,ke),ge.isBroadcast&&Pe&&e.onChannelMemberCountChanged([ge])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(he.channelUrl,!0)];case 46:Re=bn.sent(),Fe=e.as(lt).operators,Oe=Fe.map((function(e){return e.userId}));try{for(He=v(Re.members),Ge=He.next();!Ge.done;Ge=He.next())(St=Ge.value).role=Oe.includes(St.userId)?a.OPERATOR:a.NONE}catch(e){_n={error:e}}finally{try{Ge&&!Ge.done&&(mn=He.return)&&mn.call(He)}finally{if(_n)throw _n.error}}return Re.myRole=Oe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new Be({channels:[Re],source:je.EVENT_CHANNEL_OPERATOR_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Re,Fe)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(he.channelUrl,!0)];case 48:Ve=bn.sent(),ze=e.as(Pn),nt=ze.memberCount,rt=ze.joinedMemberCount,Qe=ze.inviter,(We=ze.invitees).forEach((function(e){return e.state=xt.INVITED}));try{for(Ke=v(We),Ye=Ke.next();!Ye.done;Ye=Ke.next())Je=Ye.value,Ve.isExclusive||Ve.isSuper||Ve.isBroadcast?Ve._setLatestMemberCount(nt,rt,he.ts):Ve.addMember(Je,he.ts),this._sdkState.userId===Je.userId&&(Ve.hiddenState=ts.UNHIDDEN,Ve.myMemberState!==xt.JOINED&&(Ve.myMemberState=xt.INVITED),Ve.invitedAt=he.ts)}catch(e){vn={error:e}}finally{try{Ye&&!Ye.done&&(gn=Ke.return)&&gn.call(Ke)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new Be({channels:[Ve],source:je.EVENT_CHANNEL_INVITED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ve,Qe,We)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(he.channelUrl,!0)];case 50:return et=bn.sent(),tt=e.as(Rn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,it=tt.invitee,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(nt,rt,he.ts):et.removeMember(it),this._sdkState.userId===it.userId?(et.invitedAt=0,et.myMemberState=xt.NONE,et.isPublic?this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new qe({channelUrls:[et.url],source:je.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(et,st,it)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(he.channelUrl,!0)];case 52:return at=bn.sent(),ot=he.category===ct.TYPING_START,vt=e.as(ot?Qn:Kn).user,at._updateTypingStatus(vt,ot?he.ts:0),this._dispatcher.dispatch(new Be({channels:[at],source:je.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(at)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(he.channelUrl,!0)];case 54:gt=bn.sent(),Ct=he.category===ct.USER_CHANNEL_MUTE,(Et=e.as(Ct?Ne:Se).user).userId===this._sdkState.userId&&(gt.myMutedState=Ct?es.MUTED:es.UNMUTED,gt._myMutedRemainingTime=Et.restrictionInfo.remainingDuration);try{for(bt=v(gt.members),Mt=bt.next();!Mt.done;Mt=bt.next())if((St=Mt.value).userId===Et.userId){St.isMuted=Ct;break}}catch(e){yn={error:e}}finally{try{Mt&&!Mt.done&&(Cn=bt.return)&&Cn.call(bt)}finally{if(yn)throw yn.error}}return this._dispatcher.dispatch(new Be({channels:[gt],source:Ct?je.EVENT_CHANNEL_MUTED:je.EVENT_CHANNEL_UNMUTED,data:Et.userId})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted(gt,Et):e.onUserUnmuted(gt,Et)})),[2]}))}))})),[3,77];case 55:return(Ut=this._leftChannels.get(he.channelUrl))?(It=Ut.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(he.channelUrl,!0)];case 57:It=bn.sent(),bn.label=58;case 58:return Tt=It,this._markAsLeave(Tt),At=e.as(Me).user,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Tt,At)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(he.channelUrl,!0)];case 60:return wt=bn.sent(),Dt=e.as(be).user,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(wt,Dt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(he.channelUrl,!0)];case 62:return Lt=bn.sent(),kt=e.as(Ee).freeze,Lt.isFrozen=kt,this._dispatcher.dispatch(new Be({channels:[Lt],source:kt?je.EVENT_CHANNEL_FROZEN:je.EVENT_CHANNEL_UNFROZEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen(Lt):e.onChannelUnfrozen(Lt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(he.channelUrl,!0)];case 64:return Pt=bn.sent(),Rt=e.as(jn),Ft=Rt.allowAutoUnhide,Ot=Rt.hidePreviousMessages,Ht=Rt.messageOffsetTimestamp,null!==Ft&&(Pt.hiddenState=Ft?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ot&&Ot&&Pt._updateUnreadCount(0,0),null!==Ht&&(Pt.messageOffsetTimestamp=Ht),this._dispatcher.dispatch(new Be({channels:[Pt],source:je.EVENT_CHANNEL_HIDDEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Pt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(he.channelUrl,!0)];case 66:return(Gt=bn.sent()).hiddenState=ts.UNHIDDEN,this._dispatcher.dispatch(new Be({channels:[Gt],source:je.EVENT_CHANNEL_UNHIDDEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Gt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(he.channelUrl,!0)];case 68:return Vt=bn.sent(),this._dispatcher.dispatch(new qe({channelUrls:[he.channelUrl],source:je.EVENT_CHANNEL_DELETED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Vt.url,Vt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(he.channelUrl,!0)];case 70:return qt=bn.sent(),this._dispatcher.dispatch(new Be({channels:[qt],source:je.EVENT_CHANNEL_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(he.channelUrl,!0)];case 72:return Bt=bn.sent(),jt=e.as(Ce),zt=jt.created,Qt=jt.updated,Wt=jt.deleted,zt&&Bt._upsertCachedMetaData(zt,he.ts),Qt&&Bt._upsertCachedMetaData(Qt,he.ts),Wt&&Bt._removeFromCachedMetaData(Wt,he.ts),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated(Bt,zt),Qt&&e.onMetaDataUpdated(Bt,Qt),Wt&&e.onMetaDataDeleted(Bt,Wt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(he.channelUrl,!0)];case 74:return Kt=bn.sent(),Yt=e.as(ye),Jt=Yt.created,Xt=Yt.updated,Zt=Yt.deleted,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Jt&&e.onMetaCounterCreated(Kt,Jt),Xt&&e.onMetaCounterUpdated(Kt,Xt),Zt&&e.onMetaCounterDeleted(Kt,Zt)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(he.channelUrl,!0)];case 76:return $t=bn.sent(),en=e.as(Zn),tn=en.pinnedMessageIds,nn=en.latestPinnedMessage,(rn=en.ts)>$t._pinnedMessagesUpdatedAt&&($t.pinnedMessageIds=tn,$t.lastPinnedMessage=nn,$t._pinnedMessagesUpdatedAt=rn,this._dispatcher.dispatch(new Be({channels:[$t],source:je.EVENT_PINNED_MESSAGE_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged($t)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated($t)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((sn=e.as(Xe).event).category){case Ze.USER_BLOCK:an=$e.getDataAsUserBlockEvent(this._iid,sn),un=an.blocker,cn=an.blockee,this._groupChannelCache.block(un.userId,cn.userId);break;case Ze.USER_UNBLOCK:on=$e.getDataAsUserBlockEvent(this._iid,sn),un=on.blocker,cn=on.blockee,this._groupChannelCache.unblock(un.userId,cn.userId)}return[3,79];case 79:return[3,81];case 80:if(ln=bn.sent(),Q(ln))throw ln;return[3,81];case 81: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===xt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:Y(y("string",e)).throw(q.invalidParameters),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=r.sent())?[2,n]:[3,4];case 3:return r.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,r.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),_(this,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(ln).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case $r.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case $r.UNREAD_MENTION_COUNT_ONLY:i=0;break;case $r.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return[2,o.sent()[0]]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=je.REFRESH_CHANNEL),_(this,void 0,void 0,(function(){var r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(ln).channel).myMemberState!==xt.NONE?[3,2]:(this._dispatcher.dispatch(new qe({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new Be({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==J.NON_AUTHORIZED&&o.code!==J.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new qe({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=je.REQUEST_CHANNEL),_(this,void 0,void 0,(function(){var i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return i=new hn(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(dn),u=o.channels,c=o.token,this._dispatcher.dispatch(new Be({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return _(this,void 0,void 0,(function(){return m(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=De),_(this,void 0,void 0,(function(){return m(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=De),_(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},e.prototype.getCachedMessageCountBetween=function(e,t,n,r){return _(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Xn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=je.REQUEST_CHANNEL_CHANGELOGS),_(this,void 0,void 0,(function(){var i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return i=s(s({},Xt),t),Y((y("string",e)||y("number",e))&&Zt(i)).throw(q.invalidParameters),a=new on(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:i})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(un),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new Be({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new qe({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r;return m(this,(function(i){switch(i.label){case 0:return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return _(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h,d,p,f,_,v,y,C;return m(this,(function(m){switch(m.label){case 0:return t=s(s({},tn),e),Y(function(e){return g(Qt,e.keys)}(t)).throw(q.invalidParameters),n=j.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new _n({userId:i.userId,filter:t}),[4,a.send(o)];case 1:return u=m.sent(),c=u.as(mn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,f=c.superGroupChannelUnreadMessageCount,_=c.superGroupChannelInvitationCount,v=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,C=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:f,superGroupChannelInvitationCount:_,nonSuperGroupChannelUnreadMentionCount:v,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:C})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(gn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},nn),e),Y(function(e){return g("string",e.channelCustomTypesFilter,!0)&&i(Ot,e.superChannelFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.sdkState,a=n.requestQueue,o=new yn({userId:r.userId,filter:t}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t,n,r,a;return m(this,(function(o){switch(o.label){case 0:return t=s(s({},rn),e),Y(function(e){return y("string",e.channelUrl,!0)&&g(gt,e.scheduledStatus,!0)&&i(E,e.messageTypeFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid).requestQueue,r=new En(t),[4,n.send(r)];case 1:return a=o.sent(),[2,a.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=j.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=j.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=j.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i;return m(this,(function(a){switch(a.label){case 0:return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),i=r.as(Sn).channel,[4,this.upsertChannelsToCache([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return e=Date.now(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Un({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=v(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(g("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Un({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=v(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.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},e}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var tr,nr=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],f(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],f(r),!1)),bottom:Math.max.apply(Math,d([],f(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],f(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],f(r),!1)),bottom:Math.max.apply(Math,d([],f(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,t.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return u.sent(),[3,6];case 5:throw s=u.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ir[t]||(ir[t]={}),ir[t][n.url]||(ir[t][n.url]=new e({_iid:t,channel:n})),ir[t][n.url].ref++,ir[t][n.url]},e.clear=function(e,t){ir[e]&&ir[e][t]&&(ir[e][t].close(),delete ir[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,d([],f(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],f(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof q&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=j.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new nr(h,(function(){return _(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return m(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=j.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Pt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof q&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){j.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=A.GET,c.path="".concat(ne(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,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(D),dr=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return Et(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return Et(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(L),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){for(var r=pr(e,t),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,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:_r(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},_r=function(e,t,n){switch(n){case He.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 He.CHRONOLOGICAL:return t.createdAt-e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r}},mr=function(e,t){return t instanceof yt?e.findIndex((function(e){return e instanceof yt&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},gr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(tr||(tr={}));var Cr,Er,br,Mr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;W((function(){return _(r,void 0,void 0,(function(){return m(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}(),Nr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=e,this._key="mc-".concat(ae()),this.filter=null!=r?r:new Ye,this._channel=n,this._syncRange=new Xn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+yr,this._limit=i||De;var o=er.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=pr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case je.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED);break;case je.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case je.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case je.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}W((function(){return _(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),et(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),W((function(){return _(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=v(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(re(t)){if(s.length>0)switch(t){case K.EVENT_MESSAGE_SENT_FAILED:case K.EVENT_MESSAGE_SENT_SUCCESS:case K.EVENT_MESSAGE_UPDATED:case K.EVENT_MESSAGE_THREADINFO_UPDATED:case K.EVENT_MESSAGE_REACTION_UPDATED:case K.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case K.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case K.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case K.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=j.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=ar.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new nr(this._key,(function(e){return _(a,void 0,void 0,(function(){var t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)switch(e.stateType){case ee.CONNECTED:a._refreshChannel(je.SYNC_CHANNEL_CHANGELOGS),b((function(){return _(a,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),a._checkHugeGap();break;case ee.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],f(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],f(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],f(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=v(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===K.SYNC_MESSAGE_FILL){if(l.messageId>0){if((y=mr(this._messages,l))<0){mr(this._unsentMessages,l)<0&&a.push(l);var h=gr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof yt){(y=mr(this._unsentMessages,l))<0&&mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((y=mr(this._messages,l))<0){var p=mr(this._unsentMessages,l);p<0?a.push(l):(this._unsentMessages.splice(p,1),o.push(l));h=gr(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[y]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],f(g),!1))}}else if(l instanceof yt){var y;(y=mr(this._unsentMessages,l))<0?mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[y]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=v(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&re(t)&&W((function(){return _(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&re(t)&&W((function(){return _(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=v(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=mr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=mr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof yt)(c=mr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return re(t)&&a.length>0&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return _(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=er.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)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,d(d([],f(n),!1),f(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?K.REQUEST_MESSAGE:o,c=t.reverse,l=void 0!==c&&c,h=t.checkingContinuousMessages,d=void 0!==h&&h;return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(i){switch(i.label){case 0:return t=St.of(this._iid),r>0||a>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),u,d)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,h,p,v,g,y,C,E,b,M,N,S,U=this;return m(this,(function(T){switch(T.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=er.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=T.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,i)];case 2:return u=T.sent(),[4,ue((function(){return _(U,void 0,void 0,(function(){var e,a,c,l,h,p,v,g,y,C,E,b,M,N,S,U,T,A,w,D,L,k=this;return m(this,(function(P){switch(P.label){case 0:return e=j.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new hr(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:i,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return p=P.sent(),v=p.as(dr),g=v.isHugeGap,y=v.prevMessages,C=void 0===y?[]:y,E=v.prevHasMore,b=v.isContinuousPrevMessages,M=v.nextMessages,N=void 0===M?[]:M,S=v.nextHasmore,U=v.isContinuousNextMessages,g?W((function(){return _(k,void 0,void 0,(function(){var e;return m(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=S,T=this.viewTop,A=this.viewBottom,w=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],f(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,d([0,A],f(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new I({messages:C,source:K.SYNC_MESSAGE_FILL})),a.dispatch(new I({messages:N,source:K.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||U)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),TD&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return T.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),T.label=5;case 5:return T.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(p=T.sent(),v=p.messages,g=p.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),C=0,E=0,b=0;b=h&&E++;this._hasPrevious=C>=l,this._hasNext=E>=l,(S=this._syncRange).extends.apply(S,d([],f(y),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,K.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(N=T.sent())instanceof q&&N.code===J.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,er.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+yr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){er.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return _(t,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=null,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=es.UNMUTED,n=new rr(je.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)},e.prototype.initialize=function(e){var t=this,n=new Mr;this._messages=[],this._unsentMessages=[],this._syncRange=new Xn({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(je.REFRESH_CHANNEL),b((function(){return _(t,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===tr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return _(t,void 0,void 0,(function(){var t;return m(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,K.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Q(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=j.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,p=0;p=t._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,d([],f(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,K.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(Q(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return _(this,void 0,void 0,(function(){var e,t,n,r=this;return m(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return _(r,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,b((function(){return _(r,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,K.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,K.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return _(this,void 0,void 0,(function(){var t,n,r,s=this;return m(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,b((function(){return _(s,void 0,void 0,(function(){var e;return m(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,b((function(){return _(s,void 0,void 0,(function(){var e,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,d([],f(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,K.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,K.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return[4,er.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=er.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ur={hidePreviousMessages:!1,allowAutoUnhide:!0},Tr=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=A.GET,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(D),Ir=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 jt(e,t)}))),r}return e(n,t),n}(L);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Cr||(Cr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Er||(Er={})),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"}(br||(br={}));var Ar=function(t){function n(e,n,r){var s,i,a,u,c=this;return(c=t.call(this,e,n,o.GROUP,r)||this).mutedMemberFilter=Cr.ALL,c.memberStateFilter=br.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Vt.ALL,c.order=Er.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Cr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:br.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(u=r.order)&&void 0!==u?u:Er.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&i(Cr,this.mutedMemberFilter)&&i(br,this.memberStateFilter)&&(y("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&i(Vt,this.operatorFilter)&&i(Er,this.order)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new Tr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ir),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce),wr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),Dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.JOINED,r}return e(n,t),n}(L),Lr=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,p=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:_}),n}return e(n,t),n}(D),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Rr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(D),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(L),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(D),Hr=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}(L),Gr=s(s({},Le),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Vr=s(s({},Pe),{scheduledAt:null}),qr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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?e.thumbnailSizes.map((function(e){return Ut.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}return e(n,t),n}(L),jr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new bt(e,n),r}e(n,t)}(L);var zr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.DELETE,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(D),Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.POST,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(D),Wr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(D),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(D),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Xr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.POST,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Zr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.DELETE,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var $r,es,ts,ns=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=Et(e,n.message),r}return e(n,t),n}(c),rs=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=A.GET,n.path="".concat(ne(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(D),ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.hasMore=null,r.token=null;var s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ns(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(L),is=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeMetaArray,!0)&&y("boolean",this.includeReactions,!0)&&y("boolean",this.includeParentMessageInfo,!0)&&y("boolean",this.includeThreadInfo,!0)&&y("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return m(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new rs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(ss),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce);!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"}($r||($r={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(es||(es={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ts||(ts={}));var as,os=function(t){function n(e,n){var r,c,l,h,p,_,m,v,g,C,E,b,M,N,S,U,T,I,A,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ts.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=xt.NONE,w.myRole=a.NONE,w.myMutedState=es.UNMUTED,w.myLastRead=0,w.myCountPreference=$r.ALL,w.myPushTriggerOption=pe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=o.GROUP,w.isDistinct=null!==(c=n.is_distinct)&&void 0!==c&&c,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(h=n.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(p=n.is_exclusive)&&void 0!==p&&p,w.isPublic=null!==(_=n.is_public)&&void 0!==_&&_,w.isDiscoverable=null!==(m=n.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=n.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,d([],f(n.members.map((function(e){return new jt(w._iid,e)}))),!1)),w.memberCount=null!==(C=n.member_count)&&void 0!==C?C:0,w.joinedMemberCount=null!==(E=n.joined_member_count)&&void 0!==E?E:0,w.hiddenState=i(ts,n.hidden_state)?n.hidden_state:ts.UNHIDDEN,w.messageOffsetTimestamp=null!==(b=n.ts_message_offset)&&void 0!==b?b:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?Et(w._iid,s({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){y("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){y("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=i(xt,n.member_state)?n.member_state:xt.NONE,w.myRole=i(a,n.my_role)?n.my_role:a.NONE,i(es,n.is_muted)?w.myMutedState=n.is_muted:y("boolean",n.is_muted)?w.myMutedState=n.is_muted?es.MUTED:es.UNMUTED:w.myMutedState=es.UNMUTED,w.myCountPreference=i($r,n.count_preference)?n.count_preference:$r.ALL,w.myPushTriggerOption=i(pe,n.push_trigger_option)?n.push_trigger_option:pe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new u(w._iid,n.inviter):null,w.invitedAt=null!==(S=n.invited_at)&&void 0!==S?S:0,w.joinedAt=null!==(U=n.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(I=n.unread_mention_count)&&void 0!==I?I:0),w.pinnedMessageIds=null!==(A=n.pinned_message_ids)&&void 0!==A?A:[],w.lastPinnedMessage=n.latest_pinned_message?Et(w._iid,s({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==ts.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=f(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(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=f(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}),n.payloadify=function(e){return e?r(s(s({},t.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 jt.payloadify(e)})),last_message:At(e.lastMessage),inviter:e.inviter?u.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:At(e.lastPinnedMessage)})):null},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof yt&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=j.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===$r.ALL||this.myCountPreference===$r.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.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},n.prototype.isReadMessage=function(e){var t=j.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return H(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Nr(this._iid,s({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ar(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,this.url,this.channelType,e)},n.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===xt.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)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof jt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof yt&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=v(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===xt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=j.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof yt?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(ln).channel,this._update(i),n.dispatch(new Be({channels:[i],source:je.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},n.prototype.unfreeze=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},n.prototype.updateChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},Sr),e),Y(function(e){return y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isDiscoverable,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Lr(s({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(kr).channel,this._update(u),r.dispatch(new Be({channels:[u],source:je.EVENT_CHANNEL_UPDATED})),[2,this]}}))}))},n.prototype.invite=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(e.every((function(e){return e instanceof u}))).throw(q.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(g("string",e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Ln({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(kn).channel,this._update(a),n.dispatch(new Be({channels:[a],source:je.EVENT_CHANNEL_INVITED})),[2,this]}}))}))},n.prototype.join=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Tn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),_(this,void 0,void 0,(function(){var t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=xt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new wr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Dr).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=xt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===ts.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=ts.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),er.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return _(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new wt,s=j.of(this._iid).dispatcher;return t.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})).onFileUploaded((function(e,t,n,s){r._triggerOnFileUploaded(e,t,n,s)})),r},n.prototype.updateFileMessage=function(e,n){return _(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof yt&&j.of(this._iid).dispatcher.dispatch(new U({reqId:e.reqId,source:K.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=s(s({},Ur),e),Y(function(e){return y("boolean",e.hidePreviousMessages)&&y("boolean",e.allowAutoUnhide)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new qn(s({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Bn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},n.prototype.unhide=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ts.UNHIDDEN,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},n.prototype.delete=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Pr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(On).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Hn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=s(s({},nt),e),Y(rt(e)).throw(q.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return n=s(s({},Vr),t),Y(function(e){return xe(e)&&y("number",e.scheduledAt,!0)}(n)).throw(q.invalidParameters),r=j.of(this._iid).requestQueue,i=new jr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(Fe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},st),e),Y(it(e)).throw(q.invalidParameters);var n=Date.now(),r=this._generateRequestId(),i=new Dt;return de(Oe).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);W((function(){return _(t,void 0,void 0,(function(){return m(this,(function(e){return[2,i._trigger(null,s)]}))}))}))})),C(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,r,n)})):this._createScheduledFileMessage(e,i,r,n),i},n.prototype.updateScheduledFileMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,i;return m(this,(function(a){switch(a.label){case 0:return n=s(s({},Gr),t),Y(function(e){return ke(e)&&y("number",e.scheduledAt,!0)&&(C(e.file)||y("string",e.fileUrl))&&y("string",e.fileName,!0)&&y("string",e.mimeType,!0)&&y("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return y("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(q.invalidParameters),C(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new qr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return i=a.sent(),[2,i.as(Br).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Jr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i(pe,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Wr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Kr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i($r,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Rr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Or({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Hr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Xr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Zr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return C(e.file)?(t=j.of(this._iid).requestQueue,n=new kt({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(Lt),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]}}))}))},n}(Re),us={},cs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=j.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new nr(l,(function(){return _(s,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(a.sent(),c.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:He.CHRONOLOGICAL},this._limit,je.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),c.debug("channel background sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return us[t]||(us[t]=new e({_iid:t})),us[t].ref++,us[t]},e.clear=function(e){us[e]&&(us[e].close(),delete us[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Xn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n=j.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){j.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete us[this._iid])},e}(),ls={},hs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=j.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new nr(u,(function(){return _(n,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),i.debug("channel changelog sync from",this._metadata.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},je.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),i.debug("channel changelog sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(ae()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Wt,this.order=null!=r?r:He.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ge;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=cs.of(e),this._backgroundSync.resume()),this._changelogSync=hs.of(e),this._changelogSync.resume(),er.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(et(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)}}),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof $&&(e.stateType===ee.CONNECTED?i._isGetRemoteChannelsSucceeded||_(i,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===ee.LOGOUT&&i.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&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,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=v(e),d=h.next();!d.done;d=h.next()){var p=d.value,f=fr(this.channels,p,this.order),g=f.place,y=f.oldPosition;if(-1===y)g===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(g,0,p));else switch(t){case je.EVENT_CHANNEL_UPDATED:case je.EVENT_MESSAGE_RECEIVED:case je.SYNC_CHANNEL_CHANGELOGS:case je.EVENT_MESSAGE_SENT:g!==y?this._hasMore&&g===this.channels.length?l.push(p):(this.channels.splice(y,1),this.channels.splice(y0)try{for(var C=v(l),E=C.next();!E.done;E=C.next()){p=E.value;var b=pr(this.channels,p);-1!==b&&this.channels.splice(b,1)}}catch(e){i={error:e}}finally{try{E&&!E.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}et(t)&&W((function(){return _(o,void 0,void 0,(function(){var e,n,r,s;return m(this,(function(i){return e=new rr(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[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=v(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 et(t)&&i.length>0&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case He.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case He.CHRONOLOGICAL:return e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:null)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return _(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return[4,er.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,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,je.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return _(this,void 0,void 0,(function(){var e,t,n=this;return m(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new q({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,b((function(){return _(n,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,2]):[3,6];case 1:return r.sent(),this._hasMore=t.length>=this._limit,[3,5];case 2:return r.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return t=r.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return r.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(t,je.REQUEST_CHANNEL,!0),[2,t];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),er.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),ps=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,p=e.superChannelFilter,f=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=A.GET,n.path=x,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:Rt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:f,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(D),fs=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 os(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(L);!function(e){e.ALL="all",e.JOINED="joined"}(as||(as={}));var _s=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=as.ALL,v.superChannelFilter=Ot.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=at.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:as.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ot.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:at.CHRONOLOGICAL,v}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter,!0)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter,!0)&&i(as,this.membershipFilter)&&i(Ot,this.superChannelFilter)&&i(at,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=j.of(this._iid),n=t.requestQueue,t.dispatcher,r=new ps(s(s({},this),{token:this._token})),[4,n.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(fs),o=a.channels,u=a.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),ms=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=fe,e.onUserLeft=fe,e.onUserReceivedInvitation=fe,e.onUserDeclinedInvitation=fe,e.onChannelHidden=fe,e.onUnreadMemberStatusUpdated=fe,e.onUndeliveredMemberStatusUpdated=fe,e.onTypingStatusUpdated=fe,e.onPollUpdated=fe,e.onPollVoted=fe,e.onPollDeleted=fe,e.onPinnedMessageUpdated=fe,e}return e(n,t),n}(vt)),vs=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=A.GET,n.path="".concat(R),n.params=r({token:s,limit:i,reverse:o,channel_url:u,order:a,message_type:c,status:l}),n}return e(n,t),n}(D),gs=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 Et(e,t)})),r}return e(n,t),n}(L),ys=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=E.ALL,u.channelUrl=null!==(r=n.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=n.order)&&void 0!==s?s:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:E.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("string",this.channelUrl,!0)&&(i(ot,this.order)||null===this.order)&&y("boolean",this.reverse)&&(g(gt,this.scheduledStatus)||null===this.scheduledStatus)&&i(E,this.messageTypeFilter)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new vs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(gs),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Cs=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 er(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new ds(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Jn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new _s(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ys(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(y("string",e)&&t instanceof ms).throw(q.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(y("string",e)).throw(q.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("string",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("number",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},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=""),_(this,void 0,void 0,(function(){var o;return m(this,(function(u){return o=s(s({},Yt),{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 _(this,void 0,void 0,(function(){return m(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(g("string",e)).throw(q.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(_e);export{$r as CountPreference,os as GroupChannel,ds as GroupChannelCollection,rr as GroupChannelEventContext,Wt as GroupChannelFilter,ms as GroupChannelHandler,Jn as GroupChannelListQuery,Cs as GroupChannelModule,Bt as GroupChannelSearchField,Gt as HiddenChannelFilter,ts as HiddenState,jt as Member,Er as MemberListOrder,Ar as MemberListQuery,xt as MemberState,br as MemberStateFilter,as as MembershipFilter,Nr as MessageCollection,Mr as MessageCollectionInitHandler,tr as MessageCollectionInitPolicy,sr as MessageEventContext,Cr as MutedMemberFilter,es as MutedState,Ft as MyMemberStateFilter,Vt as OperatorFilter,ns as PinnedMessage,is as PinnedMessageListQuery,Rt as PublicChannelFilter,_s as PublicGroupChannelListQuery,qt as QueryType,zt as ReadStatus,ys as ScheduledMessageListQuery,Ot as SuperChannelFilter,Ht as UnreadChannelFilter,Qt as UnreadItemKey}; diff --git a/index.js b/index.js index 4e0af10..d25ec44 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as t,_ as n,n as r,b as s,c as a,E as u,A as d,d as l,e as p,f as v,U as _,g as m,h as b,P as y,j as w,k,l as I,m as E,B as D,S as A,V as F,o as j,L as q,u as z,p as x,q as G,r as W,v as K,C as V,s as J,t as Z,w as $,x as ee,W as te,y as ne,z as re,D as ie,F as se,G as oe,H as ae,I as ue,J as ce,K as de,M as le,N as he}from"./lib/__bundle-2cf2dbb7.js";export{Q as CachedChannelInfo,O as ChannelType,C as ConnectionState,L as LocalCacheConfig,R as LogLevel,N as PushTemplate,H as PushTokenRegistrationState,P as PushTokenType,M as PushTriggerOption,T as Role,o as SendbirdChatOptions,S as SendbirdError,X as UIKitConfigInfo,U as User,Y as UserOnlineState}from"./lib/__bundle-2cf2dbb7.js";import{M as fe,a as pe}from"./lib/__bundle-199cda92.js";export{P as Plugin}from"./lib/__bundle-199cda92.js";import{PollModule as ve}from"./poll.js";import{N as _e,a as ge,b as me,c as be,d as ye,e as we}from"./lib/__bundle-e902ed46.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./lib/__bundle-e902ed46.js";import{g as ke,G as Ie,a as Ce,M as Se,N as Te,b as Pe,c as Ee,A as De,I as Ue,d as Oe,U as Le,e as Ne,f as Ae,D as Me,h as Re,i as Fe,j as je,R as qe,k as ze}from"./lib/__bundle-b2746c15.js";export{c as MemoryStore}from"./lib/__bundle-b2746c15.js";import{P as Qe,a as xe}from"./lib/__bundle-b3187dac.js";export{P as Participant}from"./lib/__bundle-6d9f318a.js";var He={profileImage:null,profileUrl:null,nickname:null},Ge=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),We=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),Ke=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Ve=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return a(this,(function(t){return[2,e.commitSchema([{collectionName:_e,keyName:ge,index:[ke(Ie.LATEST_LAST_MESSAGE),ke(Ie.CHRONOLOGICAL),ke(Ie.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:me,keyName:be,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:Te,keyName:Pe,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:ye,keyName:we}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},Be=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Je=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Be:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._pauseDelayTimer=null,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"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")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(u),Xe=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:d.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Ye=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,h=void 0===c?null:c,f=e.call(this)||this;return f.method=d.PUT,f.path="".concat(l,"/").concat(encodeURIComponent(n)),f.params=p({nickname:i,profile_url:o,profile_file:u,preferred_languages:h}),f}return n(t,e),t}(v),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new _(t,m({},n)),r}return n(t,e),t}(b),$e=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(b);var et=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(b);var tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var nt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var rt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var it=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var st=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=d.GET,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(v),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?y[n.type.toLowerCase()]:y.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(b),at=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(v),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(b),ct=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(v),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(b),lt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),ht=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 n(t,e),t}(b),ft=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=d.PUT,c.path="".concat(l,"/").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 n(t,e),t}(v),pt=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 n(t,e),t}(b),vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),_t=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 n(t,e),t}(b),gt=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=d.PUT,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(v),mt=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 n(t,e),t}(b),bt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new _(t,n),r}n(t,e)}(b);var yt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var wt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(b),It=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(v),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(b),St=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(v),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(b),Pt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(v),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(b),Dt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(v),Ut=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 _(t,e)})),updatedUsers:n.updated.map((function(e){return new _(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(b),Ot=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").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 n(t,e),t}(v),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var At=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v),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 _(t,e)})),r}return n(t,e),t}(b),Rt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var Ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(v),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var zt=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Qt=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 zt(e)})):[]},xt=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 Qt(e)})):[]},Ht=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=w,t}return n(t,e),t}(v),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new xt(n),r}return n(t,e),t}(b),Wt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(w,"/").concat(n),r}return n(t,e),t}(v),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Qt(n),r}return n(t,e),t}(b),Vt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new zt(n),r}return n(t,e),t}(b),Jt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(I),t}return n(t,e),t}(v),Xt=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return n(t,e),t}(b),Yt=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=d.GET,u.path=l,u.params=p({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return n(t,e),t}(v),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),$t=function(e){function r(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 n(r,e),r.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)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Yt(m(m({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Zt),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},r}(D),en=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=d.GET,o.path="".concat(l,"/").concat(n,"/block"),o.params=p({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(v),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),nn=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 n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(tn),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),rn=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(v),sn=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 _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),on=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(sn),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),an=null,un=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var i=F.of(e),o=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Xe({logger:h,connectionDelegate:{reconnect:function(){var t=F.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){F.of(e).connectionManager.disconnect()}}});var v=new Oe(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Je({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof $){if(t.stateType===ee.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof te){if("USEV"===t.code){var n=t.as(Le).event;if(n.category===Ne.FRIEND_DISCOVERED){var i=Ae.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof re){var c=F.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var p in t.customTypes)c.customTypes[p]!==t.customTypes[p]&&(d=!0),c.customTypes[p]=t.customTypes[p];d=d&&c.ts>0,c.ts=l}d&&ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof ie?u.preference.set(r._getUserProfileCacheKey(o.userId),se.payloadify(t.userProfile)):t instanceof oe&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}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 j:a,c=e.debugMode,d=void 0!==c&&c,l=e.customApiHost,h=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,g=void 0!==_&&_,m=e.localCacheConfig,b=void 0===m?new q:m,y=e.localCacheEncryption,w=e.useAsyncStorageStore,k=void 0===w?null:w,I=e.appStateToggleEnabled,C=void 0===I||I;if(!an||p){var S="su-".concat(z()),T=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new Ee({encryption:T});d||(P=x()?k?new De({AsyncStorage:k,encryption:T}):new Ee({encryption:T}):new Ue({encryption:T})),new F(S,{appId:t,appVersion:i,options:u,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:P,encryption:T,logLevel:v,localCacheEnabled:g,localCacheConfig:b,debugMode:d,appStateToggleEnabled:C});var E=[new fe,new ve],D=new n(S,u,G(G([],W(o),!1),W(E),!1));return an||(an=D),D}return an},Object.defineProperty(n,"instance",{get:function(){return an},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return F.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return F.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=F.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return F.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return F.of(this._iid).logger.level},set:function(e){F.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return F.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=F.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return F.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=F.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=F.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=F.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._getCurrentPreferenceVersion=function(){return 1},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=F.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ee?n.store:null;throw A.debugModeRequired},n.prototype.addExtension=function(e,t){var n=F.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=F.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.store=new Ee,[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,o=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==ze.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Re({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Ve(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Ve(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Me(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),o.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,A.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=Fe.of(this._iid),n=je.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return void 0===n&&(n=null),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:J(t("string",e)&&t("string",n,!0)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.cacheContext,o=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),F.of(this._iid).dispatcher.dispatch(new qe),[3,4];case 3:return a.sent(),c=F.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new se(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,o.connect(n)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=F.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=F.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=F.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){J(e instanceof Ge).throw(A.invalidParameters),F.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){J(t("string",e)&&n instanceof Ke).throw(A.invalidParameters),F.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){F.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){F.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){J(t("string",e)&&n instanceof We).throw(A.invalidParameters),F.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){F.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){F.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new $t(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new pe(this._iid,e)},n.prototype.createPollListQuery=function(e){return new Qe(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new xe(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=Z(e);return new _(this._iid,_.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},He),n),J(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(A.invalidParameters),this.currentUser?(i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Ye(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(Ze).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw A.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(E("string",e)).throw(A.invalidParameters),this.currentUser?(t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ye({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ze).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw A.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(y.FCM,e)?[2,ae.SUCCESS]:(u=new et({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(y.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new nt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(y.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new it({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(y.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(y.APNS,e)?[2,ae.SUCCESS]:(u=new $e({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(y.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new tt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(y.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new rt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(y.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new at({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(ut).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ct({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(dt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new lt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ht).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(A.invalidParameters),s=F.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new ft({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(pt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(_t).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)).throw(A.invalidParameters),i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new gt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(mt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)&&de(y,n)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new st({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ot).pushTokens;try{for(l=ce(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new wt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(kt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(le,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new It({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new St({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Tt).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(he,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Et).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new bt({userId:r.userId,blockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new yt({userId:r.userId,unblockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Dt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Ut).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ft({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(jt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ot({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Lt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({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 s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid).requestQueue,t=new Ht,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Gt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Wt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Kt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Vt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Bt).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),J(e.hasExtension("sb_uikit")).throw(A.notSupportedError),t=e.requestQueue,n=new Jt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Xt).uikitConfiguration]}}))}))},n}();export{$t as ApplicationUserListQuery,nn as BlockedUserListQuery,We as ConnectionHandler,zt as Emoji,Qt as EmojiCategory,xt as EmojiContainer,on as FriendListQuery,Ge as SessionHandler,Ke as UserEventHandler,un as default}; +import{i as e,a as t,_ as n,n as r,b as s,c as a,E as u,A as d,d as l,e as p,f as v,U as _,g as m,h as b,P as y,j as w,k,l as I,m as E,B as D,S as A,V as F,o as j,L as q,u as z,p as x,q as G,r as W,v as K,C as V,s as J,t as Z,w as $,x as ee,W as te,y as ne,z as re,D as ie,F as se,G as oe,H as ae,I as ue,J as ce,K as de,M as le,N as he}from"./lib/__bundle-a8f5769e.js";export{Q as CachedChannelInfo,O as ChannelType,C as ConnectionState,L as LocalCacheConfig,R as LogLevel,N as PushTemplate,H as PushTokenRegistrationState,P as PushTokenType,M as PushTriggerOption,T as Role,o as SendbirdChatOptions,S as SendbirdError,X as UIKitConfigInfo,U as User,Y as UserOnlineState}from"./lib/__bundle-a8f5769e.js";import{M as fe,a as pe}from"./lib/__bundle-f20da9a5.js";export{P as Plugin}from"./lib/__bundle-f20da9a5.js";import{PollModule as ve}from"./poll.js";import{N as _e,a as ge,b as me,c as be,d as ye,e as we}from"./lib/__bundle-ad6d760f.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./lib/__bundle-ad6d760f.js";import{g as ke,G as Ie,a as Ce,M as Se,N as Te,b as Pe,c as Ee,A as De,I as Ue,d as Oe,U as Le,e as Ne,f as Ae,D as Me,h as Re,i as Fe,j as je,R as qe,k as ze}from"./lib/__bundle-d67b9997.js";export{c as MemoryStore}from"./lib/__bundle-d67b9997.js";import{P as Qe,a as xe}from"./lib/__bundle-6bc4500a.js";export{P as Participant}from"./lib/__bundle-ed97dd0a.js";var He={profileImage:null,profileUrl:null,nickname:null},Ge=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),We=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),Ke=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Ve=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return a(this,(function(t){return[2,e.commitSchema([{collectionName:_e,keyName:ge,index:[ke(Ie.LATEST_LAST_MESSAGE),ke(Ie.CHRONOLOGICAL),ke(Ie.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:me,keyName:be,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:Te,keyName:Pe,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:ye,keyName:we}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},Be=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Je=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Be:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._pauseDelayTimer=null,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"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")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(u),Xe=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:d.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Ye=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,h=void 0===c?null:c,f=e.call(this)||this;return f.method=d.PUT,f.path="".concat(l,"/").concat(encodeURIComponent(n)),f.params=p({nickname:i,profile_url:o,profile_file:u,preferred_languages:h}),f}return n(t,e),t}(v),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new _(t,m({},n)),r}return n(t,e),t}(b),$e=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(b);var et=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(b);var tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var nt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var rt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var it=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?y[n.type.toLowerCase()]:y.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var st=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=d.GET,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(v),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?y[n.type.toLowerCase()]:y.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(b),at=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(v),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(b),ct=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(v),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(b),lt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),ht=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 n(t,e),t}(b),ft=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=d.PUT,c.path="".concat(l,"/").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 n(t,e),t}(v),pt=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 n(t,e),t}(b),vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),_t=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 n(t,e),t}(b),gt=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=d.PUT,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(v),mt=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 n(t,e),t}(b),bt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new _(t,n),r}n(t,e)}(b);var yt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var wt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(b),It=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(v),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(b),St=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(v),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(b),Pt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(v),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(b),Dt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(v),Ut=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 _(t,e)})),updatedUsers:n.updated.map((function(e){return new _(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(b),Ot=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").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 n(t,e),t}(v),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var At=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v),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 _(t,e)})),r}return n(t,e),t}(b),Rt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var Ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(v),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var zt=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Qt=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 zt(e)})):[]},xt=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 Qt(e)})):[]},Ht=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=w,t}return n(t,e),t}(v),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new xt(n),r}return n(t,e),t}(b),Wt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(w,"/").concat(n),r}return n(t,e),t}(v),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Qt(n),r}return n(t,e),t}(b),Vt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new zt(n),r}return n(t,e),t}(b),Jt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(I),t}return n(t,e),t}(v),Xt=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return n(t,e),t}(b),Yt=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=d.GET,u.path=l,u.params=p({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return n(t,e),t}(v),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),$t=function(e){function r(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 n(r,e),r.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)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Yt(m(m({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Zt),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},r}(D),en=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=d.GET,o.path="".concat(l,"/").concat(n,"/block"),o.params=p({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(v),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),nn=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 n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(tn),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),rn=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(v),sn=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 _(t,e)})),r.next=n.next,r}return n(t,e),t}(b),on=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(sn),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),an=null,un=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var i=F.of(e),o=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Xe({logger:h,connectionDelegate:{reconnect:function(){var t=F.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){F.of(e).connectionManager.disconnect()}}});var v=new Oe(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Je({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof $){if(t.stateType===ee.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof te){if("USEV"===t.code){var n=t.as(Le).event;if(n.category===Ne.FRIEND_DISCOVERED){var i=Ae.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof re){var c=F.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var p in t.customTypes)c.customTypes[p]!==t.customTypes[p]&&(d=!0),c.customTypes[p]=t.customTypes[p];d=d&&c.ts>0,c.ts=l}d&&ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof ie?u.preference.set(r._getUserProfileCacheKey(o.userId),se.payloadify(t.userProfile)):t instanceof oe&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}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 j:a,c=e.debugMode,d=void 0!==c&&c,l=e.customApiHost,h=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,g=void 0!==_&&_,m=e.localCacheConfig,b=void 0===m?new q:m,y=e.localCacheEncryption,w=e.useAsyncStorageStore,k=void 0===w?null:w,I=e.appStateToggleEnabled,C=void 0===I||I;if(!an||p){var S="su-".concat(z()),T=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new Ee({encryption:T});d||(P=x()?k?new De({AsyncStorage:k,encryption:T}):new Ee({encryption:T}):new Ue({encryption:T})),new F(S,{appId:t,appVersion:i,options:u,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:P,encryption:T,logLevel:v,localCacheEnabled:g,localCacheConfig:b,debugMode:d,appStateToggleEnabled:C});var E=[new fe,new ve],D=new n(S,u,G(G([],W(o),!1),W(E),!1));return an||(an=D),D}return an},Object.defineProperty(n,"instance",{get:function(){return an},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return F.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return F.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=F.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return F.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return F.of(this._iid).logger.level},set:function(e){F.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return F.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=F.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return F.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=F.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=F.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=F.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._getCurrentPreferenceVersion=function(){return 1},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=F.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ee?n.store:null;throw A.debugModeRequired},n.prototype.addExtension=function(e,t){var n=F.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=F.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.store=new Ee,[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,o=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==ze.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Re({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Ve(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Ve(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Me(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),o.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,A.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=Fe.of(this._iid),n=je.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return void 0===n&&(n=null),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:J(t("string",e)&&t("string",n,!0)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.cacheContext,o=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),F.of(this._iid).dispatcher.dispatch(new qe),[3,4];case 3:return a.sent(),c=F.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new se(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,o.connect(n)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=F.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=F.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=F.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){J(e instanceof Ge).throw(A.invalidParameters),F.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){J(t("string",e)&&n instanceof Ke).throw(A.invalidParameters),F.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){F.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){F.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){J(t("string",e)&&n instanceof We).throw(A.invalidParameters),F.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){F.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){F.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new $t(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new pe(this._iid,e)},n.prototype.createPollListQuery=function(e){return new Qe(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new xe(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=Z(e);return new _(this._iid,_.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},He),n),J(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(A.invalidParameters),this.currentUser?(i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Ye(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(Ze).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw A.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(E("string",e)).throw(A.invalidParameters),this.currentUser?(t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ye({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ze).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw A.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(y.FCM,e)?[2,ae.SUCCESS]:(u=new et({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(y.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new nt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(y.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new it({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(y.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(y.APNS,e)?[2,ae.SUCCESS]:(u=new $e({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(y.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new tt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(y.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new rt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(y.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new at({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(ut).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ct({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(dt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new lt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ht).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(A.invalidParameters),s=F.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new ft({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(pt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(_t).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)).throw(A.invalidParameters),i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new gt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(mt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)&&de(y,n)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new st({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ot).pushTokens;try{for(l=ce(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new wt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(kt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(le,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new It({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new St({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Tt).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(he,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Et).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new bt({userId:r.userId,blockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new yt({userId:r.userId,unblockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Dt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Ut).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ft({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(jt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ot({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Lt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({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 s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid).requestQueue,t=new Ht,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Gt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Wt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Kt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Vt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Bt).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),J(e.hasExtension("sb_uikit")).throw(A.notSupportedError),t=e.requestQueue,n=new Jt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Xt).uikitConfiguration]}}))}))},n}();export{$t as ApplicationUserListQuery,nn as BlockedUserListQuery,We as ConnectionHandler,zt as Emoji,Qt as EmojiCategory,xt as EmojiContainer,on as FriendListQuery,Ge as SessionHandler,Ke as UserEventHandler,un as default}; diff --git a/lib/__bundle-199cda92.js b/lib/__bundle-199cda92.js deleted file mode 100644 index 61d9878..0000000 --- a/lib/__bundle-199cda92.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,A as t,Z as n,e as s,f as a,h as i,g as r,U as l,$ as u,m as o,a as d,K as c,q as h,r as p,J as m,T as f,a0 as g,a1 as y,a2 as _,O as v,a3 as I,a4 as T,a5 as M,a6 as S,b,c as U,s as A,S as E,a7 as w,V as F,a8 as q,a9 as D,aa as P,ab as N,W as C,w as R,x as O,ac as L,ad as k,i as z,ae as x,af as Q,ag as G,t as B,ah as j,ai as H,aj as W,n as K,ak as V,B as X,al as J,am as Z}from"./__bundle-2cf2dbb7.js";var $,Y=function(a){function i(e){var i=a.call(this)||this;if(i.method=t.POST,i.path="".concat(n),i.params=s({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var r=0;r0&&d("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){l[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}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?s({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 $.ADD:t<0&&this.userIds.push(e.userId);break;case $.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),re=function(){function e(e){this.key=e.key,this.value=o("string",e.value)?h([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return e?s({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),le=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?s({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}(),ue=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 le(e["og:image"]))}return e.payloadify=function(e){return e?s({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?le.payloadify(e.defaultImage):null}):null},e}(),oe=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?s({name:e.name,volume:e.volume}):null},e}(),de=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.role=null,s.isBlockedByMe=!1,s.role=c(f,n.role)?n.role:f.NONE,n.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=n.is_blocked_by_me),s}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},n}(l);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ne||(ne={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(se||(se={}));var ce=function(e){switch(e){case y.BASE:return"";case y.USER:return"MESG";case y.FILE:return"FILE";case y.ADMIN:return"ADMM"}},he=function(t){function n(e,n){var s,a,i,r,u,o,d,h,p,m,f,g,_,T,M,S=this;(S=t.call(this,e)||this).channelUrl=null,S.channelType=v.BASE,S.messageId=0,S.parentMessageId=null,S.parentMessage=null,S.silent=!1,S.isOperatorMessage=!1,S.messageType=y.BASE,S.data=null,S.customType=null,S.mentionType=null,S.mentionedUsers=[],S.mentionedUserIds=[],S.mentionedMessageTemplate=null,S.threadInfo=null,S.reactions=[],S.metaArrays=[],S.ogMetaData=null,S.appleCriticalAlertOptions=null,S.createdAt=0,S.updatedAt=0,S.scheduledInfo=null,S.extendedMessage={},S._isContinuousMessages=!1,S._scheduledStatus=null,S.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,S.channelUrl=n.channel_url,S.channelType=c(v,n.channel_type)?n.channel_type:v.GROUP,n.channel&&(n.channel.channel_url&&(S.channelUrl=n.channel.channel_url),n.channel.channel_type&&(S.channelType=n.channel.channel_type)),S.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,S.data=null!==(r=n.data)&&void 0!==r?r:"",S.customType=null!==(u=n.custom_type)&&void 0!==u?u:"",S.mentionType=c(I,n.mention_type)?n.mention_type:null;var b=n.mentioned_users;S.mentionedUsers=b?b.map((function(e){return new l(S._iid,e)})):null;var U=n.mentioned_user_ids;S.mentionedUserIds=null!=U?U:null,S.mentionedUsers&&!S.mentionedUserIds&&(S.mentionedUserIds=S.mentionedUsers.map((function(e){return e.userId}))),S.mentionedMessageTemplate=null!==(o=n.mentioned_message_template)&&void 0!==o?o:"",S.threadInfo=n.thread_info?new te(S._iid,n.thread_info):null,S.reactions=n.reactions?n.reactions.map((function(e){return new ie(e)})):[];for(var A=null!==(d=n.metaarray)&&void 0!==d?d:{},E=null!==(h=n.metaarray_key_order)&&void 0!==h?h:Object.keys(A).sort((function(e,t){return e.localeCompare(t)})),w=0;w=t)return this.parentMessage=e,!0}return!1},n}(u),pe=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).sender=null,l.reqId="",l.replyToChannel=!1,l.sendingStatus=null,l.errorCode=0,l.sender=n.user?new de(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&c(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(l._scheduledStatus=n.scheduled_status,n.scheduled_status){case se.SENT:case se.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case se.PENDING:l.sendingStatus=T.SCHEDULED;break;case se.FAILED:case se.REMOVED:l.sendingStatus=T.FAILED;break;case se.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{user:de.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&M(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(he),me=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?s({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}(),fe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ge=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},ye=function(t){function n(e,n){var a,i,l,u,o=this;if((o=t.call(this,e,n)||this).message=null,o.translations={},o.message=null!==(a=n.message)&&void 0!==a?a:"",o.messageType=y.ADMIN,o.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var d=n.parent_message_info,c=s(r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth}));o.parentMessage=Se(e,c)}return o}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(he),_e=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")&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?s({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),ve=function(t){function n(e,n){var a,i,l,u,o,d,c,h=this;if((h=t.call(this,e,n)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=n.message,h.messageType=y.USER,h.translations=null!==(l=n.translations)&&void 0!==l?l:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=m(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var g=f.value;h.translations[g]=""}}catch(e){a={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(h.messageSurvivalSeconds=null!==(o=n.message_survival_seconds)&&void 0!==o?o:-1,h.plugins=n.plugins?n.plugins.map((function(e){return new _e(e)})):[],h._poll=n.poll?new w(h._iid,n.poll):null,n.parent_message_info){var _=n.parent_message_info,v=s(r(r({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(c=_.file)||void 0===c?void 0:c.require_auth}));h.parentMessage=Se(e,s(v))}return h}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return _e.payloadify(e)})),poll:w.payloadify(e._poll),parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(pe),Ie=function(t){function n(e,n){var s,a,i,l,u=this;(u=t.call(this,e)||this).plainUrl="",u.fileName=null,u.mimeType=null,u.fileSize=0,u.thumbnails=[],u._requireAuth=!1,u.plainUrl=n.url,u.fileName=null!==(s=n.file_name)&&void 0!==s?s:null,u.mimeType=null!==(a=n.file_type)&&void 0!==a?a:null,u.fileSize=null!==(i=n.file_size)&&void 0!==i?i:0;var o=F.of(u._iid).sessionManager;return u._requireAuth=null!==(l=n.require_auth)&&void 0!==l&&l,u.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(u._requireAuth?"?auth=".concat(o.ekey):"")}))})):[],u}return e(n,t),n.payloadify=function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(u),Te=function(t){function n(e,n){var s,a,i,l,u,o=this;if((o=t.call(this,e,n)||this).messageParams=null,o.fileInfoList=[],o.messageSurvivalSeconds=-1,o.messageType=y.FILE,o.fileInfoList=null!==(a=null===(s=n.files)||void 0===s?void 0:s.map((function(t){return new Ie(e,t)})))&&void 0!==a?a:[],o.messageSurvivalSeconds=null!==(i=n.message_survival_seconds)&&void 0!==i?i:-1,n.parent_message_info){var d=n.parent_message_info,c=r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth});o.parentMessage=Se(e,c)}return o}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Ie.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(pe),Me=function(e){if(e)switch(e.messageType){case y.USER:return ve.payloadify(e);case y.FILE:return be.payloadify(e);case y.ADMIN:return ye.payloadify(e)}return null},Se=function(e,t){switch(t.type){case"MESG":return new ve(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new be(e,t);case"ADMM":case"BRDM":return new ye(e,t)}return null},be=function(t){function n(e,n){var a,i,l,u,o,d,c,h,p,m,f,g,_,v,I,T=this;(T=t.call(this,e,n)||this).messageParams=null,T.plainUrl="",T.requireAuth=!1,T.name=null,T.size=0,T.type=null,T.thumbnails=[],T.messageSurvivalSeconds=-1,T.messageType=y.FILE;var M=null!==(a=n.file)&&void 0!==a?a:null;T.plainUrl=(null!==(l=null!==(i=null==M?void 0:M.url)&&void 0!==i?i:n.url)&&void 0!==l?l:"").split("?auth=")[0],T.name=null!==(o=null!==(u=null==M?void 0:M.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",T.size=null!==(c=null!==(d=null==M?void 0:M.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,T.data=null!==(p=null!==(h=null==M?void 0:M.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",T.type=M?null!==(m=M.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=F.of(T._iid).sessionManager;if(T.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,T.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(T.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],T.messageSurvivalSeconds=null!==(_=n.message_survival_seconds)&&void 0!==_?_:-1,n.parent_message_info){var b=n.parent_message_info,U=s(r(r({},b),{message_id:T.parentMessageId,channel_url:T.channelUrl,channel_type:T.channelType,file:b.file,url:null===(v=b.file)||void 0===v?void 0:v.url,require_auth:null===(I=b.file)||void 0===I?void 0:I.require_auth}));T.parentMessage=Se(e,U)}return T}return e(n,t),n.payloadify=function(e){var n;return e?s(r(r({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),Ue=function(t){function n(e){var n,a,i,r=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s({channel_url:e.channelUrl,files:Fe(e.files),url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==q.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage})})||this}return e(n,t),n}(D),Ae=function(n){function a(e){var a,i,r=this;r=n.call(this)||this;var l=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),r.method=t.POST,r.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),r.params=s({message_type:y.FILE,user_id:e.userId,files:Fe(e.files),url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:l,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(a=e.thumbnailSizes)||void 0===a?void 0:a.map((function(e){return me.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return re.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,apple_critical_alert_options:oe.payloadify(e.appleCriticalAlertOptions),reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}),r}return e(a,n),a}(a),Ee=function(t){function n(e,n,s){var a,i,r,l=this;(l=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new be(e,s);var u=F.of(e).sdkState;return l.isMentioned=N(l.message.mentionType,null!==(a=l.message.mentionedUserIds)&&void 0!==a?a:null===(i=l.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),u.userId),l.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(C),we=function(t){function n(e,n){var s,a,i=this;(i=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new be(e,n);var r=F.of(e).sdkState;return i.isMentioned=N(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),r.userId),i.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,i}return e(n,t),n}(i);function Fe(e){return null==e?void 0:e.map((function(e){var t,n;return s({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return me.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var qe;!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"}(qe||(qe={}));var De=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof R&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return b(this,void 0,void 0,(function(){var n,s,a;return U(this,(function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(s=new Ue(n),[4,this._requestQueue.send(s)]):[3,2];case 1:return a=i.sent(),[2,a.as(Ee).message];case 2:return s=new Ae(r(r({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(we).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var s=t.params;n.files=s.fileInfoList}else{s=t.params;n.url=s.fileUrl,n.requireAuth=s.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){return b(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h;return U(this,(function(p){switch(p.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],s=!0,p.label=1;case 1:p.trys.push([1,15,16,17]),a=m(t.messageQueue),i=a.next(),p.label=2;case 2:if(i.done)return[3,14];switch(r=i.value,r.state){case qe.PENDING:case qe.UPLOADING:return[3,3];case qe.UPLOADED:return[3,4];case qe.FAILED:return[3,12]}return[3,13];case 3:return s=!1,n.push(r),[3,13];case 4:if(!s)return[3,10];p.label=5;case 5:return p.trys.push([5,8,,9]),r.state=qe.SENDING,[4,this._sendFileMessage(e,r)];case 6:return l=p.sent(),r.deferred.resolve(l),[4,k(100)];case 7:return p.sent(),[3,9];case 8:return u=p.sent(),r.deferred.reject(u),[3,9];case 9:return[3,11];case 10:n.push(r),p.label=11;case 11:return[3,13];case 12:return r.deferred.reject(r.error.code===L.REQUEST_CANCELED?E.fileUploadCanceled:r.error),[3,13];case 13:return i=a.next(),[3,2];case 14:return[3,17];case 15:return o=p.sent(),c={error:o},[3,17];case 16:try{i&&!i.done&&(h=a.return)&&h.call(a)}finally{if(c)throw c.error}return[7];case 17:return d=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,d?[4,this._resolveMessageQueue(e)]:[3,19];case 18:p.sent(),p.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,p.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return b(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d;return U(this,(function(c){switch(c.label){case 0:return n=this._queueMap.get(e.url),(s=n.messageQueue.find((function(e){return e.state===qe.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!z(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,s)]):[3,4]:[3,9];case 1:return c.sent(),[3,3];case 2:s.state=i=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var r,l,u,o,d,c,h,p,m,f;return U(this,(function(g){switch(g.label){case 0:return r=new Y({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(r)];case 1:return l=g.sent(),u=l.as(ee),o=u.url,d=u.fileSize,c=void 0===d?n.fileSize:d,h=u.thumbnailSizes,p=void 0===h?n.thumbnailSizes:h,m=u.requireAuth,f=void 0!==m&&m,n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=o,n.fileSize=c,n.thumbnailSizes=p,n.requireAuth=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m,f,g,y,_;return U(this,(function(v){switch(v.label){case 0:return l=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[l],o=new Y({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(o)];case 1:return d=v.sent(),c=d.as(ee),h=c.url,p=c.fileSize,m=void 0===p?u.fileSize:p,f=c.thumbnailSizes,g=void 0===f?u.thumbnailSizes:f,y=c.requireAuth,_=void 0!==y&&y,u.fileName=null!==(s=u.fileName)&&void 0!==s?s:u.file.name,u.mimeType=null!==(a=u.mimeType)&&void 0!==a?a:u.file.type,u.fileSize=null!==(i=u.fileSize)&&void 0!==i?i:u.file.size,u.file=null,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=r(r({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return void 0===s&&(s=null),b(this,void 0,void 0,(function(){var a,i,r,l,u;return U(this,(function(o){return this._queueMap.has(e.url)||(a={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,a)),i=this._queueMap.get(e.url),r=new x,l={requestId:t,params:n,state:qe.PENDING,deferred:r},function(e){return"fileInfoList"in e}(n)&&(u={uploadIndex:0,uploadCount:n.fileInfoList.length,requestHandler:s},l.multipleFileUploadInfo=u),i.messageQueue.push(l),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s;void 0===t&&(t=null);var a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:h([],p(a.messageQueue),!1);try{for(var r=m(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case qe.PENDING:u.state=qe.FAILED,u.error=E.requestCanceled,this._resolveMessageQueue(e);break;case qe.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}();var Pe,Ne={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:Q.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Ce=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&c(Q,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},Re={replyType:Q.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return c(Q,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},Le=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),ke=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),ze=function(n){function a(e){var a=e.channelType,i=e.channelUrl,r=e.timestamp,l=void 0===r?null:r,u=e.token,o=void 0===u?null:u,d=e.prevResultSize,c=e.nextResultSize,h=e.isInclusive,p=e.reverse,m=e.messageTypeFilter,f=e.customTypesFilter,g=e.senderUserIdsFilter,y=e.replyType,_=e.includeMetaArray,v=e.includeReactions,I=e.parentMessageId,T=e.includeThreadInfo,M=e.includeParentMessageInfo,S=e.showSubchannelMessagesOnly,b=e.checkingContinuousMessages,U=n.call(this)||this;return U.method=t.GET,U.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),U.params=s({is_sdk:!0,prev_limit:d,next_limit:c,include:h,reverse:p,message_ts:l,message_id:o,message_type:null!=m?m:null,custom_types:f,sender_ids:g,include_reply_type:y,with_sorted_meta_array:_,include_reactions:v,parent_message_id:I,include_thread_info:T,include_parent_message_info:M,show_subchannel_message_only:S,include_poll_details:!0,checking_continuous_messages:b}),U}return e(a,n),a}(a),xe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Se(e,t)})),s}return e(n,t),n}(i),Qe=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),Ge=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Se(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),Be=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),je=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),He={},We=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new De(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),He[e]=this}return e.of=function(e){return He[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=B(e);switch(t.messageType){case y.USER:return new ve(this._iid,ve.payloadify(t));case y.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new be(this._iid,be.payloadify(t));case y.ADMIN:return new ye(this._iid,ye.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return s({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,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=B(e);return new de(this._iid,de.payloadify(t))},e.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return U(this,(function(s){switch(s.label){case 0:return t=new Le(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ke).message]}}))}))},e.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return U(this,(function(s){switch(s.label){case 0:return t=new Be(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(je).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return U(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,token:String(n)},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return U(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var l,u,o,d;return U(this,(function(c){switch(c.label){case 0:return l=new ze(r(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(l)];case 1:return u=c.sent(),o=u.payload,d=u.as(xe).messages,this._dispatcher.dispatch(new H({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=j.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,l,u;return U(this,(function(o){switch(o.label){case 0:return a=new ze(r(r(r({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},fe),n),{replyType:Q.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),l=i.as(xe).messages,(u=l.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new H({messages:u,source:s})),[2,{parentMessage:l[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=j.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m;return U(this,(function(f){switch(f.label){case 0:return l=new Qe(s(r(r({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Re),a))),[4,this._requestQueue.send(l)];case 1:return u=f.sent(),o=u.as(Ge),d=o.updatedMessages,c=o.deletedMessagesInfo,h=o.hasMore,p=o.nextToken,m=c.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new H({messages:d,source:i})),m.length>0&&this._dispatcher.dispatch(new W({messageIds:m,source:i})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:h,token:p}]}}))}))},e}(),Ke=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.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}(),Ve=function(t){function n(e,n){var s=t.call(this,e)||this;s.threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&d("object",a)&&d("number",i)&&d("string",r)&&d("string",l)&&(s.threadInfo=new te(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(u),Xe={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Je=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,f=n.call(this)||this;return f.method=t.GET,f.path="".concat(V,"/messages"),f.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},f}return e(s,n),s}(a),Ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Se(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Pe||(Pe={}));var $e=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Pe.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:Pe.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&c(Pe,this.order)&&d("boolean",this.advancedQuery)&&o("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,l,u;return U(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Je(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),s=n.as(Ze),a=s.messages,i=s.hasNext,l=s.nextToken,u=s.totalCount,this._nextToken=l,this._hasNext=i,this._isLoading=!1,this.totalCount=u,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(X),Ye=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,f=this;return(f=t.call(this,e,n,s,a)||this).reverse=!1,f.messageTypeFilter=S.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=Q.NONE,f.includeMetaArray=!1,f.includeReactions=!1,f.includeParentMessageInfo=!1,f.includeThreadInfo=!1,f.showSubchannelMessagesOnly=!1,f._edge=Number.MAX_SAFE_INTEGER,f.reverse=null!==(i=a.reverse)&&void 0!==i&&i,f.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:S.ALL,f.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,f.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,f.replyType=null!==(o=a.replyType)&&void 0!==o?o:Q.NONE,f.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,f.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,f.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,f.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,f.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,f}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&c(S,this.messageTypeFilter)&&c(Q,this.replyType)&&o("string",this.customTypesFilter,!0)&&o("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return b(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,We.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,h([Number.MAX_SAFE_INTEGER],p(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 E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(J),et={channelUrl:null,scheduledMessageId:0},tt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=K,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,s){this._onFileUploaded(e,t,n,s)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(Ke),nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new We(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=r(r({},Xe),e),A(function(e){return d("string",e.channelUrl)&&d("string",e.channelType)&&c(v,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)}(t)).throw(E.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=r(r({},et),e),A(function(e){return d("string",e.channelUrl)&&d("number",e.scheduledMessageId)}(t)).throw(E.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Z);export{oe as A,he as B,be as F,se as I,nt as M,le as O,_e as P,ae as R,pe as S,me as T,ve as U,$e as a,Te as b,We as c,re as d,Ye as e,de as f,tt as g,Ke as h,Ne as i,Re as j,Oe as k,ne as l,Ee as m,Me as n,ee as o,Se as p,Y as q,ye as r,Ve as s,Pe as t,ue as u,Ce as v,ie as w,$ as x,te as y,Ie as z}; diff --git a/lib/__bundle-b3187dac.js b/lib/__bundle-6bc4500a.js similarity index 99% rename from lib/__bundle-b3187dac.js rename to lib/__bundle-6bc4500a.js index b5adf67..db303b2 100644 --- a/lib/__bundle-b3187dac.js +++ b/lib/__bundle-6bc4500a.js @@ -1 +1 @@ -import{_ as t,A as n,at as e,f as o,a7 as s,h as l,an as a,aa as i,e as r,a as u,au as c,av as h,K as p,O as d,t as f,b as _,c as m,ah as v,s as g,S as I,g as w,aw as y,al as T,V as U,U as k}from"./__bundle-2cf2dbb7.js";var b=function(o){function s(t){var s=t.title,l=t.optionTexts,a=t.data,i=t.allowUserSuggestion,r=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:l,data:a,allow_user_suggestion:i,allow_multiple_votes:r,close_at:u},c}return t(s,o),s}(o),P=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),O=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=o.call(this)||this;return i.method=n.GET,i.path="".concat(e,"/").concat(encodeURIComponent(a)),i.params={channel_url:s,channel_type:l},i}return t(s,o),s}(o),x=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),q=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:l},r}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new a(t,e),o}return t(e,n),e}(l),S=function(e){function o(t){var o=t.channelType,s=t.channelUrl,l=t.timestamp,a=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(i(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=r({change_ts:l,token:a}),u}return t(o,e),o}(o),C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return n?new s(t,n):null}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(l),M={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Q=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},G={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},E=function(t){return u("string",t.channelUrl)&&p(d,t.channelType)&&u("number",t.pollId)&&u("number",t.pollOptionId)},N={channelUrl:null,channelType:null,pollId:null},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&p(d,t.channelType)&&u("number",t.pollId)},A={},V=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,l=n.requestQueue,a=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=l,this._dispatcher=o,this._logger=a,A[t]=this}return t.of=function(t){return A[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new O(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e,o;return m(this,(function(s){switch(s.label){case 0:return g(Q(t)).throw(I.invalidParameters),n=t.data,e=new b(w(w({},t),{data:n})),[4,this._requestQueue.send(e)];case 1:return o=s.sent(),[2,o.as(P).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=v.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,l,a,i,u,c,h;return m(this,(function(p){switch(p.label){case 0:return s=new S(r({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return l=p.sent(),a=l.as(C),i=a.updatedPolls,u=a.deletedPollIds,c=a.hasMore,h=a.nextToken,i.length>0&&this._dispatcher.dispatch(new y({polls:i,source:o})),[2,{updatedPolls:i,deletedPollIds:u,hasMore:c,token:h}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.token,i=t.limit,r=o.call(this)||this;return r.method=n.GET,r.path=e,r.params={channel_url:s,channel_type:l,token:a,limit:i},r}return t(s,o),s}(o),F=function(n){function e(t,e){var o,l=this;return(l=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),l.token=e.next,l}return t(e,n),e}(l),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(F),s=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T),K=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i),"/voters"),c.params={channel_url:s,channel_type:l,token:r,limit:u},c}return t(s,o),s}(o),Y=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new k(t,n)})),s.token=e.next,s}return t(e,n),e}(l),B=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new K(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(Y),s=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T);export{H as P,B as a,V as b,M as c,N as d,R as e,G as f,E as g,j as h,z as i,Q as v}; +import{_ as t,A as n,at as e,f as o,a7 as s,h as l,an as a,aa as i,e as r,a as u,au as c,av as h,K as p,O as d,t as f,b as _,c as m,ah as v,s as g,S as I,g as w,aw as y,al as T,V as U,U as k}from"./__bundle-a8f5769e.js";var b=function(o){function s(t){var s=t.title,l=t.optionTexts,a=t.data,i=t.allowUserSuggestion,r=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:l,data:a,allow_user_suggestion:i,allow_multiple_votes:r,close_at:u},c}return t(s,o),s}(o),P=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),O=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=o.call(this)||this;return i.method=n.GET,i.path="".concat(e,"/").concat(encodeURIComponent(a)),i.params={channel_url:s,channel_type:l},i}return t(s,o),s}(o),x=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),q=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:l},r}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new a(t,e),o}return t(e,n),e}(l),S=function(e){function o(t){var o=t.channelType,s=t.channelUrl,l=t.timestamp,a=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(i(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=r({change_ts:l,token:a}),u}return t(o,e),o}(o),C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return n?new s(t,n):null}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(l),M={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Q=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},G={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},E=function(t){return u("string",t.channelUrl)&&p(d,t.channelType)&&u("number",t.pollId)&&u("number",t.pollOptionId)},N={channelUrl:null,channelType:null,pollId:null},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&p(d,t.channelType)&&u("number",t.pollId)},A={},V=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,l=n.requestQueue,a=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=l,this._dispatcher=o,this._logger=a,A[t]=this}return t.of=function(t){return A[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new O(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e,o;return m(this,(function(s){switch(s.label){case 0:return g(Q(t)).throw(I.invalidParameters),n=t.data,e=new b(w(w({},t),{data:n})),[4,this._requestQueue.send(e)];case 1:return o=s.sent(),[2,o.as(P).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=v.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,l,a,i,u,c,h;return m(this,(function(p){switch(p.label){case 0:return s=new S(r({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return l=p.sent(),a=l.as(C),i=a.updatedPolls,u=a.deletedPollIds,c=a.hasMore,h=a.nextToken,i.length>0&&this._dispatcher.dispatch(new y({polls:i,source:o})),[2,{updatedPolls:i,deletedPollIds:u,hasMore:c,token:h}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.token,i=t.limit,r=o.call(this)||this;return r.method=n.GET,r.path=e,r.params={channel_url:s,channel_type:l,token:a,limit:i},r}return t(s,o),s}(o),F=function(n){function e(t,e){var o,l=this;return(l=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),l.token=e.next,l}return t(e,n),e}(l),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(F),s=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T),K=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i),"/voters"),c.params={channel_url:s,channel_type:l,token:r,limit:u},c}return t(s,o),s}(o),Y=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new k(t,n)})),s.token=e.next,s}return t(e,n),e}(l),B=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new K(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(Y),s=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T);export{H as P,B as a,V as b,M as c,N as d,R as e,G as f,E as g,j as h,z as i,Q as v}; diff --git a/lib/__bundle-2cf2dbb7.js b/lib/__bundle-a8f5769e.js similarity index 99% rename from lib/__bundle-2cf2dbb7.js rename to lib/__bundle-a8f5769e.js index fe366e3..3bd554b 100644 --- a/lib/__bundle-2cf2dbb7.js +++ b/lib/__bundle-a8f5769e.js @@ -1 +1 @@ -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!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=w("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},N=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=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),R={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),a?(this._clearOrder=o,this._customClearOrderComparator=a):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),Z=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}(),V=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)}))},H=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=V()}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}(),W=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new H({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new H({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()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),Q=function(){function e(){this._dispatcher=new W}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}(),Y=function(){},X=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(x||(x={})),function(e){e.OPERATOR="operator",e.NONE="none"}(M||(M={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(P||(P={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(U||(U={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(z||(z={})),function(e){e.USERS="users",e.CHANNEL="channel"}(F||(F={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(q||(q={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(G||(G={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(j||(j={}));var J,$="v3",ee="/".concat($,"/users"),te="/".concat($,"/storage/file"),ne="/".concat($,"/group_channels"),re="/".concat($,"/sdk/group_channels"),ie="/".concat($,"/open_channels"),oe="/".concat($,"/sdk/open_channels"),se="/".concat($,"/search"),ae="/".concat($,"/report"),ce="/".concat($,"/emojis"),ue="/".concat($,"/emoji_categories"),le="/".concat($,"/polls"),he="/".concat($,"/scheduled_messages"),de="/".concat($,"/sdk/ui_kit/configuration"),_e="/".concat($,"/sdk/statistics"),fe=function(e){switch(e){case x.GROUP:return ne;case x.OPEN:return ie;default:return null}},pe=function(e){switch(e){case x.GROUP:return"".concat(ae,"/group_channels");case x.OPEN:return"".concat(ae,"/open_channels");default:return null}},ge=function(e,t,n){var r,i;switch(e){case F.CHANNEL:return!0;case F.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},ve=function(e,t,n){var r=ge(e.mentionType,e.mentionedUserIds,n),i=ge(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0},Ee=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(o in e){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;A(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=Ee(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(J||(J={}));var be,me=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=V(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=X(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=X(this.params);return Object.keys(e).some((function(t){return A(e[t])}))?Ee(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),ye=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}(Y),we=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),Se=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:o.error=new E({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError},enumerable:!1,configurable:!0}),n}(Y),ke=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(Y);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(be||(be={}));var Te=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 X({stat_type:e.type,ts:e.createdAt,data:X(e.data)})},e}(),Ce=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Oe=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof we&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Ce()?"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(h.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,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new ke(new Te({type:be.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![J.GET,J.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:null),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-57274663.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new ye(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9: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}(),Ae=function(e){function n(t,n,r,i){void 0===i&&(i="");var o=e.call(this)||this;return o._iid=t,o.code=n,o.payload=r,o.requestId=r?r.req_id: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}(Y),Ne=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const Re=256,De=286,Le=30,xe=15,Me=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fe=new Array(576);Ie(Fe);const qe=new Array(60);Ie(qe);const Ge=new Array(512);Ie(Ge);const je=new Array(256);Ie(je);const Ke=new Array(29);Ie(Ke);const Be=new Array(Le);function Ze(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let Ve,He,We;function Qe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Be);const Ye=e=>e<256?Ge[e]:Ge[256+(e>>>7)],Xe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Je=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Je(e,n[2*t],n[2*t+1])},et=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},tt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=xe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=et(r[t]++,t))}},nt=e=>{let t;for(t=0;t{e.bi_valid>8?Xe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},it=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?$e(e,i,t):(o=je[i],$e(e,o+Re+1,t),s=Me[o],0!==s&&(i-=Ke[o],Je(e,i,s)),r--,o=Ye(r),$e(e,o,n),s=Pe[o],0!==s&&(r-=Be[o],Je(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)ot(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ot(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,ot(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=xe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),tt(n,u,e.bl_count)},ct=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{Je(e,0+(r?1:0),3),rt(e),Xe(e,n),Xe(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var dt=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(ct(e,e.dyn_ltree,e.l_desc.max_code),ct(e,e.dyn_dtree,e.d_desc.max_code),at(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ze[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?ht(e,t,n,r):4===e.strategy||o===i?(Je(e,2+(r?1:0),3),st(e,Fe,qe)):(Je(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Je(e,t-257,5),Je(e,n-1,5),Je(e,r-4,4),i=0;i{lt||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Ke[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(je[n]+Re+1)]++,e.dyn_dtree[2*Ye(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Je(e,2,3),$e(e,256,Fe),(e=>{16===e.bi_valid?(Xe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ft=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const pt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var gt=(e,t,n,r)=>{const i=pt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},vt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Et={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:bt,_tr_stored_block:mt,_tr_flush_block:yt,_tr_tally:wt,_tr_align:St}=_t,{Z_NO_FLUSH:kt,Z_PARTIAL_FLUSH:Tt,Z_FULL_FLUSH:Ct,Z_FINISH:Ot,Z_BLOCK:At,Z_OK:Nt,Z_STREAM_END:It,Z_STREAM_ERROR:Rt,Z_DATA_ERROR:Dt,Z_BUF_ERROR:Lt,Z_DEFAULT_COMPRESSION:xt,Z_FILTERED:Mt,Z_HUFFMAN_ONLY:Pt,Z_RLE:Ut,Z_FIXED:zt,Z_DEFAULT_STRATEGY:Ft,Z_UNKNOWN:qt,Z_DEFLATED:Gt}=Et,jt=258,Kt=262,Bt=42,Zt=113,Vt=666,Ht=(e,t)=>(e.msg=vt[t],t),Wt=e=>2*e-(e>4?9:0),Qt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Yt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let Xt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},$t=(e,t)=>{yt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Jt(e.strm)},en=(e,t)=>{e.pending_buf[e.pending++]=t},tn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},nn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=ft(e.adler,t,i,n):2===e.state.wrap&&(e.adler=gt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},rn=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Kt?e.strstart-(e.w_size-Kt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+jt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},on=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Kt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Yt(e),r+=t),0===e.strm.avail_in)break;if(n=nn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Xt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Xt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Jt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(nn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(nn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Ot)&&t!==kt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Ot&&0===e.strm.avail_in&&n===r?1:0,mt(e,e.block_start,n,s),e.block_start+=n,Jt(e.strm)),s?3:1)},an=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Kt&&(e.match_length=rn(e,n)),e.match_length>=3)if(r=wt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+1]);else r=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2},cn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=wt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&($t(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=wt(e,0,e.window[e.strstart-1]),r&&$t(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=wt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2};function un(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const ln=[new un(0,0,0,0,sn),new un(4,4,8,4,an),new un(4,5,16,8,an),new un(4,6,32,32,an),new un(4,4,16,16,cn),new un(8,16,32,32,cn),new un(8,16,128,128,cn),new un(8,32,128,256,cn),new un(32,128,258,1024,cn),new un(32,258,258,4096,cn)];function hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Qt(this.dyn_ltree),Qt(this.dyn_dtree),Qt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Qt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Qt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const dn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Bt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Vt?1:0},_n=e=>{if(dn(e))return Ht(e,Rt);e.total_in=e.total_out=0,e.data_type=qt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Bt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,bt(t),Nt},fn=e=>{const t=_n(e);var n;return t===Nt&&((n=e.state).window_size=2*n.w_size,Qt(n.head),n.max_lazy_match=ln[n.level].max_lazy,n.good_match=ln[n.level].good_length,n.nice_match=ln[n.level].nice_length,n.max_chain_length=ln[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},pn=(e,t,n,r,i,o)=>{if(!e)return Rt;let s=1;if(t===xt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Gt||r<8||r>15||t<0||t>9||o<0||o>zt||8===r&&1!==s)return Ht(e,Rt);8===r&&(r=9);const a=new hn;return e.state=a,a.strm=e,a.status=Bt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<pn(e,t,Gt,15,8,Ft),deflateInit2:pn,deflateReset:fn,deflateResetKeep:_n,deflateSetHeader:(e,t)=>dn(e)||2!==e.state.wrap?Rt:(e.state.gzhead=t,Nt),deflate:(e,t)=>{if(dn(e)||t>At||t<0)return e?Ht(e,Rt):Rt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Vt&&t!==Ot)return Ht(e,0===e.avail_out?Lt:Rt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Jt(e),0===e.avail_out)return n.last_flush=-1,Nt}else if(0===e.avail_in&&Wt(t)<=Wt(r)&&t!==Ot)return Ht(e,Lt);if(n.status===Vt&&0!==e.avail_in)return Ht(e,Lt);if(n.status===Bt&&0===n.wrap&&(n.status=Zt),n.status===Bt){let t=Gt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Pt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,tn(n,t),0!==n.strstart&&(tn(n,e.adler>>>16),tn(n,65535&e.adler)),e.adler=1,n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(57===n.status)if(e.adler=0,en(n,31),en(n,139),en(n,8),n.gzhead)en(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),en(n,255&n.gzhead.time),en(n,n.gzhead.time>>8&255),en(n,n.gzhead.time>>16&255),en(n,n.gzhead.time>>24&255),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(en(n,255&n.gzhead.extra.length),en(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=gt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(en(n,0),en(n,0),en(n,0),en(n,0),en(n,0),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,3),n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Jt(e),0!==n.pending))return n.last_flush=-1,Nt;en(n,255&e.adler),en(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(0!==e.avail_in||0!==n.lookahead||t!==kt&&n.status!==Vt){let r=0===n.level?sn(n,t):n.strategy===Pt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(on(e),0===e.lookahead)){if(t===kt)return 1;break}if(e.match_length=0,n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Ut?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=jt){if(on(e),e.lookahead<=jt&&t===kt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+jt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=wt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):ln[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Vt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Nt;if(2===r&&(t===Tt?St(n):t!==At&&(mt(n,0,0,!1),t===Ct&&(Qt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Jt(e),0===e.avail_out))return n.last_flush=-1,Nt}return t!==Ot?Nt:n.wrap<=0?It:(2===n.wrap?(en(n,255&e.adler),en(n,e.adler>>8&255),en(n,e.adler>>16&255),en(n,e.adler>>24&255),en(n,255&e.total_in),en(n,e.total_in>>8&255),en(n,e.total_in>>16&255),en(n,e.total_in>>24&255)):(tn(n,e.adler>>>16),tn(n,65535&e.adler)),Jt(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Nt:It)},deflateEnd:e=>{if(dn(e))return Rt;const t=e.state.status;return e.state=null,t===Zt?Ht(e,Dt):Nt},deflateSetDictionary:(e,t)=>{let n=t.length;if(dn(e))return Rt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Bt||r.lookahead)return Rt;if(1===i&&(e.adler=ft(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Qt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,on(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Xt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,on(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,Nt},deflateInfo:"pako deflate (from Nodeca project)"};const vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var En={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)vn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;mn[254]=mn[254]=1;var yn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&bn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+mn[e[n]]>t?n:t}};var wn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Sn=Object.prototype.toString,{Z_NO_FLUSH:kn,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:Cn,Z_FINISH:On,Z_OK:An,Z_STREAM_END:Nn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Rn,Z_DEFLATED:Dn}=Et;function Ln(e){this.options=En.assign({level:In,method:Dn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Rn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=gn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==An)throw new Error(vt[n]);if(t.header&&gn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?yn.string2buf(t.dictionary):"[object ArrayBuffer]"===Sn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=gn.deflateSetDictionary(this.strm,e),n!==An)throw new Error(vt[n]);this._dict_set=!0}}function xn(e,t){const n=new Ln(t);if(n.push(e,!0),n.err)throw n.msg||vt[n.err];return n.result}Ln.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?On:kn,"string"==typeof e?n.input=yn.string2buf(e):"[object ArrayBuffer]"===Sn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Tn||o===Cn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=gn.deflate(n,o),i===Nn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=gn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===An;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Ln.prototype.onData=function(e){this.chunks.push(e)},Ln.prototype.onEnd=function(e){e===An&&(this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mn={Deflate:Ln,deflate:xn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,xn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,xn(e,t)},constants:Et};const Pn=16209;var Un=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=Pn;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Pn;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,I,R=null;for(p=0;p<=zn;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=R[s[g]-f],I=T[s[g]-f]):(N=96,I=0),u=1<>y)+l]=A<<24|N<<16|I|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:Bn,Z_BLOCK:Zn,Z_TREES:Vn,Z_OK:Hn,Z_STREAM_END:Wn,Z_NEED_DICT:Qn,Z_STREAM_ERROR:Yn,Z_DATA_ERROR:Xn,Z_MEM_ERROR:Jn,Z_BUF_ERROR:$n,Z_DEFLATED:er}=Et,tr=16180,nr=16190,rr=16191,ir=16192,or=16194,sr=16199,ar=16200,cr=16206,ur=16209,lr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function hr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const dr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},_r=e=>{if(dr(e))return Yn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=tr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Hn},fr=e=>{if(dr(e))return Yn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,_r(e)},pr=(e,t)=>{let n;if(dr(e))return Yn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Yn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,fr(e))},gr=(e,t)=>{if(!e)return Yn;const n=new hr;e.state=n,n.strm=e,n.window=null,n.mode=tr;const r=pr(e,t);return r!==Hn&&(e.state=null),r};let vr,Er,br=!0;const mr=e=>{if(br){vr=new Int32Array(512),Er=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Kn(1,e.lens,0,288,vr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Kn(2,e.lens,0,32,Er,0,e.work,{bits:5}),br=!1}e.lencode=vr,e.lenbits=9,e.distcode=Er,e.distbits=5},yr=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whavegr(e,15),inflateInit2:gr,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(dr(e)||!e.output||!e.input&&0!==e.avail_in)return Yn;n=e.state,n.mode===rr&&(n.mode=ir),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Hn;e:for(;;)switch(n.mode){case tr:if(0===n.wrap){n.mode=ir;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=ur;break}if((15&u)!==er){e.msg="unknown compression method",n.mode=ur;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=ur;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=gt(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=gt(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=rr;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=cr;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(mr(n),n.mode=sr,t===Vn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ur}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=ur;break}if(n.length=65535&u,u=0,l=0,n.mode=or,t===Vn)break e;case or:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=rr;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ur;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=Kn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=ur;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=ur;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ur;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===ur)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ur;break}if(n.lenbits=9,C={bits:n.lenbits},S=Kn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=ur;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Kn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=ur;break}if(n.mode=sr,t===Vn)break e;case sr:n.mode=ar;case ar:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,Un(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===rr&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=rr;break}if(64&v){e.msg="invalid literal/length code",n.mode=ur;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=ur;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ur;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ur;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=ar);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=ar;break;case cr:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(dr(e))return Yn;let t=e.state;return t.window&&(t.window=null),e.state=null,Hn},inflateGetHeader:(e,t)=>{if(dr(e))return Yn;const n=e.state;return 0==(2&n.wrap)?Yn:(n.head=t,t.done=!1,Hn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return dr(e)?Yn:(r=e.state,0!==r.wrap&&r.mode!==nr?Yn:r.mode===nr&&(i=1,i=ft(i,t,n,0),i!==r.check)?Xn:(o=yr(e,t,n,n),o?(r.mode=16210,Jn):(r.havedict=1,Hn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Sr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const kr=Object.prototype.toString,{Z_NO_FLUSH:Tr,Z_FINISH:Cr,Z_OK:Or,Z_STREAM_END:Ar,Z_NEED_DICT:Nr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Rr,Z_MEM_ERROR:Dr}=Et;function Lr(e){this.options=En.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=wr.inflateInit2(this.strm,t.windowBits);if(n!==Or)throw new Error(vt[n]);if(this.header=new Sr,wr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=yn.string2buf(t.dictionary):"[object ArrayBuffer]"===kr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=wr.inflateSetDictionary(this.strm,t.dictionary),n!==Or)))throw new Error(vt[n])}function xr(e,t){const n=new Lr(t);if(n.push(e),n.err)throw n.msg||vt[n.err];return n.result}Lr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Cr:Tr,"[object ArrayBuffer]"===kr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=wr.inflate(n,s),o===Nr&&i&&(o=wr.inflateSetDictionary(n,i),o===Or?o=wr.inflate(n,s):o===Rr&&(o=Nr));n.avail_in>0&&o===Ar&&n.state.wrap>0&&0!==e[n.next_in];)wr.inflateReset(n),o=wr.inflate(n,s);switch(o){case Ir:case Rr:case Nr:case Dr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Ar))if("string"===this.options.to){let e=yn.utf8border(n.output,n.next_out),t=n.next_out-e,i=yn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Or||0!==a){if(o===Ar)return o=wr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Lr.prototype.onData=function(e){this.chunks.push(e)},Lr.prototype.onEnd=function(e){e===Or&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mr={Inflate:Lr,inflate:xr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,xr(e,t)},ungzip:xr,constants:Et};const{Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr}=Mn,{Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr}=Mr;var Br,Zr={Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr,Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr,constants:Et};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Br||(Br={}));var Vr,Hr=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Br.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Br.CONNECTING;case 1:return Br.OPEN}return Br.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ae.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Se(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},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){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=Zr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==Br.CLOSED?(e._ws.onopen=Ne,e._ws.onmessage=Ne,e._ws.onerror=Ne,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(W),Wr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?null:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:V(),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}(Y),Qr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(Y),Yr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Xr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Oe(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Hr(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Qr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(t=new Yr,e.ackRequired){n=null,r=function(r,o){void 0===r&&(r=null),void 0===o&&(o=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof me?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Wr?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.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.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Vr||(Vr={}));var Jr=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(Y),$r=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=Vr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Xr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof Jr){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Vr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case Vr.INITIALIZED:case Vr.INTERNAL_DISCONNECTED:case Vr.EXTERNAL_DISCONNECTED:case Vr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Vr.CONNECTING||this._currentConnectionStateType===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof Wr?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 Yr,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"),E.connectionRequired;case 3:return[3,7];case 4:return e instanceof me?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 Yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(E.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}(),ei="sendbird@devicetokens",ti=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),ni=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(ee,"/").concat(n,"/session_key"),s.method=J.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(me),ri=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?null:o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(Wr),ii=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}(ye),oi=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 E(r.error):null,i}return t(n,e),n}(Ae),si=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ai=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ci=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ui=function(e,t,n){return void 0===n&&(n=new ci),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return void 0===t&&(t=null),new ri({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(oi),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new ni({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,ui((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(ii).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Vr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)?t?(r=this.auth,[4,this._receiveNewAuthToken()]):[3,9]:[3,9];case 4:return r.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKey(this.auth.authToken,!1)]:[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return i=o.sent(),this._isSessionRelatedError(i)?t?(s=this.auth,[4,this._receiveNewAuthToken()]):[3,18]:[3,20];case 13:return s.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKeyByApi(this.auth.authToken)]:[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw i;case 19:return[3,21];case 20:throw i;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Yr;return li((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,di.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(ei)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(ei,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),di.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(W),fi=function(){function e(){this.type=Vr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),pi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new yi,t)];case 2:return s.sent(),li((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(fi),gi=function(e){function n(){var t=e.call(this)||this;return t.type=Vr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),vi=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Vr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new Ei,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),Ei=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,ui((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new bi,t)];case 3:return h.sent(),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new vi({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new Yr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new mi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new vi({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new Ei,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new vi({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),mi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Vr.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,ui((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new bi,t)];case 3:return a.sent(),li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new yi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new vi({autoReconnect:s}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new gi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),yi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new mi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(fi),wi=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Wr),Si=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 wi;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}(),ki=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return X({last_updated_at:e.lastUpdatedAt})},e}(),Ti=1048576,Ci=5,Oi=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ti:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new ki(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ti,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?ki.payloadify(e.uikitConfigInfo):void 0}},e}(),Ai=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),Ni=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(ee,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(me),Ii=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(ye),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=J.PUT,o.path="".concat(ee,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(me),Di=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(ye),Li=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=J.DELETE,i.path="".concat(ee,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var xi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=J.DELETE,r.path="".concat(ee,"/").concat(n,"/metadata"),r}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var Mi,Pi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ui=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},zi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Mi||(Mi={}));var Fi,qi=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Mi.NON_AVAILABLE,S(Mi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Mi.ONLINE:Mi.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=to.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Pi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ni({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Ii).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),n=to.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ri({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Di).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return zi(w("string",e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Li({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=to.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ai),Gi=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(Y),ji=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Oi(t),this.user=new qi(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return n(n(n({},qi.payloadify(e.user)),Oi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=to.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Gi({userProfile:this}))},e}(),Ki=function(e){function r(t,n,r){var i,o=this;return(o=e.call(this,t,n,r)||this).error=null,o.userProfile=new ji(t,r),o.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,o.key=r.key,o.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",o.error=r.error?new E(r):null,o}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=to.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(Ae),Bi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(Y),Zi=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,o=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,c=n.dispatcher,u=n.logger,l=n.entryState,h=void 0===l?new yi:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._logiProcessingTimer=null,d._unresolvedLogi=null,d._stateUpdatedAt=0,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=o,d._sessionManager=s,d._websocketClient=a,d._dispatcher=c,d._logger=u,d._currentState=h,d.sdkState.websocket.pingerDisabled||(d._pinger=new Si({pingDelegate:{send:function(e){return d._websocketClient.send(e)},error:function(e){return d._websocketClient.error(e)}},sdkState:d.sdkState,logger:u})),d._websocketClient.on("open",(function(){d._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)d.clearLoginTimer(),d._dispatcher.dispatch(e.as(Ki))})).on("ping-refresh",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){d._logiProcessingTimer=setTimeout((function(){d._logiProcessingTimer=null,d._unresolvedLogi||d._rejectConnectionRequest(E.networkError)}),500)})),d._dispatcher.on((function(e){e instanceof Ki&&(d._unresolvedLogi=e,d._tryResolveConnectionRequest())})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Jr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t;void 0===e&&(e="");var n=this.sdkState,r=n.appId,i=n.appVersion,o=n.userId,s=n.extensions,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,u=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,l=!!this.sdkState.extensions.sb_uikit,d=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",_=s.sb_uikit?"u".concat(s.sb_uikit):"",f="JS/c".concat(h.SDK_VERSION,"/").concat(d,"/").concat(_);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(r).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Bi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new ke(new Te({type:be.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(E.connectionCanceled)),t=this._url(e),n=new Yr,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._rejectConnectionRequest(E.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ki.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(W),Vi=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Zi(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Vr.CONNECTING||e.type===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return o(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.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Hi=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Te),Wi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(_e),i.params={device_id:n,log_entries:r.map((function(e){return Te.payloadify(e)}))},i}return t(n,e),n}(me),Qi=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Qi(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Fi||(Fi={}));var Yi,Xi=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=Fi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h.commandEventContext=null,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=V(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Fi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.API_RESULT||e.type===be.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==Fi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Te.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Hi){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Wi({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=Fi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Fi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Te({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,ai(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ke){var t=e.statLog;r.put(t)}else if(e instanceof Bi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?Fi.ENABLED:Fi.COLLECT_ONLY:r.enabledState=Fi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===Fi.DISABLED?[3,3]:(e instanceof Hi?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Hi&&t.key===e.key})),1),(n=t[0])?n.data=Qi(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)},n}(W);!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"}(Yi||(Yi={}));var Ji,$i=function(){function e(){this.level=Yi.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return co.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return Pi(this)},r}(Ai);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(ro||(ro={}));var lo=function(e){return e.startsWith("EVENT_")||e===ro.SYNC_MESSAGE_FILL||e===ro.SYNC_MESSAGE_CHANGELOGS||e===ro.SYNC_POLL_CHANGELOGS},ho=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}(Y),_o=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}(Y),fo=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}(Y),po=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(Y),go=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(Y),vo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=null,i.source=null,i.event=n,i.source=r,i}return t(n,e),n}(Y),Eo=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 w("number",this.limit)&&this.limit>0},e}(),bo=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(x,this.channelType)},n}(Eo);export{Ai as $,J as A,Eo as B,Br as C,Gi as D,W as E,ji as F,Se as G,d as H,hi as I,s as J,S as K,B as L,_ as M,p as N,x as O,f as P,K as Q,Yi as R,E as S,M as T,qi as U,to as V,Ae as W,ki as X,Mi as Y,te as Z,t as _,w as a,y as a0,P as a1,Pi as a2,F as a3,j as a4,C as a5,U as a6,uo as a7,G as a8,Wr as a9,ve as aA,z as aB,v as aC,vo as aD,N as aE,go as aF,fo as aG,re as aH,he as aI,io as aJ,lo as aK,Hi as aL,be as aM,ui as aN,oo as aO,oe as aP,ie as aQ,fe as aa,ge as ab,u as ac,ai as ad,Yr as ae,q as af,ne as ag,ro as ah,ho as ai,_o as aj,se as ak,bo as al,no as am,co as an,Ji as ao,Y as ap,O as aq,R as ar,r as as,le as at,ao as au,so as av,po as aw,Ci as ax,pe as ay,ae as az,i as b,o as c,ee as d,X as e,me as f,n as g,ye as h,A as i,ue as j,ce as k,de as l,T as m,Ne as n,I as o,Ce as p,c as q,a as r,zi as s,Ui as t,V as u,l as v,Jr as w,Vr as x,li as y,Qr 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!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=w("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},N=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=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),R={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),a?(this._clearOrder=o,this._customClearOrderComparator=a):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),Z=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}(),V=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)}))},H=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=V()}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}(),W=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new H({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new H({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()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),Q=function(){function e(){this._dispatcher=new W}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}(),Y=function(){},X=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(x||(x={})),function(e){e.OPERATOR="operator",e.NONE="none"}(M||(M={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(P||(P={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(U||(U={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(z||(z={})),function(e){e.USERS="users",e.CHANNEL="channel"}(F||(F={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(q||(q={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(G||(G={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(j||(j={}));var J,$="v3",ee="/".concat($,"/users"),te="/".concat($,"/storage/file"),ne="/".concat($,"/group_channels"),re="/".concat($,"/sdk/group_channels"),ie="/".concat($,"/open_channels"),oe="/".concat($,"/sdk/open_channels"),se="/".concat($,"/search"),ae="/".concat($,"/report"),ce="/".concat($,"/emojis"),ue="/".concat($,"/emoji_categories"),le="/".concat($,"/polls"),he="/".concat($,"/scheduled_messages"),de="/".concat($,"/sdk/ui_kit/configuration"),_e="/".concat($,"/sdk/statistics"),fe=function(e){switch(e){case x.GROUP:return ne;case x.OPEN:return ie;default:return null}},pe=function(e){switch(e){case x.GROUP:return"".concat(ae,"/group_channels");case x.OPEN:return"".concat(ae,"/open_channels");default:return null}},ge=function(e,t,n){var r,i;switch(e){case F.CHANNEL:return!0;case F.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},ve=function(e,t,n){var r=ge(e.mentionType,e.mentionedUserIds,n),i=ge(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0},Ee=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(o in e){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;A(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=Ee(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(J||(J={}));var be,me=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=V(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=X(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=X(this.params);return Object.keys(e).some((function(t){return A(e[t])}))?Ee(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),ye=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}(Y),we=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),Se=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:o.error=new E({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError},enumerable:!1,configurable:!0}),n}(Y),ke=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(Y);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(be||(be={}));var Te=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 X({stat_type:e.type,ts:e.createdAt,data:X(e.data)})},e}(),Ce=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Oe=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof we&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Ce()?"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(h.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,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new ke(new Te({type:be.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![J.GET,J.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:null),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-57274663.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new ye(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9: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}(),Ae=function(e){function n(t,n,r,i){void 0===i&&(i="");var o=e.call(this)||this;return o._iid=t,o.code=n,o.payload=r,o.requestId=r?r.req_id: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}(Y),Ne=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const Re=256,De=286,Le=30,xe=15,Me=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fe=new Array(576);Ie(Fe);const qe=new Array(60);Ie(qe);const Ge=new Array(512);Ie(Ge);const je=new Array(256);Ie(je);const Ke=new Array(29);Ie(Ke);const Be=new Array(Le);function Ze(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let Ve,He,We;function Qe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Be);const Ye=e=>e<256?Ge[e]:Ge[256+(e>>>7)],Xe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Je=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Je(e,n[2*t],n[2*t+1])},et=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},tt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=xe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=et(r[t]++,t))}},nt=e=>{let t;for(t=0;t{e.bi_valid>8?Xe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},it=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?$e(e,i,t):(o=je[i],$e(e,o+Re+1,t),s=Me[o],0!==s&&(i-=Ke[o],Je(e,i,s)),r--,o=Ye(r),$e(e,o,n),s=Pe[o],0!==s&&(r-=Be[o],Je(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)ot(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ot(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,ot(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=xe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),tt(n,u,e.bl_count)},ct=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{Je(e,0+(r?1:0),3),rt(e),Xe(e,n),Xe(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var dt=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(ct(e,e.dyn_ltree,e.l_desc.max_code),ct(e,e.dyn_dtree,e.d_desc.max_code),at(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ze[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?ht(e,t,n,r):4===e.strategy||o===i?(Je(e,2+(r?1:0),3),st(e,Fe,qe)):(Je(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Je(e,t-257,5),Je(e,n-1,5),Je(e,r-4,4),i=0;i{lt||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Ke[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(je[n]+Re+1)]++,e.dyn_dtree[2*Ye(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Je(e,2,3),$e(e,256,Fe),(e=>{16===e.bi_valid?(Xe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ft=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const pt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var gt=(e,t,n,r)=>{const i=pt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},vt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Et={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:bt,_tr_stored_block:mt,_tr_flush_block:yt,_tr_tally:wt,_tr_align:St}=_t,{Z_NO_FLUSH:kt,Z_PARTIAL_FLUSH:Tt,Z_FULL_FLUSH:Ct,Z_FINISH:Ot,Z_BLOCK:At,Z_OK:Nt,Z_STREAM_END:It,Z_STREAM_ERROR:Rt,Z_DATA_ERROR:Dt,Z_BUF_ERROR:Lt,Z_DEFAULT_COMPRESSION:xt,Z_FILTERED:Mt,Z_HUFFMAN_ONLY:Pt,Z_RLE:Ut,Z_FIXED:zt,Z_DEFAULT_STRATEGY:Ft,Z_UNKNOWN:qt,Z_DEFLATED:Gt}=Et,jt=258,Kt=262,Bt=42,Zt=113,Vt=666,Ht=(e,t)=>(e.msg=vt[t],t),Wt=e=>2*e-(e>4?9:0),Qt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Yt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let Xt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},$t=(e,t)=>{yt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Jt(e.strm)},en=(e,t)=>{e.pending_buf[e.pending++]=t},tn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},nn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=ft(e.adler,t,i,n):2===e.state.wrap&&(e.adler=gt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},rn=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Kt?e.strstart-(e.w_size-Kt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+jt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},on=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Kt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Yt(e),r+=t),0===e.strm.avail_in)break;if(n=nn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Xt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Xt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Jt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(nn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(nn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Ot)&&t!==kt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Ot&&0===e.strm.avail_in&&n===r?1:0,mt(e,e.block_start,n,s),e.block_start+=n,Jt(e.strm)),s?3:1)},an=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Kt&&(e.match_length=rn(e,n)),e.match_length>=3)if(r=wt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+1]);else r=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2},cn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=wt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&($t(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=wt(e,0,e.window[e.strstart-1]),r&&$t(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=wt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2};function un(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const ln=[new un(0,0,0,0,sn),new un(4,4,8,4,an),new un(4,5,16,8,an),new un(4,6,32,32,an),new un(4,4,16,16,cn),new un(8,16,32,32,cn),new un(8,16,128,128,cn),new un(8,32,128,256,cn),new un(32,128,258,1024,cn),new un(32,258,258,4096,cn)];function hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Qt(this.dyn_ltree),Qt(this.dyn_dtree),Qt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Qt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Qt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const dn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Bt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Vt?1:0},_n=e=>{if(dn(e))return Ht(e,Rt);e.total_in=e.total_out=0,e.data_type=qt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Bt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,bt(t),Nt},fn=e=>{const t=_n(e);var n;return t===Nt&&((n=e.state).window_size=2*n.w_size,Qt(n.head),n.max_lazy_match=ln[n.level].max_lazy,n.good_match=ln[n.level].good_length,n.nice_match=ln[n.level].nice_length,n.max_chain_length=ln[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},pn=(e,t,n,r,i,o)=>{if(!e)return Rt;let s=1;if(t===xt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Gt||r<8||r>15||t<0||t>9||o<0||o>zt||8===r&&1!==s)return Ht(e,Rt);8===r&&(r=9);const a=new hn;return e.state=a,a.strm=e,a.status=Bt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<pn(e,t,Gt,15,8,Ft),deflateInit2:pn,deflateReset:fn,deflateResetKeep:_n,deflateSetHeader:(e,t)=>dn(e)||2!==e.state.wrap?Rt:(e.state.gzhead=t,Nt),deflate:(e,t)=>{if(dn(e)||t>At||t<0)return e?Ht(e,Rt):Rt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Vt&&t!==Ot)return Ht(e,0===e.avail_out?Lt:Rt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Jt(e),0===e.avail_out)return n.last_flush=-1,Nt}else if(0===e.avail_in&&Wt(t)<=Wt(r)&&t!==Ot)return Ht(e,Lt);if(n.status===Vt&&0!==e.avail_in)return Ht(e,Lt);if(n.status===Bt&&0===n.wrap&&(n.status=Zt),n.status===Bt){let t=Gt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Pt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,tn(n,t),0!==n.strstart&&(tn(n,e.adler>>>16),tn(n,65535&e.adler)),e.adler=1,n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(57===n.status)if(e.adler=0,en(n,31),en(n,139),en(n,8),n.gzhead)en(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),en(n,255&n.gzhead.time),en(n,n.gzhead.time>>8&255),en(n,n.gzhead.time>>16&255),en(n,n.gzhead.time>>24&255),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(en(n,255&n.gzhead.extra.length),en(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=gt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(en(n,0),en(n,0),en(n,0),en(n,0),en(n,0),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,3),n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Jt(e),0!==n.pending))return n.last_flush=-1,Nt;en(n,255&e.adler),en(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(0!==e.avail_in||0!==n.lookahead||t!==kt&&n.status!==Vt){let r=0===n.level?sn(n,t):n.strategy===Pt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(on(e),0===e.lookahead)){if(t===kt)return 1;break}if(e.match_length=0,n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Ut?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=jt){if(on(e),e.lookahead<=jt&&t===kt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+jt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=wt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):ln[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Vt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Nt;if(2===r&&(t===Tt?St(n):t!==At&&(mt(n,0,0,!1),t===Ct&&(Qt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Jt(e),0===e.avail_out))return n.last_flush=-1,Nt}return t!==Ot?Nt:n.wrap<=0?It:(2===n.wrap?(en(n,255&e.adler),en(n,e.adler>>8&255),en(n,e.adler>>16&255),en(n,e.adler>>24&255),en(n,255&e.total_in),en(n,e.total_in>>8&255),en(n,e.total_in>>16&255),en(n,e.total_in>>24&255)):(tn(n,e.adler>>>16),tn(n,65535&e.adler)),Jt(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Nt:It)},deflateEnd:e=>{if(dn(e))return Rt;const t=e.state.status;return e.state=null,t===Zt?Ht(e,Dt):Nt},deflateSetDictionary:(e,t)=>{let n=t.length;if(dn(e))return Rt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Bt||r.lookahead)return Rt;if(1===i&&(e.adler=ft(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Qt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,on(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Xt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,on(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,Nt},deflateInfo:"pako deflate (from Nodeca project)"};const vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var En={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)vn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;mn[254]=mn[254]=1;var yn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&bn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+mn[e[n]]>t?n:t}};var wn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Sn=Object.prototype.toString,{Z_NO_FLUSH:kn,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:Cn,Z_FINISH:On,Z_OK:An,Z_STREAM_END:Nn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Rn,Z_DEFLATED:Dn}=Et;function Ln(e){this.options=En.assign({level:In,method:Dn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Rn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=gn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==An)throw new Error(vt[n]);if(t.header&&gn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?yn.string2buf(t.dictionary):"[object ArrayBuffer]"===Sn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=gn.deflateSetDictionary(this.strm,e),n!==An)throw new Error(vt[n]);this._dict_set=!0}}function xn(e,t){const n=new Ln(t);if(n.push(e,!0),n.err)throw n.msg||vt[n.err];return n.result}Ln.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?On:kn,"string"==typeof e?n.input=yn.string2buf(e):"[object ArrayBuffer]"===Sn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Tn||o===Cn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=gn.deflate(n,o),i===Nn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=gn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===An;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Ln.prototype.onData=function(e){this.chunks.push(e)},Ln.prototype.onEnd=function(e){e===An&&(this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mn={Deflate:Ln,deflate:xn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,xn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,xn(e,t)},constants:Et};const Pn=16209;var Un=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=Pn;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Pn;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,I,R=null;for(p=0;p<=zn;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=R[s[g]-f],I=T[s[g]-f]):(N=96,I=0),u=1<>y)+l]=A<<24|N<<16|I|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:Bn,Z_BLOCK:Zn,Z_TREES:Vn,Z_OK:Hn,Z_STREAM_END:Wn,Z_NEED_DICT:Qn,Z_STREAM_ERROR:Yn,Z_DATA_ERROR:Xn,Z_MEM_ERROR:Jn,Z_BUF_ERROR:$n,Z_DEFLATED:er}=Et,tr=16180,nr=16190,rr=16191,ir=16192,or=16194,sr=16199,ar=16200,cr=16206,ur=16209,lr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function hr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const dr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},_r=e=>{if(dr(e))return Yn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=tr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Hn},fr=e=>{if(dr(e))return Yn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,_r(e)},pr=(e,t)=>{let n;if(dr(e))return Yn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Yn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,fr(e))},gr=(e,t)=>{if(!e)return Yn;const n=new hr;e.state=n,n.strm=e,n.window=null,n.mode=tr;const r=pr(e,t);return r!==Hn&&(e.state=null),r};let vr,Er,br=!0;const mr=e=>{if(br){vr=new Int32Array(512),Er=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Kn(1,e.lens,0,288,vr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Kn(2,e.lens,0,32,Er,0,e.work,{bits:5}),br=!1}e.lencode=vr,e.lenbits=9,e.distcode=Er,e.distbits=5},yr=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whavegr(e,15),inflateInit2:gr,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(dr(e)||!e.output||!e.input&&0!==e.avail_in)return Yn;n=e.state,n.mode===rr&&(n.mode=ir),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Hn;e:for(;;)switch(n.mode){case tr:if(0===n.wrap){n.mode=ir;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=ur;break}if((15&u)!==er){e.msg="unknown compression method",n.mode=ur;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=ur;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=gt(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=gt(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=rr;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=cr;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(mr(n),n.mode=sr,t===Vn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ur}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=ur;break}if(n.length=65535&u,u=0,l=0,n.mode=or,t===Vn)break e;case or:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=rr;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ur;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=Kn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=ur;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=ur;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ur;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===ur)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ur;break}if(n.lenbits=9,C={bits:n.lenbits},S=Kn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=ur;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Kn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=ur;break}if(n.mode=sr,t===Vn)break e;case sr:n.mode=ar;case ar:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,Un(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===rr&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=rr;break}if(64&v){e.msg="invalid literal/length code",n.mode=ur;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=ur;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ur;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ur;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=ar);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=ar;break;case cr:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(dr(e))return Yn;let t=e.state;return t.window&&(t.window=null),e.state=null,Hn},inflateGetHeader:(e,t)=>{if(dr(e))return Yn;const n=e.state;return 0==(2&n.wrap)?Yn:(n.head=t,t.done=!1,Hn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return dr(e)?Yn:(r=e.state,0!==r.wrap&&r.mode!==nr?Yn:r.mode===nr&&(i=1,i=ft(i,t,n,0),i!==r.check)?Xn:(o=yr(e,t,n,n),o?(r.mode=16210,Jn):(r.havedict=1,Hn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Sr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const kr=Object.prototype.toString,{Z_NO_FLUSH:Tr,Z_FINISH:Cr,Z_OK:Or,Z_STREAM_END:Ar,Z_NEED_DICT:Nr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Rr,Z_MEM_ERROR:Dr}=Et;function Lr(e){this.options=En.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=wr.inflateInit2(this.strm,t.windowBits);if(n!==Or)throw new Error(vt[n]);if(this.header=new Sr,wr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=yn.string2buf(t.dictionary):"[object ArrayBuffer]"===kr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=wr.inflateSetDictionary(this.strm,t.dictionary),n!==Or)))throw new Error(vt[n])}function xr(e,t){const n=new Lr(t);if(n.push(e),n.err)throw n.msg||vt[n.err];return n.result}Lr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Cr:Tr,"[object ArrayBuffer]"===kr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=wr.inflate(n,s),o===Nr&&i&&(o=wr.inflateSetDictionary(n,i),o===Or?o=wr.inflate(n,s):o===Rr&&(o=Nr));n.avail_in>0&&o===Ar&&n.state.wrap>0&&0!==e[n.next_in];)wr.inflateReset(n),o=wr.inflate(n,s);switch(o){case Ir:case Rr:case Nr:case Dr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Ar))if("string"===this.options.to){let e=yn.utf8border(n.output,n.next_out),t=n.next_out-e,i=yn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Or||0!==a){if(o===Ar)return o=wr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Lr.prototype.onData=function(e){this.chunks.push(e)},Lr.prototype.onEnd=function(e){e===Or&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mr={Inflate:Lr,inflate:xr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,xr(e,t)},ungzip:xr,constants:Et};const{Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr}=Mn,{Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr}=Mr;var Br,Zr={Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr,Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr,constants:Et};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Br||(Br={}));var Vr,Hr=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Br.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Br.CONNECTING;case 1:return Br.OPEN}return Br.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ae.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Se(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},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){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=Zr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==Br.CLOSED?(e._ws.onopen=Ne,e._ws.onmessage=Ne,e._ws.onerror=Ne,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(W),Wr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?null:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:V(),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}(Y),Qr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(Y),Yr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Xr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Oe(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Hr(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Qr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(t=new Yr,e.ackRequired){n=null,r=function(r,o){void 0===r&&(r=null),void 0===o&&(o=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof me?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Wr?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.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.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Vr||(Vr={}));var Jr=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(Y),$r=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=Vr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Xr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof Jr){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Vr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case Vr.INITIALIZED:case Vr.INTERNAL_DISCONNECTED:case Vr.EXTERNAL_DISCONNECTED:case Vr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Vr.CONNECTING||this._currentConnectionStateType===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof Wr?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 Yr,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"),E.connectionRequired;case 3:return[3,7];case 4:return e instanceof me?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 Yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(E.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}(),ei="sendbird@devicetokens",ti=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),ni=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(ee,"/").concat(n,"/session_key"),s.method=J.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(me),ri=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?null:o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(Wr),ii=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}(ye),oi=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 E(r.error):null,i}return t(n,e),n}(Ae),si=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ai=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ci=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ui=function(e,t,n){return void 0===n&&(n=new ci),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return void 0===t&&(t=null),new ri({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(oi),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new ni({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,ui((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(ii).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Vr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)?t?(r=this.auth,[4,this._receiveNewAuthToken()]):[3,9]:[3,9];case 4:return r.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKey(this.auth.authToken,!1)]:[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return i=o.sent(),this._isSessionRelatedError(i)?t?(s=this.auth,[4,this._receiveNewAuthToken()]):[3,18]:[3,20];case 13:return s.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKeyByApi(this.auth.authToken)]:[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw i;case 19:return[3,21];case 20:throw i;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Yr;return li((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,di.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(ei)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(ei,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),di.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(W),fi=function(){function e(){this.type=Vr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),pi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new yi,t)];case 2:return s.sent(),li((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(fi),gi=function(e){function n(){var t=e.call(this)||this;return t.type=Vr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),vi=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Vr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new Ei,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),Ei=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,ui((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new bi,t)];case 3:return h.sent(),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new vi({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new Yr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new mi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new vi({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new Ei,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new vi({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),mi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Vr.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,ui((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new bi,t)];case 3:return a.sent(),li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new yi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new vi({autoReconnect:s}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new gi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),yi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new mi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(fi),wi=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Wr),Si=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 wi;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}(),ki=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return X({last_updated_at:e.lastUpdatedAt})},e}(),Ti=1048576,Ci=5,Oi=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ti:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new ki(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ti,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?ki.payloadify(e.uikitConfigInfo):void 0}},e}(),Ai=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),Ni=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(ee,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(me),Ii=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(ye),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=J.PUT,o.path="".concat(ee,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(me),Di=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(ye),Li=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=J.DELETE,i.path="".concat(ee,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var xi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=J.DELETE,r.path="".concat(ee,"/").concat(n,"/metadata"),r}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var Mi,Pi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ui=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},zi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Mi||(Mi={}));var Fi,qi=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Mi.NON_AVAILABLE,S(Mi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Mi.ONLINE:Mi.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=to.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Pi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ni({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Ii).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),n=to.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ri({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Di).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return zi(w("string",e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Li({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=to.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ai),Gi=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(Y),ji=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Oi(t),this.user=new qi(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return n(n(n({},qi.payloadify(e.user)),Oi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=to.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Gi({userProfile:this}))},e}(),Ki=function(e){function r(t,n,r){var i,o=this;return(o=e.call(this,t,n,r)||this).error=null,o.userProfile=new ji(t,r),o.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,o.key=r.key,o.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",o.error=r.error?new E(r):null,o}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=to.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(Ae),Bi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(Y),Zi=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,o=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,c=n.dispatcher,u=n.logger,l=n.entryState,h=void 0===l?new yi:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._logiProcessingTimer=null,d._unresolvedLogi=null,d._stateUpdatedAt=0,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=o,d._sessionManager=s,d._websocketClient=a,d._dispatcher=c,d._logger=u,d._currentState=h,d.sdkState.websocket.pingerDisabled||(d._pinger=new Si({pingDelegate:{send:function(e){return d._websocketClient.send(e)},error:function(e){return d._websocketClient.error(e)}},sdkState:d.sdkState,logger:u})),d._websocketClient.on("open",(function(){d._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)d.clearLoginTimer(),d._dispatcher.dispatch(e.as(Ki))})).on("ping-refresh",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){d._logiProcessingTimer=setTimeout((function(){d._logiProcessingTimer=null,d._unresolvedLogi||d._rejectConnectionRequest(E.networkError)}),500)})),d._dispatcher.on((function(e){e instanceof Ki&&(d._unresolvedLogi=e,d._tryResolveConnectionRequest())})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Jr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t;void 0===e&&(e="");var n=this.sdkState,r=n.appId,i=n.appVersion,o=n.userId,s=n.extensions,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,u=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,l=!!this.sdkState.extensions.sb_uikit,d=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",_=s.sb_uikit?"u".concat(s.sb_uikit):"",f="JS/c".concat(h.SDK_VERSION,"/").concat(d,"/").concat(_);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(r).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Bi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new ke(new Te({type:be.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(E.connectionCanceled)),t=this._url(e),n=new Yr,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._rejectConnectionRequest(E.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ki.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(W),Vi=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Zi(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Vr.CONNECTING||e.type===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return o(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.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Hi=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Te),Wi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(_e),i.params={device_id:n,log_entries:r.map((function(e){return Te.payloadify(e)}))},i}return t(n,e),n}(me),Qi=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Qi(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Fi||(Fi={}));var Yi,Xi=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=Fi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h.commandEventContext=null,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=V(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Fi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.API_RESULT||e.type===be.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==Fi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Te.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Hi){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Wi({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=Fi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Fi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Te({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,ai(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ke){var t=e.statLog;r.put(t)}else if(e instanceof Bi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?Fi.ENABLED:Fi.COLLECT_ONLY:r.enabledState=Fi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===Fi.DISABLED?[3,3]:(e instanceof Hi?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Hi&&t.key===e.key})),1),(n=t[0])?n.data=Qi(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)},n}(W);!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"}(Yi||(Yi={}));var Ji,$i=function(){function e(){this.level=Yi.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return co.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return Pi(this)},r}(Ai);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(ro||(ro={}));var lo=function(e){return e.startsWith("EVENT_")||e===ro.SYNC_MESSAGE_FILL||e===ro.SYNC_MESSAGE_CHANGELOGS||e===ro.SYNC_POLL_CHANGELOGS},ho=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}(Y),_o=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}(Y),fo=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}(Y),po=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(Y),go=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(Y),vo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=null,i.source=null,i.event=n,i.source=r,i}return t(n,e),n}(Y),Eo=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 w("number",this.limit)&&this.limit>0},e}(),bo=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(x,this.channelType)},n}(Eo);export{Ai as $,J as A,Eo as B,Br as C,Gi as D,W as E,ji as F,Se as G,d as H,hi as I,s as J,S as K,B as L,_ as M,p as N,x as O,f as P,K as Q,Yi as R,E as S,M as T,qi as U,to as V,Ae as W,ki as X,Mi as Y,te as Z,t as _,w as a,y as a0,P as a1,Pi as a2,F as a3,j as a4,C as a5,U as a6,uo as a7,G as a8,Wr as a9,ve as aA,z as aB,v as aC,vo as aD,N as aE,go as aF,fo as aG,re as aH,he as aI,io as aJ,lo as aK,Hi as aL,be as aM,ui as aN,oo as aO,oe as aP,ie as aQ,fe as aa,ge as ab,u as ac,ai as ad,Yr as ae,q as af,ne as ag,ro as ah,ho as ai,_o as aj,se as ak,bo as al,no as am,co as an,Ji as ao,Y as ap,O as aq,R as ar,r as as,le as at,ao as au,so as av,po as aw,Ci as ax,pe as ay,ae as az,i as b,o as c,ee as d,X as e,me as f,n as g,ye as h,A as i,ue as j,ce as k,de as l,T as m,Ne as n,I as o,Ce as p,c as q,a as r,zi as s,Ui as t,V as u,l as v,Jr as w,Vr as x,li as y,Qr as z}; diff --git a/lib/__bundle-e902ed46.js b/lib/__bundle-ad6d760f.js similarity index 52% rename from lib/__bundle-e902ed46.js rename to lib/__bundle-ad6d760f.js index 91095ba..e621183 100644 --- a/lib/__bundle-e902ed46.js +++ b/lib/__bundle-ad6d760f.js @@ -1 +1 @@ -import{a3 as e,a as t,K as n,m as r,U as i,a8 as a,g as s,e as o,i as u,ax as c,_ as l,A as d,aa as h,f as p,h as f,b as m,al as v,c as y,S as g,V as _,W as T,ay as U,az as I,O as w,a9 as M,ab as E,aA as b,aB as S,av as P,at as C,a7 as A,u as D,a0 as q,a4 as R,J as L,a1 as O,ac as N,s as F,ad as k,ai as Q,ah as z,y as x,aC as G,aq as V,$ as j,q as B,r as W,ae as K,aD as H}from"./__bundle-2cf2dbb7.js";import{d as Y,A as J,U as $,F as X,R as Z,T as ee,e as te,f as ne,b as re,c as ie,g as ae,h as se,i as oe,v as ue,j as ce,k as le,B as de,S as he}from"./__bundle-199cda92.js";import{i as pe,P as fe,a as me,b as ve}from"./__bundle-b3187dac.js";var ye,ge=100,_e="GroupChannel",Te="url",Ue=100,Ie="Message",we="messageId",Me="Poll",Ee="pollId",be={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Se=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Pe=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Ce=s(s({},be),{message:null,translationTargetLanguages:null,pollId:null}),Ae=function(e){return Se(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ye||(ye={}));var De,qe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Re=function(e){return e===ye.BLOB||e===ye.FILE},Le=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Oe=s(s({},be),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Ne=function(e){return Se(e)&&(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fe=function(e){return e?o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null},ke=s(s({},be),{fileInfoList:null}),Qe=function(e){return(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(De||(De={}));var ze,xe=function(){function e(e){var t,r,i,a;this.restrictionType=null,this.description=null,this.endAt=-1,this.remainingDuration=-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,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?o({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}):null},e}(),Ge=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new xe(n),r}return l(t,e),t.payloadify=function(t){return t?o(s(s({},e.payloadify.call(this,t)),xe.payloadify(t.restrictionInfo))):null},t}(i),Ve={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},je=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)},Be=s(s({},Ve),{message:null,translationTargetLanguages:null,pollId:null}),We=function(e){return je(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},Ke=s({},Ve),He=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=d.GET,s.path="".concat(h(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return l(t,e),t}(p),Ye=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 l(t,e),t}(f),Je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return l(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=_.of(this._iid).requestQueue,n=new He(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ye),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),$e=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=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return l(t,e),t}(p),Xe=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 Ge(t,e)}))),r}return l(t,e),t}(f),Ze=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return l(t,e),t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new $e(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Xe),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),et=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=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return l(t,e),t}(p),tt=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 Ge(t,e.user)}))),r}return l(t,e),t}(f),nt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return l(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new et(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(ze||(ze={}));var rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return l(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}l(t,e)}(f);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return l(t,e),t}(p),st=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 l(t,e),t}(f),ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return l(t,e),t}(p),ut=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 l(t,e),t}(f),ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return l(t,e),t}(p),lt=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return l(t,e),t}(f),dt=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=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return l(t,e),t}(p),ht=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 l(t,e),t}(f),pt=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 l(t,e),t}(T),ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return l(t,e),t}(p),mt=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 l(t,e),t}(f),vt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return l(t,e),t}(p),yt=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 l(t,e),t}(f),gt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return l(t,e),t}(p),_t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return l(t,e),t}(f),Tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return l(t,e),t}(p),Ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return l(t,e),t}(f),It=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=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return l(t,e),t}(p),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return l(t,e),t}(f),Mt=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 l(t,e),t}(T),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=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return l(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}l(t,e)}(f);var bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var 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=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return l(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}l(t,e)}(f);var Pt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return l(t,e),t}(T),Ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return l(t,e),t}(T),Dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var qt=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 Ge(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 l(t,e),t}(T),Rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return l(t,e),t}(T),Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var Nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return l(t,e),t}(T),Ft=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=d.POST,n.path="".concat(U(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return l(t,e),t}(p),kt=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=d.POST,n.path="".concat(I,"/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 l(t,e),t}(p),Qt=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=d.POST,n.path="".concat(U(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 l(t,e),t}(p),zt=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:o({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!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return l(n,t),n}(M),xt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new $(t,r);var u=_.of(t).sdkState;return o.isMentioned=E(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 l(t,e),t}(T),Gt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return l(n,t),n}(M),Vt=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 $(t,r);var d=_.of(t).sdkState;return l.mentionCountChange=b({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 l(t,e),t}(T),jt=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o({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 l(n,t),n}(M),Bt=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 X(t,r);var d=_.of(t).sdkState;return l.mentionCountChange=b({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 l(t,e),t}(T),Wt=function(e){function t(t){var n=e.call(this)||this;return n.method=d.DELETE,n.path="".concat(h(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var Kt=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 l(t,e),t}(T),Ht=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=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return l(t,e),t}(p),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(n),r}return l(t,e),t}(f),Jt=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=d.DELETE,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return l(t,e),t}(p),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(s({},n)),r}return l(t,e),t}(f),Xt=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=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return l(t,e),t}(p),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return l(t,e),t}(f),en=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return l(n,t),n}(p),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return l(t,e),t}(f),nn=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return ee.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return l(n,t),n}(p),rn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return l(t,e),t}(f),an=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=d.PUT,u.path="".concat(C,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return l(t,e),t}(p),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return l(t,e),t}(f),on=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return l(t,e),t}(p),cn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return l(t,e),t}(f),ln=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=d.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return l(t,e),t}(p),dn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return l(t,e),t}(f),hn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return l(t,e),t}(p),pn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return l(t,e),t}(f),fn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return l(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}l(t,e)}(f);var mn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===w.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return l(t,e),t}(M),vn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=null,i.channelUrl=null,i.channelType=null,i.event=new pe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return l(t,e),t}(T),yn=2,gn=function(e){function d(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._messageCollectionLastAccessedAt=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,r.metadata&&Object.keys(r.metadata).length>0&&r.ts&&(c._cachedMetaData=new Map,Object.keys(r.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})}))),c}return l(d,e),d.payloadify=function(t){return o(s(s({},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}))},d.prototype.isGroupChannel=function(){return this.channelType===w.GROUP},d.prototype.isOpenChannel=function(){return this.channelType===w.OPEN},Object.defineProperty(d.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),d.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},d.prototype._update=function(e){var t=o(e);Object.assign(this,t)},d.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},d.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(g.invalidParameters),n=_.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).message]}}))}))},d.prototype._createScheduledUserMessage=function(e,t){var n=this,r=_.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();k(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new en(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(tn).message;x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(G(r))throw r;k(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},d.prototype.sendFileMessage=function(e){var t=s(s({},Oe),e);return F(Ne(t)).throw(g.invalidParameters),this._sendFileMessage(t)},d.prototype.sendMultipleFilesMessage=function(e){var t=s(s({},ke),e),n=_.of(this._iid);F(function(e,t){return void 0===t&&(t=c),Se(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Qe(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(g.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return F(!r).throw(g.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)},d.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new se;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=_.of(n._iid).cacheContext.localCacheEnabled&&V(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new Q({messages:[i],source:i.sendingStatus===R.PENDING?z.REQUEST_RESEND_MESSAGE:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._autoResendFileMessage=function(e){F(e instanceof X).throw(g.invalidParameters);var t=_.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},d.prototype._sendMultipleFilesMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new ae;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e,o).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingMultipleFilesMessage(e,a,s);n._markMessageAsFailed(i,t),r.dispatch(new Q({messages:[i],source:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=_.of(this._iid).requestQueue,o=new nn(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(rn).message;x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(G(a))throw a;k(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},d.prototype.sendFileMessages=function(e){var t,n;F(e.every((function(e){return Ne(s(s({},Oe),e))}))).throw(g.invalidParameters);var r=new se;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).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},d.prototype.resendFileMessage=function(e,t){var n;return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){return r=Boolean(e.url)||u(t)||u(null===(n=e.messageParams)||void 0===n?void 0:n.file),F(e instanceof X&&r&&!e.scheduledInfo).throw(g.invalidParameters),i=new K,a=function(e,t){var n,r;return void 0===t&&(t=null),e.messageParams?(!e.url&&u(t)&&(e.messageParams.file=t),e.messageParams):o({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(r=e.thumbnails)||void 0===r?void 0:r.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},d.prototype.updateFileMessage=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return r=s(s({},Ke),n),F(t("number",e)&&function(e){return je(e)}(r)).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new jt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Bt).message]}}))}))},d.prototype.cancelUploadingFileMessage=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(t("string",e)).throw(g.invalidParameters),ie.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},d.prototype.copyFileMessage=function(e,t){var n,r,i;return m(this,void 0,void 0,(function(){var o,u;return y(this,(function(c){return F(e instanceof d&&t instanceof X&&t.sendingStatus===R.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(g.invalidParameters),o=new K,u=s(s({},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:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=t.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(u).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},d.prototype.deleteMessage=function(e){return m(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return F(e instanceof de).throw(g.invalidParameters),e.messageId>0?(t=_.of(this._iid).requestQueue,n=new Wt({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]}}))}))},d.prototype.addReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Ht({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Yt).reactionEvent]}}))}))},d.prototype.deleteReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as($t).reactionEvent]}}))}))},d.prototype._updateUserMessageMetaArray=function(e,t,n,r){return m(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=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Gt({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(Vt).message,a.dispatch(new Q({messages:[c],source:z.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},d.prototype._updateFileMessageMetaArray=function(e,t,n,r){return m(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=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new jt({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(Bt).message,a.dispatch(new Q({messages:[c],source:z.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},d.prototype.createMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},d.prototype.deleteMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},d.prototype.addMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},d.prototype.removeMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},d.prototype.report=function(e,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return F(n(ze,e)&&t("string",r)).throw(g.invalidParameters),i=_.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new Ft({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},d.prototype.reportUser=function(e,r,a){return m(this,void 0,void 0,(function(){var s,o,u,c;return y(this,(function(l){switch(l.label){case 0:return F(e instanceof i&&n(ze,r)&&t("string",a)).throw(g.invalidParameters),s=_.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new kt({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]}}))}))},d.prototype.reportMessage=function(e,r,i){return m(this,void 0,void 0,(function(){var a,s,o,u;return y(this,(function(c){switch(c.label){case 0:return F(e instanceof he&&n(ze,r)&&t("string",i)).throw(g.invalidParameters),a=_.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new Qt({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]}}))}))},d.prototype.updatePoll=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(o){switch(o.label){case 0:return F(t("number",e)&&function(e){return t("string",e.title,!0)&&P(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new an(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(sn).poll]}}))}))},d.prototype.deletePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i;return y(this,(function(a){switch(a.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new on({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},d.prototype.closePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(cn).poll]}}))}))},d.prototype.addPollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new ln({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(dn).poll]}}))}))},d.prototype.updatePollOption=function(e,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),F(i).throw(g.invalidParameters),a=_.of(this._iid).requestQueue,s=new hn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(pn).poll]}}))}))},d.prototype.deletePollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new fn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},d.prototype.votePoll=function(e,n){return m(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return y(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),F(i).throw(g.invalidParameters),a=_.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new mn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return c=d.sent(),l=c.as(vn).event,o.dispatch(new H({event:l,source:z.EVENT_POLL_VOTED})),[2,l]}}))}))},d.prototype.getPollChangeLogsSinceTimestamp=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("number",e)).throw(g.invalidParameters),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.getPollChangeLogsSinceToken=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("string",e,!0)),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new fe(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},d.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},d}(j);export{Vt as A,nt as B,Bt as C,Ue as D,xt as E,ye as F,Ve as G,je as H,Be as I,We as J,tn as K,yn as L,Ze as M,_e as N,Je as O,vn as P,ze as R,Ce as U,Te as a,Ie as b,we as c,Me as d,Ee as e,gn as f,Ge as g,xe as h,De as i,be as j,Le as k,Se as l,Fe as m,Re as n,qe as o,ge as p,Mt as q,pt as r,Pe as s,Nt as t,Lt as u,Ae as v,qt as w,Pt as x,At as y,Kt as z}; +import{a3 as e,a as t,K as n,m as r,U as i,a8 as a,g as s,e as o,i as u,ax as l,_ as c,A as d,aa as h,f as p,h as f,b as m,al as v,c as y,S as g,V as _,W as T,ay as U,az as I,O as w,a9 as M,ab as E,aA as b,aB as S,av as P,at as C,a7 as A,u as D,a0 as q,a4 as R,J as L,a1 as O,ac as N,s as F,ad as k,ai as Q,ah as z,y as x,aC as G,aq as V,$ as j,q as B,r as W,ae as K,aD as H}from"./__bundle-a8f5769e.js";import{d as Y,A as J,U as $,F as X,R as Z,T as ee,e as te,f as ne,b as re,c as ie,g as ae,h as se,i as oe,v as ue,j as le,k as ce,B as de,S as he}from"./__bundle-f20da9a5.js";import{i as pe,P as fe,a as me,b as ve}from"./__bundle-6bc4500a.js";var ye,ge=100,_e="GroupChannel",Te="url",Ue=100,Ie="Message",we="messageId",Me="Poll",Ee="pollId",be={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Se=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Pe=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Ce=s(s({},be),{message:null,translationTargetLanguages:null,pollId:null}),Ae=function(e){return Se(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ye||(ye={}));var De,qe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Re=function(e){return e===ye.BLOB||e===ye.FILE},Le=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Oe=s(s({},be),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Ne=function(e){return Se(e)&&(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fe=function(e){return e?o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null},ke=s(s({},be),{fileInfoList:null}),Qe=function(e){return(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(De||(De={}));var ze,xe=function(){function e(e){var t,r,i,a;this.restrictionType=null,this.description=null,this.endAt=-1,this.remainingDuration=-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,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?o({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}):null},e}(),Ge=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new xe(n),r}return c(t,e),t.payloadify=function(t){return t?o(s(s({},e.payloadify.call(this,t)),xe.payloadify(t.restrictionInfo))):null},t}(i),Ve={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},je=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)},Be=s(s({},Ve),{message:null,translationTargetLanguages:null,pollId:null}),We=function(e){return je(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},Ke=s({},Ve),He=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=d.GET,s.path="".concat(h(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return c(t,e),t}(p),Ye=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 c(t,e),t}(f),Je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=_.of(this._iid).requestQueue,n=new He(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ye),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),$e=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=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return c(t,e),t}(p),Xe=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 Ge(t,e)}))),r}return c(t,e),t}(f),Ze=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new $e(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Xe),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),et=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=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return c(t,e),t}(p),tt=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 Ge(t,e.user)}))),r}return c(t,e),t}(f),nt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new et(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(ze||(ze={}));var rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return c(t,e),t}(p),st=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 c(t,e),t}(f),ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return c(t,e),t}(p),ut=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 c(t,e),t}(f),lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return c(t,e),t}(p),ct=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return c(t,e),t}(f),dt=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=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return c(t,e),t}(p),ht=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 c(t,e),t}(f),pt=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 c(t,e),t}(T),ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return c(t,e),t}(p),mt=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 c(t,e),t}(f),vt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return c(t,e),t}(p),yt=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 c(t,e),t}(f),gt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return c(t,e),t}(p),_t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),Tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return c(t,e),t}(p),Ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),It=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,l=void 0===u?"set":u;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:l},n}return c(t,e),t}(p),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),Mt=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 c(t,e),t}(T),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=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var 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=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var Pt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var qt=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 Ge(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 c(t,e),t}(T),Rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return c(t,e),t}(T),Ft=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=d.POST,n.path="".concat(U(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return c(t,e),t}(p),kt=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=d.POST,n.path="".concat(I,"/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 c(t,e),t}(p),Qt=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,l=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(U(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:l,offending_user_id:o},n}return c(t,e),t}(p),zt=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:o({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!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return c(n,t),n}(M),xt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new $(t,r);var u=_.of(t).sdkState;return o.isMentioned=E(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 c(t,e),t}(T),Gt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return c(n,t),n}(M),Vt=function(e){function t(t,n,r){var i,a,s,o,u,l,c=this;(c=e.call(this,t,"MEDI",r)||this).message=new $(t,r);var d=_.of(t).sdkState;return c.mentionCountChange=b({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:c.message.mentionType,mentionedUserIds:null!==(u=c.message.mentionedUserIds)&&void 0!==u?u:null===(l=c.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),c}return c(t,e),t}(T),jt=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o({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 c(n,t),n}(M),Bt=function(e){function t(t,n,r){var i,a,s,o,u,l,c=this;(c=e.call(this,t,"FEDI",r)||this).message=new X(t,r);var d=_.of(t).sdkState;return c.mentionCountChange=b({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:c.message.mentionType,mentionedUserIds:null!==(u=c.message.mentionedUserIds)&&void 0!==u?u:null===(l=c.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),c}return c(t,e),t}(T),Wt=function(e){function t(t){var n=e.call(this)||this;return n.method=d.DELETE,n.path="".concat(h(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Kt=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 c(t,e),t}(T),Ht=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=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(p),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(n),r}return c(t,e),t}(f),Jt=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=d.DELETE,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(p),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(s({},n)),r}return c(t,e),t}(f),Xt=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=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return c(t,e),t}(p),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return c(t,e),t}(f),en=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(p),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return c(t,e),t}(f),nn=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return ee.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(p),rn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return c(t,e),t}(f),an=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=d.PUT,u.path="".concat(C,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return c(t,e),t}(p),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),on=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return c(t,e),t}(p),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),cn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=d.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return c(t,e),t}(p),dn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),hn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return c(t,e),t}(p),pn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),fn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var mn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===w.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return c(t,e),t}(M),vn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=null,i.channelUrl=null,i.channelType=null,i.event=new pe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return c(t,e),t}(T),yn=2,gn=function(e){function d(n,r){var a,s,o,u,l=this;return(l=e.call(this,n)||this).url="",l.channelType=w.BASE,l.name="",l.coverUrl="",l.customType="",l.data="",l.isFrozen=!1,l.isEphemeral=!1,l.creator=null,l.createdAt=0,l._messageCollectionLastAccessedAt=0,l.url=r.channel_url,l.name=null!==(a=r.name)&&void 0!==a?a:"",l.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",l.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",l.data=null!==(u=r.data)&&void 0!==u?u:"",l.isFrozen=!!t("boolean",r.freeze)&&r.freeze,l.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,l.creator=r.created_by?new i(l._iid,r.created_by):null,l.createdAt=1e3*r.created_at,r.metadata&&Object.keys(r.metadata).length>0&&r.ts&&(l._cachedMetaData=new Map,Object.keys(r.metadata).forEach((function(e){l._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})}))),l}return c(d,e),d.payloadify=function(t){return o(s(s({},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}))},d.prototype.isGroupChannel=function(){return this.channelType===w.GROUP},d.prototype.isOpenChannel=function(){return this.channelType===w.OPEN},Object.defineProperty(d.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),d.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},d.prototype._update=function(e){var t=o(e);Object.assign(this,t)},d.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},d.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(g.invalidParameters),n=_.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).message]}}))}))},d.prototype._createScheduledUserMessage=function(e,t){var n=this,r=_.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();k(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new en(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(tn).message;x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(G(r))throw r;k(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},d.prototype.sendFileMessage=function(e){var t=s(s({},Oe),e);return F(Ne(t)).throw(g.invalidParameters),this._sendFileMessage(t)},d.prototype.sendMultipleFilesMessage=function(e){var t=s(s({},ke),e),n=_.of(this._iid);F(function(e,t){return void 0===t&&(t=l),Se(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Qe(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(g.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return F(!r).throw(g.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)},d.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new se;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=_.of(n._iid).cacheContext.localCacheEnabled&&V(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new Q({messages:[i],source:i.sendingStatus===R.PENDING?z.REQUEST_RESEND_MESSAGE:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._autoResendFileMessage=function(e){F(e instanceof X).throw(g.invalidParameters);var t=_.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},d.prototype._sendMultipleFilesMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new ae;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e,o).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingMultipleFilesMessage(e,a,s);n._markMessageAsFailed(i,t),r.dispatch(new Q({messages:[i],source:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=_.of(this._iid).requestQueue,o=new nn(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(rn).message;x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(G(a))throw a;k(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},d.prototype.sendFileMessages=function(e){var t,n;F(e.every((function(e){return Ne(s(s({},Oe),e))}))).throw(g.invalidParameters);var r=new se;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).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},d.prototype.resendFileMessage=function(e,t){var n;return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){return r=Boolean(e.url)||u(t)||u(null===(n=e.messageParams)||void 0===n?void 0:n.file),F(e instanceof X&&r&&!e.scheduledInfo).throw(g.invalidParameters),i=new K,a=function(e,t){var n,r;return void 0===t&&(t=null),e.messageParams?(!e.url&&u(t)&&(e.messageParams.file=t),e.messageParams):o({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(r=e.thumbnails)||void 0===r?void 0:r.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},d.prototype.updateFileMessage=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return r=s(s({},Ke),n),F(t("number",e)&&function(e){return je(e)}(r)).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new jt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Bt).message]}}))}))},d.prototype.cancelUploadingFileMessage=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(t("string",e)).throw(g.invalidParameters),ie.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},d.prototype.copyFileMessage=function(e,t){var n,r,i;return m(this,void 0,void 0,(function(){var o,u;return y(this,(function(l){return F(e instanceof d&&t instanceof X&&t.sendingStatus===R.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(g.invalidParameters),o=new K,u=s(s({},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:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=t.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(u).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},d.prototype.deleteMessage=function(e){return m(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return F(e instanceof de).throw(g.invalidParameters),e.messageId>0?(t=_.of(this._iid).requestQueue,n=new Wt({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]}}))}))},d.prototype.addReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Ht({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Yt).reactionEvent]}}))}))},d.prototype.deleteReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as($t).reactionEvent]}}))}))},d.prototype._updateUserMessageMetaArray=function(e,t,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return i=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Gt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=c.sent(),l=u.as(Vt).message,a.dispatch(new Q({messages:[l],source:z.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},d.prototype._updateFileMessageMetaArray=function(e,t,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return i=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=c.sent(),l=u.as(Bt).message,a.dispatch(new Q({messages:[l],source:z.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},d.prototype.createMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},d.prototype.deleteMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},d.prototype.addMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},d.prototype.removeMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},d.prototype.report=function(e,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return F(n(ze,e)&&t("string",r)).throw(g.invalidParameters),i=_.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new Ft({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},d.prototype.reportUser=function(e,r,a){return m(this,void 0,void 0,(function(){var s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return F(e instanceof i&&n(ze,r)&&t("string",a)).throw(g.invalidParameters),s=_.of(this._iid),o=s.sdkState,u=s.requestQueue,l=new kt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(l)];case 1:return c.sent(),[2]}}))}))},d.prototype.reportMessage=function(e,r,i){return m(this,void 0,void 0,(function(){var a,s,o,u;return y(this,(function(l){switch(l.label){case 0:return F(e instanceof he&&n(ze,r)&&t("string",i)).throw(g.invalidParameters),a=_.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new Qt({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 l.sent(),[2]}}))}))},d.prototype.updatePoll=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(o){switch(o.label){case 0:return F(t("number",e)&&function(e){return t("string",e.title,!0)&&P(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new an(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(sn).poll]}}))}))},d.prototype.deletePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i;return y(this,(function(a){switch(a.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new on({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},d.prototype.closePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(ln).poll]}}))}))},d.prototype.addPollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new cn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(dn).poll]}}))}))},d.prototype.updatePollOption=function(e,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),F(i).throw(g.invalidParameters),a=_.of(this._iid).requestQueue,s=new hn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(pn).poll]}}))}))},d.prototype.deletePollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new fn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},d.prototype.votePoll=function(e,n){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l,c;return y(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),F(i).throw(g.invalidParameters),a=_.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new mn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return l=d.sent(),c=l.as(vn).event,o.dispatch(new H({event:c,source:z.EVENT_POLL_VOTED})),[2,c]}}))}))},d.prototype.getPollChangeLogsSinceTimestamp=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("number",e)).throw(g.invalidParameters),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.getPollChangeLogsSinceToken=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("string",e,!0)),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new fe(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},d.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},d}(j);export{Vt as A,nt as B,Bt as C,Ue as D,xt as E,ye as F,Ve as G,je as H,Be as I,We as J,tn as K,yn as L,Ze as M,_e as N,Je as O,vn as P,ze as R,Ce as U,Te as a,Ie as b,we as c,Me as d,Ee as e,gn as f,Ge as g,xe as h,De as i,be as j,Le as k,Se as l,Fe as m,Re as n,qe as o,ge as p,Mt as q,pt as r,Pe as s,Nt as t,Lt as u,Ae as v,qt as w,Pt as x,At as y,Kt as z}; diff --git a/lib/__bundle-b2746c15.js b/lib/__bundle-d67b9997.js similarity index 99% rename from lib/__bundle-b2746c15.js rename to lib/__bundle-d67b9997.js index e3e090c..feadddb 100644 --- a/lib/__bundle-b2746c15.js +++ b/lib/__bundle-d67b9997.js @@ -1 +1 @@ -import{a6 as e,a1 as t,af as n,b as r,J as i,c as s,g as a,a as o,i as c,_ as u,S as l,$ as h,ap as d,a4 as f,aq as _,w as m,x as p,ac as v,ai as y,ah as b,U as E,W as g,q as N,r as I,ar as w,as as A}from"./__bundle-2cf2dbb7.js";import{U as T,s as O,v as C,j as S,k as L,l as k,m as R,n as x,F as D,o as P,b as M,D as B}from"./__bundle-e902ed46.js";import{S as H,U as V,F as K,b as U,c as q}from"./__bundle-199cda92.js";var F,j,G;!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"}(F||(F={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(j||(j={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(G||(G={}));var z,W=function(e){switch(e){case F.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case F.CHRONOLOGICAL:return["-createdAt","syncIndex"];case F.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Y=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=n.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 H))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof H&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(z||(z={}));var Q,J,X=function(e){switch(e){case z.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case z.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Z=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},$=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"}(Q||(Q={})),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"}(J||(J={}));var ee,te={},ne=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Q.PROCESSING,this._queue=[],this._activationQueue=[],te[e]&&!t.forceCreate||(this.nodeId=$(),this.key=e,Z()&&(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,s=e.data,a=s.nodeId,o=s.requestId,c=s.key,u=s.op,l=s.data;if(a!==n.nodeId&&c===n.key)switch(u){case J.NEWNODE:n._sendSync();break;case J.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case J.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=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:J.REQUEST_LOCK,ts:e.ts})};try{for(var m=i(f),p=m.next();!p.done;p=m.next()){_(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=m.return)&&r.call(m)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case J.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case J.REQUEST_LOCK:n._requestLock(s);break;case J.ACQUIRE_LOCK:var v=n._queue.find((function(e){return e.requestId===o}));n._acquire(v);break;case J.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(J.REMOVENODE)}))),te[e]=this),te[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==Q.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:$(),key:this.key,op:e,data:t.data,ts:Date.now()};return Z()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(J.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&&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(J.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(J.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 r(this,void 0,void 0,(function(){var e=this;return s(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=Q.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(J.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(J.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(J.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),re=a(a({},T),{scheduledAt:null}),ie=function(e){return C(e)&&o("number",e.scheduledAt,!0)},se=a(a({},S),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),ae=function(e){return k(e)&&o("number",e.scheduledAt)&&(c(e.file)||o("string",e.fileUrl))&&o("string",e.fileName,!0)&&o("string",e.mimeType,!0)&&o("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return o("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},oe="UnsentMessage",ce="reqId",ue={},le=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,ue[t]=s,s._mutex=new ne("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return ue[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(oe)},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 l.invalidParameters;var t,n=a({},e.serialize());return e instanceof V?(e.messageParams&&(n.messageParams=O(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},O(t)),{scheduledAt:t.scheduledAt})))):e instanceof K?(e.messageParams&&(n.messageParams=L(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},L(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof U&&e.messageParams&&(n.messageParams=R(e.messageParams)),n},t.prototype._deserialize=function(e){return e?(e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=q.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof V?(a=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(a,n),[3,6]):[3,1]:[3,6];case 1:return n instanceof K?(a=e.messageParams).fileKey&&"string"==typeof a.fileKey&&x(a.fileType)?(i=a,[4,this.collection.getBlob(a.fileKey)]):[3,3]:[3,4];case 2:i.file=l.sent(),l.label=3;case 3:return n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(a,n),[3,6];case 4:return n instanceof U&&((a=e.messageParams)&&a.fileInfoList)?(n.messageParams=t.buildMultipleFilesMessageCreateParamsFromSerializedData(a,n),[4,Promise.all(n.messageParams.fileInfoList.map((function(e){return r(u,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&x(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=i.sent(),i.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:l.sent(),l.label=6;case 6:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof V?(o=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(o,n),[3,10]):[3,7]:[3,10];case 7:return n instanceof K?(o=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof o.fileKey&&x(o.fileType)?(c=o,[4,this.collection.getBlob(o.fileKey)]):[3,9]:[3,10];case 8:c.file=l.sent(),l.label=9;case 9:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(o,n),l.label=10;case 10:return[2,n]}}))}))},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,i=e.filter,a=void 0===i?new Y:i,o=e.order,c=void 0===o?z.CHANNEL_LATEST:o,u=e.sendingStatus,l=void 0===u?null:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f;return r(this,void 0,void 0,(function(){var e,t,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=X(c),t={"/where":function(e){return!!(c!==z.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&a.match(u._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),i={where:t,index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return o=h.sent(),[2,Promise.all(o.map((function(e){return r(u,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Y),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:z.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof K||e instanceof U?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a=this;return s(this,(function(o){switch(o.label){case 0:return e instanceof K?e.messageParams&&(i=e.messageParams).file&&P(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=D.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=D.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof U&&((i=e.messageParams)&&i.fileInfoList&&Array.isArray(i.fileInfoList))?[4,Promise.all(i.fileInfoList.map((function(t,n){return r(a,void 0,void 0,(function(){var r,i;return s(this,(function(s){switch(s.label){case 0:return(r=t.file)&&P(r)?[4,this.collection.saveBlob(r,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:i=s.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=i,t._uploadedMetaData.fileType=D.BLOB,s.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),he={},de=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,a=e.call(this,t)||this;return a._sdkState=r,a._cacheContext=i,a._unsentMessageCache=s,he[t]=a,a}return u(t,e),t.of=function(e){return he[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(M):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 a(a({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(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,i=e.limit,a=void 0===i?B:i,o=e.filter,c=void 0===o?new Y:o,u=e.order,l=void 0===u?z.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f,m=e.isPollOnly,p=void 0!==m&&m;return r(this,void 0,void 0,(function(){var e,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=X(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case z.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:X(z.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 r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:X(z.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=X(z.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof K&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}}))}))},t}(h),fe=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(d),_e={},me=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,_e[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof m)switch(e.stateType){case p.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case p.INTERNAL_DISCONNECTED:case p.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return _e[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=f.FAILED,r.errorCode=v.ACK_TIMEOUT,this._dispatcher.dispatch(new y({messages:[r],source:b.LOCAL_MESSAGE_FAILED})))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&_(r.errorCode)&&(a=(new Date).getTime(),o=r.createdAt+2592e5,a<=o?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(r.reqId)<0&&this._autoResendQueue.push(r):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(o).toLocaleString()),r.sendingStatus=f.FAILED,this._dispatcher.dispatch(new y({messages:[r],source:b.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===f.SUCCEEDED||e.sendingStatus===f.FAILED&&!_(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=le.of(this._iid))?[4,e.fetch({sendingStatus:f.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(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 fe({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ee||(ee={}));var pe,ve=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,i=n.blockee;return{blocker:new E(e,r),blockee:new E(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new E(e,t)})):[]}},e}(),ye=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(d);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(pe||(pe={}));var be,Ee=function(e){return e.startsWith("EVENT_")||e===pe.SYNC_CHANNEL_CHANGELOGS||e===pe.REFRESH_CHANNEL},ge=function(e){function t(t){var n=t.channels,r=t.source,i=t.data,s=void 0===i?null:i,a=e.call(this)||this;return a.channels=n,a.source=r,a.data=s,a}return u(t,e),t}(d),Ne=function(e){function t(t){var n=t.channelUrls,r=t.source,i=e.call(this)||this;return i.channelUrls=n,i.source=r,i}return u(t,e),t}(d),Ie=function(e){function t(){return e.call(this)||this}return u(t,e),t}(d),we=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ve(r),i}return u(t,e),t}(g),Ae={},Te=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,m=void 0!==_&&_;return Ae[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=m,Ae[t]=this),Ae[t]}return e.get=function(e){return Ae[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_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",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"}(be||(be={}));var Oe,Ce=function(e){function t(n){var r=n.code,i=void 0===r?be.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:be.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:be.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:be.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:be.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:be.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:be.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:be.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:be.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:be.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:be.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:be.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:be.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:be.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:be.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:be.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:be.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:be.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:be.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:be.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:be.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:be.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:be.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:be.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:be.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:be.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"}(Oe||(Oe={}));var Se,Le=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ce.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Le(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]=Le(e[r],t);return t.delete(e),n}return e},ke=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ce.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Re=function(e,t){for(var n=0,r=0;r>>0)%t},xe=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},De=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!De(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!De(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(ke(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ke(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ke(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ke(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Pe=function(){},Me=function(){return Promise.resolve()},Be=function(e){return e},He=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Se||(Se={}));var Ve,Ke,Ue,qe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Be:a,c=e.backward,u=void 0===c?Me:c,l=e.forward,h=void 0===l?Me:l,d=e.complete,f=void 0===d?Pe:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,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 r(this,void 0,void 0,(function(){var e,t,n;return s(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 r(this,void 0,void 0,(function(){var e,t,n;return s(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}(),Fe=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var c in this.condition[s])if(o.includes(c))for(var u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;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(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},d=this,i=0;i-1){var r=this._items[n];return t===Ue.PERSISTENT&&(r.state=Ke.PERSISTENT),t!==Ue.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)Xe.includes(this._items[r].state)&&Xe.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ke.VOLATILE})),a=s.length-this._limit;if(a>0){var o=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ke.VOLATILE&&a>0?a--:o.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}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!==Ke.VOLATILE}))},e}(),et=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;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(ze(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ze(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=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,N([],I(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=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],c=o.data;n[c.key]||(s.unshift(o),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=$e.get(this.dbname),r=t.generation,i=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return a(a({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(s.sent(),c=$e.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=tt.createFromCacheItem(i),null==a?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 r(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=Te.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,$e.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?tt.createFromCacheItem(a):new tt({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),$e.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),rt={},it=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var c=function(e,t,n){return"".concat(ze(e,t),"/index.").concat(n)}(t,n,i.join(">"));return rt[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=a,this._transaction.on(Ve.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ve.ERROR,this.indexerKey,(function(){return o.abort()}))),rt[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in rt)delete rt[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(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=I(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,s,a=[];try{for(var o=i(this.fields),c=o.next();!c.done;c=o.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Ce.indexTypesNotMatch;a.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ke(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 r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l,h,d,f,_,m,p,v,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=$e.get(this.dbname)).find(this._store,this.indexerKey,Ue.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),a=i(r),o=a.next(),s.label=4;case 4:return o.done?[3,7]:(c=o.value).startsWith(n)?[4,e.find(this._store,c,Ue.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=tt.createFromCacheItem(u))try{for(v=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){v={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(v)throw v.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),m={error:_},[3,10];case 9:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(m)throw m.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=Le(this._origin),s.label=12;case 12:return rt[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return $e.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete rt[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(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=Le(this._origin)},e.prototype.abort=function(){this._table=Le(this._origin)},e}(),st=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Oe.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=N([[r]],I(s.filter((function(e){return it.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new ne(function(e,t){return"".concat(ze(e,t),".lock")}(t,n)),this._blobContainer=new Je({dbname:t,collectionName:n,store:a}),this._transaction=new et({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=We(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===Oe.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,m,p,v=this;return s(this,(function(s){switch(s.label){case 0:return[4,this._mutex.lock()];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,9,,10]),t=Te.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=s.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:s.sent(),this._blockManager=new nt({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=N([],I(this.indexes),!1),a=[],o=r.map((function(e){return it.createKey(e)})),c=n?n.indexes.map((function(e){return it.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(it.parseKey(h))}catch(e){m={error:e}}finally{try{l&&!l.done&&(p=u.return)&&p.call(u)}finally{if(m)throw m.error}}return(d=[]).push.apply(d,N([],I(r.map((function(e){var t=new it({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store});return v._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,N([],I(a.map((function(e){return new it({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),o.sort().join(",")===c.sort().join(",")?[3,8]:(f=We(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata})]);case 7:s.sent(),s.label=8;case 8:return this._state=Oe.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Oe.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=it.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===it.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}throw Ce.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=We(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),o={error:a},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw Ce.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,m;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),a=r.next(),s.label=6;case 6:return a.done?[3,9]:[4,(l=a.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return a=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{a&&!a.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),a=r.next(),s.label=4;case 4:return a.done?[3,8]:0===(o=a.value).diff(o.getColumnValues(n),o.getColumnValues(e))?[3,7]:[4,o.removeItem(n)];case 5:return s.sent(),[4,o.addItem(e)];case 6:s.sent(),s.label=7;case 7:return a=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{a&&!a.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),o={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a;return s(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=i(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&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(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,Le(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ce.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new je({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ce.collectionNotReady},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestInsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestUpsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestUpdate(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,a,o,c,u,l,h,d,f,_,m,p,v,y,b=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,15]),n=e.where,a=void 0===n?{}:n,o=e.index,c=void 0===o?null:o,u=e.backward,l=void 0!==u&&u,h=[],[4,new Fe({condition:a,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(b,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,De(a,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),d=i(h),f=d.next(),E.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(Le(_))]);case 6:E.sent(),E.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return m=E.sent(),v={error:m},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,h];case 13:return p=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),p;case 15:return[3,17];case 16:throw this._transaction.clear(),Ce.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,a,o,c,u,l,h,d,f,_,m,p,v,y=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,a=e.index,o=void 0===a?null:a,c=e.backward,u=void 0!==c&&c,l=[],[4,new Fe({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(o)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,De(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),h=i(l),d=h.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:b.sent(),b.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=b.sent(),p={error:_},[3,11];case 10:try{d&&!d.done&&(v=h.return)&&v.call(h)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,l];case 13:throw m=b.sent(),this._mutex.unlock(),m;case 14:return[3,16];case 15:throw this._transaction.clear(),Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),at=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:w,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),N([],I(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(a=r.value,[4,this._getRaw(a)]);case 4:(o=s.sent())&&(e+=JSON.stringify(o).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(a=n.metadata)?void 0:a.shards)&&a.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Ce.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return o=c,[2,this.encryption.decrypt(JSON.parse(o.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,a({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,N([],I(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(a=i.metadata,t.push.apply(t,N([],I(r._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),a=i(e),o=a.next(),f.label=2;case 2:return o.done?[3,5]:(c=o.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{o&&!o.done&&(h=a.return)&&h.call(a)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),ot={},ct=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return ot[this.dbname]},set:function(e){ot[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(ot[this.dbname])return[2,Object.keys(ot[this.dbname])];throw Ce.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:return t.sent(),[2,ot[this.dbname][e]?a({key:e},ot[this.dbname][e]):null];case 2:throw Ce.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,o=r.data,c=r.metadata,ot[this.dbname][a]=Object.freeze({data:o,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ot[this.dbname][r]&&delete ot[this.dbname][r]}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,ot[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,a,o,c,u,l;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(a=r.value,(o=this.observer[a.key])&&"function"==typeof o.set&&(c=o.set()))throw c}catch(e){u={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,xe(this.delay)];case 1:return e.sent(),ot[this.dbname]={},[2]}}))}))},t}(at),ut="NestDBStore",lt=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ut,r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return u(t,e),t.prototype._getObjectStore=function(e){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);throw Ce.storeNotInitialized},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Z())return[3,4];if(!(Z()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ce.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(Ce.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Ce.storeNotAvailableInPrivateBrowsing)}else n(Ce.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ce.storeNotAvailable;case 5:return[3,7];case 6:throw Ce.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){if(n._indexedDb){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ut,{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}else r(Ce.storeNotAvailable)}))];case 2:return t._database=r.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t}(at),ht=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=A(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,a(a({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())a=r.value,o=a.key,a.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(o),JSON.stringify(a)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._asyncStorage)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(at);!function(e){function t(t){var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(a),JSON.stringify(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._mmkv)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(at);var dt,ft="[NESTDB]",_t=!0,mt=function(){function e(){}return e.off=function(){_t=!1},e.log=function(){for(var e=[],t=0;t0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof H))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof H&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(z||(z={}));var Q,J,X=function(e){switch(e){case z.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case z.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Z=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},$=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"}(Q||(Q={})),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"}(J||(J={}));var ee,te={},ne=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Q.PROCESSING,this._queue=[],this._activationQueue=[],te[e]&&!t.forceCreate||(this.nodeId=$(),this.key=e,Z()&&(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,s=e.data,a=s.nodeId,o=s.requestId,c=s.key,u=s.op,l=s.data;if(a!==n.nodeId&&c===n.key)switch(u){case J.NEWNODE:n._sendSync();break;case J.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case J.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=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:J.REQUEST_LOCK,ts:e.ts})};try{for(var m=i(f),p=m.next();!p.done;p=m.next()){_(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=m.return)&&r.call(m)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case J.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case J.REQUEST_LOCK:n._requestLock(s);break;case J.ACQUIRE_LOCK:var v=n._queue.find((function(e){return e.requestId===o}));n._acquire(v);break;case J.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(J.REMOVENODE)}))),te[e]=this),te[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==Q.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:$(),key:this.key,op:e,data:t.data,ts:Date.now()};return Z()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(J.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&&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(J.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(J.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 r(this,void 0,void 0,(function(){var e=this;return s(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=Q.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(J.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(J.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(J.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),re=a(a({},T),{scheduledAt:null}),ie=function(e){return C(e)&&o("number",e.scheduledAt,!0)},se=a(a({},S),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),ae=function(e){return k(e)&&o("number",e.scheduledAt)&&(c(e.file)||o("string",e.fileUrl))&&o("string",e.fileName,!0)&&o("string",e.mimeType,!0)&&o("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return o("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},oe="UnsentMessage",ce="reqId",ue={},le=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,ue[t]=s,s._mutex=new ne("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return ue[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(oe)},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 l.invalidParameters;var t,n=a({},e.serialize());return e instanceof V?(e.messageParams&&(n.messageParams=O(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},O(t)),{scheduledAt:t.scheduledAt})))):e instanceof K?(e.messageParams&&(n.messageParams=L(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},L(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof U&&e.messageParams&&(n.messageParams=R(e.messageParams)),n},t.prototype._deserialize=function(e){return e?(e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=q.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof V?(a=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(a,n),[3,6]):[3,1]:[3,6];case 1:return n instanceof K?(a=e.messageParams).fileKey&&"string"==typeof a.fileKey&&x(a.fileType)?(i=a,[4,this.collection.getBlob(a.fileKey)]):[3,3]:[3,4];case 2:i.file=l.sent(),l.label=3;case 3:return n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(a,n),[3,6];case 4:return n instanceof U&&((a=e.messageParams)&&a.fileInfoList)?(n.messageParams=t.buildMultipleFilesMessageCreateParamsFromSerializedData(a,n),[4,Promise.all(n.messageParams.fileInfoList.map((function(e){return r(u,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&x(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=i.sent(),i.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:l.sent(),l.label=6;case 6:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof V?(o=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(o,n),[3,10]):[3,7]:[3,10];case 7:return n instanceof K?(o=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof o.fileKey&&x(o.fileType)?(c=o,[4,this.collection.getBlob(o.fileKey)]):[3,9]:[3,10];case 8:c.file=l.sent(),l.label=9;case 9:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(o,n),l.label=10;case 10:return[2,n]}}))}))},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,i=e.filter,a=void 0===i?new Y:i,o=e.order,c=void 0===o?z.CHANNEL_LATEST:o,u=e.sendingStatus,l=void 0===u?null:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f;return r(this,void 0,void 0,(function(){var e,t,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=X(c),t={"/where":function(e){return!!(c!==z.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&a.match(u._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),i={where:t,index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return o=h.sent(),[2,Promise.all(o.map((function(e){return r(u,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Y),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:z.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof K||e instanceof U?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a=this;return s(this,(function(o){switch(o.label){case 0:return e instanceof K?e.messageParams&&(i=e.messageParams).file&&P(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=D.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=D.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof U&&((i=e.messageParams)&&i.fileInfoList&&Array.isArray(i.fileInfoList))?[4,Promise.all(i.fileInfoList.map((function(t,n){return r(a,void 0,void 0,(function(){var r,i;return s(this,(function(s){switch(s.label){case 0:return(r=t.file)&&P(r)?[4,this.collection.saveBlob(r,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:i=s.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=i,t._uploadedMetaData.fileType=D.BLOB,s.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),he={},de=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,a=e.call(this,t)||this;return a._sdkState=r,a._cacheContext=i,a._unsentMessageCache=s,he[t]=a,a}return u(t,e),t.of=function(e){return he[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(M):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 a(a({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(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,i=e.limit,a=void 0===i?B:i,o=e.filter,c=void 0===o?new Y:o,u=e.order,l=void 0===u?z.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f,m=e.isPollOnly,p=void 0!==m&&m;return r(this,void 0,void 0,(function(){var e,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=X(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case z.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:X(z.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 r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:X(z.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=X(z.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof K&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}}))}))},t}(h),fe=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(d),_e={},me=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,_e[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof m)switch(e.stateType){case p.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case p.INTERNAL_DISCONNECTED:case p.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return _e[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=f.FAILED,r.errorCode=v.ACK_TIMEOUT,this._dispatcher.dispatch(new y({messages:[r],source:b.LOCAL_MESSAGE_FAILED})))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&_(r.errorCode)&&(a=(new Date).getTime(),o=r.createdAt+2592e5,a<=o?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(r.reqId)<0&&this._autoResendQueue.push(r):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(o).toLocaleString()),r.sendingStatus=f.FAILED,this._dispatcher.dispatch(new y({messages:[r],source:b.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===f.SUCCEEDED||e.sendingStatus===f.FAILED&&!_(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=le.of(this._iid))?[4,e.fetch({sendingStatus:f.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(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 fe({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ee||(ee={}));var pe,ve=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,r=n.blocker,i=n.blockee;return{blocker:new E(e,r),blockee:new E(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new E(e,t)})):[]}},e}(),ye=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(d);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(pe||(pe={}));var be,Ee=function(e){return e.startsWith("EVENT_")||e===pe.SYNC_CHANNEL_CHANGELOGS||e===pe.REFRESH_CHANNEL},ge=function(e){function t(t){var n=t.channels,r=t.source,i=t.data,s=void 0===i?null:i,a=e.call(this)||this;return a.channels=n,a.source=r,a.data=s,a}return u(t,e),t}(d),Ne=function(e){function t(t){var n=t.channelUrls,r=t.source,i=e.call(this)||this;return i.channelUrls=n,i.source=r,i}return u(t,e),t}(d),Ie=function(e){function t(){return e.call(this)||this}return u(t,e),t}(d),we=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ve(r),i}return u(t,e),t}(g),Ae={},Te=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,m=void 0!==_&&_;return Ae[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=m,Ae[t]=this),Ae[t]}return e.get=function(e){return Ae[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_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",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"}(be||(be={}));var Oe,Ce=function(e){function t(n){var r=n.code,i=void 0===r?be.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:be.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:be.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:be.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:be.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:be.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:be.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:be.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:be.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:be.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:be.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:be.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:be.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:be.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:be.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:be.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:be.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:be.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:be.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:be.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:be.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:be.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:be.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:be.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:be.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:be.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"}(Oe||(Oe={}));var Se,Le=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ce.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Le(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]=Le(e[r],t);return t.delete(e),n}return e},ke=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ce.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Re=function(e,t){for(var n=0,r=0;r>>0)%t},xe=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},De=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!De(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!De(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(ke(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ke(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ke(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ke(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Pe=function(){},Me=function(){return Promise.resolve()},Be=function(e){return e},He=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Se||(Se={}));var Ve,Ke,Ue,qe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Be:a,c=e.backward,u=void 0===c?Me:c,l=e.forward,h=void 0===l?Me:l,d=e.complete,f=void 0===d?Pe:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,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 r(this,void 0,void 0,(function(){var e,t,n;return s(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 r(this,void 0,void 0,(function(){var e,t,n;return s(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}(),Fe=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var c in this.condition[s])if(o.includes(c))for(var u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;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(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},d=this,i=0;i-1){var r=this._items[n];return t===Ue.PERSISTENT&&(r.state=Ke.PERSISTENT),t!==Ue.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)Xe.includes(this._items[r].state)&&Xe.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ke.VOLATILE})),a=s.length-this._limit;if(a>0){var o=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ke.VOLATILE&&a>0?a--:o.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}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!==Ke.VOLATILE}))},e}(),et=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;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(ze(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ze(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=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,N([],I(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=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],c=o.data;n[c.key]||(s.unshift(o),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=$e.get(this.dbname),r=t.generation,i=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return a(a({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(s.sent(),c=$e.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=tt.createFromCacheItem(i),null==a?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 r(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=Te.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,$e.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?tt.createFromCacheItem(a):new tt({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),$e.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),rt={},it=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var c=function(e,t,n){return"".concat(ze(e,t),"/index.").concat(n)}(t,n,i.join(">"));return rt[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=a,this._transaction.on(Ve.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ve.ERROR,this.indexerKey,(function(){return o.abort()}))),rt[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in rt)delete rt[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(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=I(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,s,a=[];try{for(var o=i(this.fields),c=o.next();!c.done;c=o.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Ce.indexTypesNotMatch;a.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ke(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 r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l,h,d,f,_,m,p,v,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=$e.get(this.dbname)).find(this._store,this.indexerKey,Ue.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),a=i(r),o=a.next(),s.label=4;case 4:return o.done?[3,7]:(c=o.value).startsWith(n)?[4,e.find(this._store,c,Ue.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=tt.createFromCacheItem(u))try{for(v=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){v={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(v)throw v.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),m={error:_},[3,10];case 9:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(m)throw m.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=Le(this._origin),s.label=12;case 12:return rt[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return $e.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete rt[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(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=Le(this._origin)},e.prototype.abort=function(){this._table=Le(this._origin)},e}(),st=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Oe.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=N([[r]],I(s.filter((function(e){return it.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new ne(function(e,t){return"".concat(ze(e,t),".lock")}(t,n)),this._blobContainer=new Je({dbname:t,collectionName:n,store:a}),this._transaction=new et({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=We(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===Oe.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,m,p,v=this;return s(this,(function(s){switch(s.label){case 0:return[4,this._mutex.lock()];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,9,,10]),t=Te.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=s.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:s.sent(),this._blockManager=new nt({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=N([],I(this.indexes),!1),a=[],o=r.map((function(e){return it.createKey(e)})),c=n?n.indexes.map((function(e){return it.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(it.parseKey(h))}catch(e){m={error:e}}finally{try{l&&!l.done&&(p=u.return)&&p.call(u)}finally{if(m)throw m.error}}return(d=[]).push.apply(d,N([],I(r.map((function(e){var t=new it({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store});return v._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,N([],I(a.map((function(e){return new it({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),o.sort().join(",")===c.sort().join(",")?[3,8]:(f=We(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata})]);case 7:s.sent(),s.label=8;case 8:return this._state=Oe.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Oe.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=it.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===it.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}throw Ce.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=We(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),o={error:a},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw Ce.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,m;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),a=r.next(),s.label=6;case 6:return a.done?[3,9]:[4,(l=a.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return a=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{a&&!a.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),a=r.next(),s.label=4;case 4:return a.done?[3,8]:0===(o=a.value).diff(o.getColumnValues(n),o.getColumnValues(e))?[3,7]:[4,o.removeItem(n)];case 5:return s.sent(),[4,o.addItem(e)];case 6:s.sent(),s.label=7;case 7:return a=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{a&&!a.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),o={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a;return s(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=i(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&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(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,Le(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ce.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new je({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ce.collectionNotReady},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestInsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestUpsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionKeyNotGiven;return[4,this._requestUpdate(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,a,o,c,u,l,h,d,f,_,m,p,v,y,b=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,15]),n=e.where,a=void 0===n?{}:n,o=e.index,c=void 0===o?null:o,u=e.backward,l=void 0!==u&&u,h=[],[4,new Fe({condition:a,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(b,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,De(a,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),d=i(h),f=d.next(),E.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(Le(_))]);case 6:E.sent(),E.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return m=E.sent(),v={error:m},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,h];case 13:return p=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),p;case 15:return[3,17];case 16:throw this._transaction.clear(),Ce.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,a,o,c,u,l,h,d,f,_,m,p,v,y=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,a=e.index,o=void 0===a?null:a,c=e.backward,u=void 0!==c&&c,l=[],[4,new Fe({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(o)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,De(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),h=i(l),d=h.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:b.sent(),b.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=b.sent(),p={error:_},[3,11];case 10:try{d&&!d.done&&(v=h.return)&&v.call(h)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,l];case 13:throw m=b.sent(),this._mutex.unlock(),m;case 14:return[3,16];case 15:throw this._transaction.clear(),Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(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 r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),at=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:w,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),N([],I(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(a=r.value,[4,this._getRaw(a)]);case 4:(o=s.sent())&&(e+=JSON.stringify(o).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(a=n.metadata)?void 0:a.shards)&&a.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Ce.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return o=c,[2,this.encryption.decrypt(JSON.parse(o.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,a({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,N([],I(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(a=i.metadata,t.push.apply(t,N([],I(r._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),a=i(e),o=a.next(),f.label=2;case 2:return o.done?[3,5]:(c=o.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{o&&!o.done&&(h=a.return)&&h.call(a)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),ot={},ct=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return ot[this.dbname]},set:function(e){ot[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(ot[this.dbname])return[2,Object.keys(ot[this.dbname])];throw Ce.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:return t.sent(),[2,ot[this.dbname][e]?a({key:e},ot[this.dbname][e]):null];case 2:throw Ce.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,o=r.data,c=r.metadata,ot[this.dbname][a]=Object.freeze({data:o,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return ot[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ot[this.dbname][r]&&delete ot[this.dbname][r]}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,ot[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,a,o,c,u,l;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(a=r.value,(o=this.observer[a.key])&&"function"==typeof o.set&&(c=o.set()))throw c}catch(e){u={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,xe(this.delay)];case 1:return e.sent(),ot[this.dbname]={},[2]}}))}))},t}(at),ut="NestDBStore",lt=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ut,r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return u(t,e),t.prototype._getObjectStore=function(e){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);throw Ce.storeNotInitialized},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Z())return[3,4];if(!(Z()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ce.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(Ce.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Ce.storeNotAvailableInPrivateBrowsing)}else n(Ce.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ce.storeNotAvailable;case 5:return[3,7];case 6:throw Ce.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){if(n._indexedDb){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ut,{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}else r(Ce.storeNotAvailable)}))];case 2:return t._database=r.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t}(at),ht=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=A(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,a(a({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())a=r.value,o=a.key,a.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(o),JSON.stringify(a)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._asyncStorage)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(at);!function(e){function t(t){var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(a),JSON.stringify(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._mmkv)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(at);var dt,ft="[NESTDB]",_t=!0,mt=function(){function e(){}return e.off=function(){_t=!1},e.log=function(){for(var e=[],t=0;t0&&d("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){l[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}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?s({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 $.ADD:t<0&&this.userIds.push(e.userId);break;case $.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),re=function(){function e(e){this.key=e.key,this.value=o("string",e.value)?h([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return e?s({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),le=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?s({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}(),ue=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 le(e["og:image"]))}return e.payloadify=function(e){return e?s({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?le.payloadify(e.defaultImage):null}):null},e}(),oe=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?s({name:e.name,volume:e.volume}):null},e}(),de=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.role=null,s.isBlockedByMe=!1,s.role=c(f,n.role)?n.role:f.NONE,n.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=n.is_blocked_by_me),s}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},n}(l);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ne||(ne={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(se||(se={}));var ce=function(e){switch(e){case y.BASE:return"";case y.USER:return"MESG";case y.FILE:return"FILE";case y.ADMIN:return"ADMM"}},he=function(t){function n(e,n){var s,a,i,r,u,o,d,h,p,m,f,g,_,T,M,S=this;(S=t.call(this,e)||this).channelUrl=null,S.channelType=v.BASE,S.messageId=0,S.parentMessageId=null,S.parentMessage=null,S.silent=!1,S.isOperatorMessage=!1,S.messageType=y.BASE,S.data=null,S.customType=null,S.mentionType=null,S.mentionedUsers=[],S.mentionedUserIds=[],S.mentionedMessageTemplate=null,S.threadInfo=null,S.reactions=[],S.metaArrays=[],S.ogMetaData=null,S.appleCriticalAlertOptions=null,S.createdAt=0,S.updatedAt=0,S.scheduledInfo=null,S.extendedMessage={},S._isContinuousMessages=!1,S._scheduledStatus=null,S.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,S.channelUrl=n.channel_url,S.channelType=c(v,n.channel_type)?n.channel_type:v.GROUP,n.channel&&(n.channel.channel_url&&(S.channelUrl=n.channel.channel_url),n.channel.channel_type&&(S.channelType=n.channel.channel_type)),S.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,S.data=null!==(r=n.data)&&void 0!==r?r:"",S.customType=null!==(u=n.custom_type)&&void 0!==u?u:"",S.mentionType=c(I,n.mention_type)?n.mention_type:null;var U=n.mentioned_users;S.mentionedUsers=U?U.map((function(e){return new l(S._iid,e)})):null;var b=n.mentioned_user_ids;S.mentionedUserIds=null!=b?b:null,S.mentionedUsers&&!S.mentionedUserIds&&(S.mentionedUserIds=S.mentionedUsers.map((function(e){return e.userId}))),S.mentionedMessageTemplate=null!==(o=n.mentioned_message_template)&&void 0!==o?o:"",S.threadInfo=n.thread_info?new te(S._iid,n.thread_info):null,S.reactions=n.reactions?n.reactions.map((function(e){return new ie(e)})):[];for(var A=null!==(d=n.metaarray)&&void 0!==d?d:{},E=null!==(h=n.metaarray_key_order)&&void 0!==h?h:Object.keys(A).sort((function(e,t){return e.localeCompare(t)})),w=0;w=t)return this.parentMessage=e,!0}return!1},n}(u),pe=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).sender=null,l.reqId="",l.replyToChannel=!1,l.sendingStatus=null,l.errorCode=0,l.sender=n.user?new de(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&c(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(l._scheduledStatus=n.scheduled_status,n.scheduled_status){case se.SENT:case se.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case se.PENDING:l.sendingStatus=T.SCHEDULED;break;case se.FAILED:case se.REMOVED:l.sendingStatus=T.FAILED;break;case se.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{user:de.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&M(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(he),me=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?s({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}(),fe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ge=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},ye=function(t){function n(e,n){var a,i,l,u,o=this;if((o=t.call(this,e,n)||this).message=null,o.translations={},o.message=null!==(a=n.message)&&void 0!==a?a:"",o.messageType=y.ADMIN,o.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var d=n.parent_message_info,c=s(r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth}));o.parentMessage=Se(e,c)}return o}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(he),_e=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")&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?s({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),ve=function(t){function n(e,n){var a,i,l,u,o,d,c,h=this;if((h=t.call(this,e,n)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=n.message,h.messageType=y.USER,h.translations=null!==(l=n.translations)&&void 0!==l?l:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=m(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var g=f.value;h.translations[g]=""}}catch(e){a={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(h.messageSurvivalSeconds=null!==(o=n.message_survival_seconds)&&void 0!==o?o:-1,h.plugins=n.plugins?n.plugins.map((function(e){return new _e(e)})):[],h._poll=n.poll?new w(h._iid,n.poll):null,n.parent_message_info){var _=n.parent_message_info,v=s(r(r({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(c=_.file)||void 0===c?void 0:c.require_auth}));h.parentMessage=Se(e,s(v))}return h}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return _e.payloadify(e)})),poll:w.payloadify(e._poll),parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(pe),Ie=function(t){function n(e,n){var s,a,i,l,u=this;(u=t.call(this,e)||this).plainUrl="",u.fileName=null,u.mimeType=null,u.fileSize=0,u.thumbnails=[],u._requireAuth=!1,u.plainUrl=n.url,u.fileName=null!==(s=n.file_name)&&void 0!==s?s:null,u.mimeType=null!==(a=n.file_type)&&void 0!==a?a:null,u.fileSize=null!==(i=n.file_size)&&void 0!==i?i:0;var o=F.of(u._iid).sessionManager;return u._requireAuth=null!==(l=n.require_auth)&&void 0!==l&&l,u.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(u._requireAuth?"?auth=".concat(o.ekey):"")}))})):[],u}return e(n,t),n.payloadify=function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(u),Te=function(t){function n(e,n){var s,a,i,l,u,o=this;if((o=t.call(this,e,n)||this).messageParams=null,o.fileInfoList=[],o.messageSurvivalSeconds=-1,o.messageType=y.FILE,o.fileInfoList=null!==(a=null===(s=n.files)||void 0===s?void 0:s.map((function(t){return new Ie(e,t)})))&&void 0!==a?a:[],o.messageSurvivalSeconds=null!==(i=n.message_survival_seconds)&&void 0!==i?i:-1,n.parent_message_info){var d=n.parent_message_info,c=r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth});o.parentMessage=Se(e,c)}return o}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Ie.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(pe),Me=function(e){if(e)switch(e.messageType){case y.USER:return ve.payloadify(e);case y.FILE:return Ue.payloadify(e);case y.ADMIN:return ye.payloadify(e)}return null},Se=function(e,t){switch(t.type){case"MESG":return new ve(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new Ue(e,t);case"ADMM":case"BRDM":return new ye(e,t)}return null},Ue=function(t){function n(e,n){var a,i,l,u,o,d,c,h,p,m,f,g,_,v,I,T=this;(T=t.call(this,e,n)||this).messageParams=null,T.plainUrl="",T.requireAuth=!1,T.name=null,T.size=0,T.type=null,T.thumbnails=[],T.messageSurvivalSeconds=-1,T.messageType=y.FILE;var M=null!==(a=n.file)&&void 0!==a?a:null;T.plainUrl=(null!==(l=null!==(i=null==M?void 0:M.url)&&void 0!==i?i:n.url)&&void 0!==l?l:"").split("?auth=")[0],T.name=null!==(o=null!==(u=null==M?void 0:M.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",T.size=null!==(c=null!==(d=null==M?void 0:M.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,T.data=null!==(p=null!==(h=null==M?void 0:M.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",T.type=M?null!==(m=M.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=F.of(T._iid).sessionManager;if(T.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,T.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(T.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],T.messageSurvivalSeconds=null!==(_=n.message_survival_seconds)&&void 0!==_?_:-1,n.parent_message_info){var U=n.parent_message_info,b=s(r(r({},U),{message_id:T.parentMessageId,channel_url:T.channelUrl,channel_type:T.channelType,file:U.file,url:null===(v=U.file)||void 0===v?void 0:v.url,require_auth:null===(I=U.file)||void 0===I?void 0:I.require_auth}));T.parentMessage=Se(e,b)}return T}return e(n,t),n.payloadify=function(e){var n;return e?s(r(r({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),be=function(t){function n(e){var n,a,i,r=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s({channel_url:e.channelUrl,files:Fe(e.files),url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==q.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage})})||this}return e(n,t),n}(D),Ae=function(n){function a(e){var a,i,r=this;r=n.call(this)||this;var l=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),r.method=t.POST,r.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),r.params=s({message_type:y.FILE,user_id:e.userId,files:Fe(e.files),url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:l,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(a=e.thumbnailSizes)||void 0===a?void 0:a.map((function(e){return me.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return re.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,apple_critical_alert_options:oe.payloadify(e.appleCriticalAlertOptions),reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}),r}return e(a,n),a}(a),Ee=function(t){function n(e,n,s){var a,i,r,l=this;(l=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new Ue(e,s);var u=F.of(e).sdkState;return l.isMentioned=N(l.message.mentionType,null!==(a=l.message.mentionedUserIds)&&void 0!==a?a:null===(i=l.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),u.userId),l.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(C),we=function(t){function n(e,n){var s,a,i=this;(i=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new Ue(e,n);var r=F.of(e).sdkState;return i.isMentioned=N(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),r.userId),i.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,i}return e(n,t),n}(i);function Fe(e){return null==e?void 0:e.map((function(e){var t,n;return s({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return me.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var qe;!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"}(qe||(qe={}));var De=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof R&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,s,a;return b(this,(function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(s=new be(n),[4,this._requestQueue.send(s)]):[3,2];case 1:return a=i.sent(),[2,a.as(Ee).message];case 2:return s=new Ae(r(r({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(we).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var s=t.params;n.files=s.fileInfoList}else{s=t.params;n.url=s.fileUrl,n.requireAuth=s.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){return U(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h;return b(this,(function(p){switch(p.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],s=!0,p.label=1;case 1:p.trys.push([1,15,16,17]),a=m(t.messageQueue),i=a.next(),p.label=2;case 2:if(i.done)return[3,14];switch(r=i.value,r.state){case qe.PENDING:case qe.UPLOADING:return[3,3];case qe.UPLOADED:return[3,4];case qe.FAILED:return[3,12]}return[3,13];case 3:return s=!1,n.push(r),[3,13];case 4:if(!s)return[3,10];p.label=5;case 5:return p.trys.push([5,8,,9]),r.state=qe.SENDING,[4,this._sendFileMessage(e,r)];case 6:return l=p.sent(),r.deferred.resolve(l),[4,k(100)];case 7:return p.sent(),[3,9];case 8:return u=p.sent(),r.deferred.reject(u),[3,9];case 9:return[3,11];case 10:n.push(r),p.label=11;case 11:return[3,13];case 12:return r.deferred.reject(r.error.code===L.REQUEST_CANCELED?E.fileUploadCanceled:r.error),[3,13];case 13:return i=a.next(),[3,2];case 14:return[3,17];case 15:return o=p.sent(),c={error:o},[3,17];case 16:try{i&&!i.done&&(h=a.return)&&h.call(a)}finally{if(c)throw c.error}return[7];case 17:return d=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,d?[4,this._resolveMessageQueue(e)]:[3,19];case 18:p.sent(),p.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,p.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return U(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d;return b(this,(function(c){switch(c.label){case 0:return n=this._queueMap.get(e.url),(s=n.messageQueue.find((function(e){return e.state===qe.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!z(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,s)]):[3,4]:[3,9];case 1:return c.sent(),[3,3];case 2:s.state=i=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var s,a,i;return U(this,void 0,void 0,(function(){var r,l,u,o,d,c,h,p,m,f;return b(this,(function(g){switch(g.label){case 0:return r=new Y({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(r)];case 1:return l=g.sent(),u=l.as(ee),o=u.url,d=u.fileSize,c=void 0===d?n.fileSize:d,h=u.thumbnailSizes,p=void 0===h?n.thumbnailSizes:h,m=u.requireAuth,f=void 0!==m&&m,n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=o,n.fileSize=c,n.thumbnailSizes=p,n.requireAuth=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var s,a,i;return U(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m,f,g,y,_;return b(this,(function(v){switch(v.label){case 0:return l=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[l],o=new Y({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(o)];case 1:return d=v.sent(),c=d.as(ee),h=c.url,p=c.fileSize,m=void 0===p?u.fileSize:p,f=c.thumbnailSizes,g=void 0===f?u.thumbnailSizes:f,y=c.requireAuth,_=void 0!==y&&y,u.fileName=null!==(s=u.fileName)&&void 0!==s?s:u.file.name,u.mimeType=null!==(a=u.mimeType)&&void 0!==a?a:u.file.type,u.fileSize=null!==(i=u.fileSize)&&void 0!==i?i:u.file.size,u.file=null,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=r(r({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return void 0===s&&(s=null),U(this,void 0,void 0,(function(){var a,i,r,l,u;return b(this,(function(o){return this._queueMap.has(e.url)||(a={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,a)),i=this._queueMap.get(e.url),r=new x,l={requestId:t,params:n,state:qe.PENDING,deferred:r},function(e){return"fileInfoList"in e}(n)&&(u={uploadIndex:0,uploadCount:n.fileInfoList.length,requestHandler:s},l.multipleFileUploadInfo=u),i.messageQueue.push(l),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s;void 0===t&&(t=null);var a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:h([],p(a.messageQueue),!1);try{for(var r=m(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case qe.PENDING:u.state=qe.FAILED,u.error=E.requestCanceled,this._resolveMessageQueue(e);break;case qe.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}();var Pe,Ne={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:Q.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Ce=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&c(Q,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},Re={replyType:Q.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return c(Q,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},Le=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),ke=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),ze=function(n){function a(e){var a=e.channelType,i=e.channelUrl,r=e.timestamp,l=void 0===r?null:r,u=e.token,o=void 0===u?null:u,d=e.prevResultSize,c=e.nextResultSize,h=e.isInclusive,p=e.reverse,m=e.messageTypeFilter,f=e.customTypesFilter,g=e.senderUserIdsFilter,y=e.replyType,_=e.includeMetaArray,v=e.includeReactions,I=e.parentMessageId,T=e.includeThreadInfo,M=e.includeParentMessageInfo,S=e.showSubchannelMessagesOnly,U=e.checkingContinuousMessages,b=n.call(this)||this;return b.method=t.GET,b.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),b.params=s({is_sdk:!0,prev_limit:d,next_limit:c,include:h,reverse:p,message_ts:l,message_id:o,message_type:null!=m?m:null,custom_types:f,sender_ids:g,include_reply_type:y,with_sorted_meta_array:_,include_reactions:v,parent_message_id:I,include_thread_info:T,include_parent_message_info:M,show_subchannel_message_only:S,include_poll_details:!0,checking_continuous_messages:U}),b}return e(a,n),a}(a),xe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Se(e,t)})),s}return e(n,t),n}(i),Qe=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),Ge=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Se(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),Be=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),je=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),He={},We=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new De(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),He[e]=this}return e.of=function(e){return He[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=B(e);switch(t.messageType){case y.USER:return new ve(this._iid,ve.payloadify(t));case y.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new Ue(this._iid,Ue.payloadify(t));case y.ADMIN:return new ye(this._iid,ye.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return s({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,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=B(e);return new de(this._iid,de.payloadify(t))},e.prototype.getMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return b(this,(function(s){switch(s.label){case 0:return t=new Le(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ke).message]}}))}))},e.prototype.getScheduledMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return b(this,(function(s){switch(s.label){case 0:return t=new Be(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(je).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var i,l,u;return b(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,token:String(n)},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var i,l,u;return b(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var l,u,o,d;return b(this,(function(c){switch(c.label){case 0:return l=new ze(r(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(l)];case 1:return u=c.sent(),o=u.payload,d=u.as(xe).messages,this._dispatcher.dispatch(new H({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=j.REQUEST_THREADED_MESSAGE),U(this,void 0,void 0,(function(){var a,i,l,u;return b(this,(function(o){switch(o.label){case 0:return a=new ze(r(r(r({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},fe),n),{replyType:Q.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),l=i.as(xe).messages,(u=l.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new H({messages:u,source:s})),[2,{parentMessage:l[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=j.REQUEST_MESSAGE_CHANGELOGS),U(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m;return b(this,(function(f){switch(f.label){case 0:return l=new Qe(s(r(r({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Re),a))),[4,this._requestQueue.send(l)];case 1:return u=f.sent(),o=u.as(Ge),d=o.updatedMessages,c=o.deletedMessagesInfo,h=o.hasMore,p=o.nextToken,m=c.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new H({messages:d,source:i})),m.length>0&&this._dispatcher.dispatch(new W({messageIds:m,source:i})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:h,token:p}]}}))}))},e}(),Ke=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.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}(),Ve=function(t){function n(e,n){var s=t.call(this,e)||this;s.threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&d("object",a)&&d("number",i)&&d("string",r)&&d("string",l)&&(s.threadInfo=new te(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(u),Xe={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Je=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,f=n.call(this)||this;return f.method=t.GET,f.path="".concat(V,"/messages"),f.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},f}return e(s,n),s}(a),Ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Se(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Pe||(Pe={}));var $e=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Pe.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:Pe.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&c(Pe,this.order)&&d("boolean",this.advancedQuery)&&o("string",this.targetFields,!0)},n.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,s,a,i,l,u;return b(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Je(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),s=n.as(Ze),a=s.messages,i=s.hasNext,l=s.nextToken,u=s.totalCount,this._nextToken=l,this._hasNext=i,this._isLoading=!1,this.totalCount=u,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(X),Ye=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,f=this;return(f=t.call(this,e,n,s,a)||this).reverse=!1,f.messageTypeFilter=S.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=Q.NONE,f.includeMetaArray=!1,f.includeReactions=!1,f.includeParentMessageInfo=!1,f.includeThreadInfo=!1,f.showSubchannelMessagesOnly=!1,f._edge=Number.MAX_SAFE_INTEGER,f.reverse=null!==(i=a.reverse)&&void 0!==i&&i,f.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:S.ALL,f.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,f.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,f.replyType=null!==(o=a.replyType)&&void 0!==o?o:Q.NONE,f.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,f.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,f.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,f.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,f.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,f}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&c(S,this.messageTypeFilter)&&c(Q,this.replyType)&&o("string",this.customTypesFilter,!0)&&o("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return U(this,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,We.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,h([Number.MAX_SAFE_INTEGER],p(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 E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(J),et={channelUrl:null,scheduledMessageId:0},tt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=K,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,s){this._onFileUploaded(e,t,n,s)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(Ke),nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new We(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return U(this,void 0,void 0,(function(){var t;return b(this,(function(n){return t=r(r({},Xe),e),A(function(e){return d("string",e.channelUrl)&&d("string",e.channelType)&&c(v,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)}(t)).throw(E.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return U(this,void 0,void 0,(function(){var t;return b(this,(function(n){return t=r(r({},et),e),A(function(e){return d("string",e.channelUrl)&&d("number",e.scheduledMessageId)}(t)).throw(E.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Z);export{oe as A,he as B,Ue as F,se as I,nt as M,le as O,_e as P,ae as R,pe as S,me as T,ve as U,$e as a,Te as b,We as c,re as d,Ye as e,de as f,tt as g,Ke as h,Ne as i,Re as j,Oe as k,ne as l,Ee as m,Me as n,ee as o,Se as p,Y as q,ye as r,Ve as s,Pe as t,ue as u,Ce as v,ie as w,$ as x,te as y,Ie as z}; diff --git a/message.js b/message.js index 80c9031..8c44862 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{a3 as MentionType,a1 as MessageType,a6 as MessageTypeFilter,a8 as PushNotificationDeliveryOption,af as ReplyType,a4 as SendingStatus}from"./lib/__bundle-2cf2dbb7.js";export{r as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,d as MessageMetaArray,M as MessageModule,h as MessageRequestHandler,t as MessageSearchOrder,a as MessageSearchQuery,b as MultipleFilesMessage,g as MultipleFilesMessageRequestHandler,O as OGImage,u as OGMetaData,e as PreviousMessageListQuery,w as Reaction,R as ReactionEvent,x as ReactionEventOperation,f as Sender,y as ThreadInfo,s as ThreadInfoUpdateEvent,T as Thumbnail,z as UploadedFileInfo,U as UserMessage}from"./lib/__bundle-199cda92.js"; +export{a3 as MentionType,a1 as MessageType,a6 as MessageTypeFilter,a8 as PushNotificationDeliveryOption,af as ReplyType,a4 as SendingStatus}from"./lib/__bundle-a8f5769e.js";export{r as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,d as MessageMetaArray,M as MessageModule,h as MessageRequestHandler,t as MessageSearchOrder,a as MessageSearchQuery,b as MultipleFilesMessage,g as MultipleFilesMessageRequestHandler,O as OGImage,u as OGMetaData,e as PreviousMessageListQuery,w as Reaction,R as ReactionEvent,x as ReactionEventOperation,f as Sender,y as ThreadInfo,s as ThreadInfoUpdateEvent,T as Thumbnail,z as UploadedFileInfo,U as UserMessage}from"./lib/__bundle-f20da9a5.js"; diff --git a/openChannel.js b/openChannel.js index b98780d..6081279 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as e,b as n,c as t,$ as r,m as a,a as i,i as s,A as o,aP as u,aQ as l,f as c,h,e as d,a9 as p,U as f,W as v,w as C,x as _,J as y,t as m,aC as E,y as g,aD as U,ah as w,O as T,aF as N,s as b,S as M,g as P,aJ as O,al as H,V as x,a2 as D,n as I,B as A,am as L}from"./lib/__bundle-2cf2dbb7.js";import{q as R,r as F,t as k,w as S,u as q,x as Q,y as z,P as K,z as j,A as V,C as W,E as B,f as G}from"./lib/__bundle-e902ed46.js";import{C as X,a as J,O as Y,P as Z,M as $,T as ee,R as ne,U as te,A as re,B as ae}from"./lib/__bundle-7ad2ae44.js";import{m as ie,c as se}from"./lib/__bundle-199cda92.js";import{P as oe}from"./lib/__bundle-6d9f318a.js";import"./lib/__bundle-b3187dac.js";var ue=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return null!==e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,null!==(r=this._channels.get(e))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),le={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},ce=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(c),he=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=null,r.channel=new be(e,t),r}return e(t,n),t}(h),de=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds,f=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p,is_ephemeral:f}),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}e(t,n)}(h);var pe=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),fe=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"SYEV",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),ve=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),Ce=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),_e={},ye=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return _e[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ue(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof v)i._handleEvent(e);else if(e instanceof C&&e.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(e){n={error:e}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),_e[e]=this),_e[e]}return e.of=function(e){return _e[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=m(e);return new be(this._iid,be.payloadify(n))},e.prototype.getChannelFromCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=y(e),r=n.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=n.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=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},e.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},e.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},e.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,i,s,o,u,l,c,h,d,p,f,v,C,_,m,b,M,P,H,x,D,I,A,L,G,ae,se,oe,ue,le,ce,he,de,pe,ve,_e,ye,me,Ee,ge,Ue,we,Te,Ne,be,Me,Pe,Oe,He,xe,De,Ie,Ae,Le,Re,Fe,ke,Se,qe,Qe,ze,Ke,je,Ve,We,Be,Ge,Xe=this;return t(this,(function(Je){switch(Je.label){case 0:switch(Je.trys.push([0,57,,58]),e.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"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return s=null,"MESG"===e.code?s=e.as(B):"FILE"===e.code?s=e.as(ie):"ADMM"!==e.code&&"BRDM"!=e.code||(s=e.as(re)),s?(r=s.message,a=s.isMentioned,r.channelType!==T.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,s,o,u;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())s=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),Je.label=3;case 3:return[3,56];case 4:return s=null,"MEDI"===e.code?s=e.as(V):"FEDI"===e.code?s=e.as(W):"AEDI"===e.code&&(s=e.as(te)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==T.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(l.url)&&(r.onMessageUpdated(l,o),u>0&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=6;case 6:return[3,56];case 7:return c=e.as(j),le=c.channelUrl,ce=c.channelType,h=c.messageId,ce!==T.OPEN?[3,9]:[4,this.getChannel(le,!0)];case 8:d=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=9;case 9:return[3,56];case 10:return p=e.as(ne),le=p.channelUrl,ce=p.channelType,f=p.event,ce!==T.OPEN?[3,12]:[4,this.getChannel(le,!0)];case 11:v=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated(v,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=12;case 12:return[3,56];case 13:return(C=e.as(ee).event).channelType!==T.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated(_,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=15;case 15:return[3,56];case 16:m=e.as($).openChannelMemberCounts,b=[],Je.label=17;case 17:Je.trys.push([17,22,23,24]),M=y(m),P=M.next(),Je.label=18;case 18:return P.done?[3,21]:(H=P.value,le=H.channelUrl,ge=H.participantCount,x=H.updatedAt,[4,this.getChannelFromCache(le)]);case 19:(D=Je.sent())&&D._updateParticipantCount(ge,x)&&b.push(D),Je.label=20;case 20:return P=M.next(),[3,18];case 21:return[3,24];case 22:return I=Je.sent(),Be={error:I},[3,24];case 23:try{P&&!P.done&&(Ge=M.return)&&Ge.call(M)}finally{if(Be)throw Be.error}return[7];case 24:return b.length>0?[4,this.upsertChannelsToCache(b)]:[3,26];case 25:A=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onChannelMemberCountChanged(A)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=26;case 26:return[3,56];case 27:return L=e.as(Z),G=L.event,ae=L.status,le=L.channelUrl,ce=L.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,29];case 28:se=Je.sent(),this._dispatcher.dispatch(new N({event:G,source:w.EVENT_POLL_UPDATED})),g(ae===O?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollDeleted(se,G.pollId)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollUpdated(se,G)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Je.label=29;case 29:return[3,56];case 30:return oe=e.as(K),ue=oe.event,le=oe.channelUrl,ce=oe.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,32];case 31:he=Je.sent(),this._dispatcher.dispatch(new U({event:ue,source:w.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollVoted(he,ue)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=32;case 32:return[3,56];case 33:if(!(de=e.as(X).event).isOpenChannelEvent)return[3,55];switch(de.category){case J.CHANNEL_ENTER:return[3,34];case J.CHANNEL_EXIT:return[3,36];case J.CHANNEL_OPERATOR_UPDATE:return[3,38];case J.USER_CHANNEL_MUTE:case J.USER_CHANNEL_UNMUTE:return[3,40];case J.USER_CHANNEL_BAN:case J.USER_CHANNEL_UNBAN:return[3,42];case J.CHANNEL_FREEZE:case J.CHANNEL_UNFREEZE:return[3,44];case J.CHANNEL_DELETED:return[3,46];case J.CHANNEL_PROP_CHANGED:return[3,49];case J.CHANNEL_META_DATA_CHANGED:return[3,51];case J.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Je.sent(),ve=e.as(fe),ge=ve.participantCount,_e=ve.user,ye=pe._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered(pe,_e),ye&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Je.sent(),Ee=e.as(Ce),ge=Ee.participantCount,Ue=Ee.user,we=me._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited(me,Ue),we&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Je.sent(),Ne=e.as(Y).operators,Te.operators=Ne,this.upsertChannelsToCache([Te]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(Te,Ne)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Je.sent(),Me=de.category===J.USER_CHANNEL_MUTE,Pe=e.as(Me?Q:z).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Me?e.onUserMuted(be,Pe):e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return Oe=Je.sent(),He=de.category===J.USER_CHANNEL_BAN,xe=e.as(He?S:q).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){He?e.onUserBanned(Oe,xe):e.onUserUnbanned(Oe,xe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return De=Je.sent(),Ie=e.as(k).freeze,De.isFrozen=Ie,this.upsertChannelsToCache([De]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen(De):e.onChannelUnfrozen(De)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Je.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Le=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Le)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Re=Je.sent(),Fe=e.as(F),ke=Fe.created,Se=Fe.updated,qe=Fe.deleted,ke&&Re._upsertCachedMetaData(ke,de.ts),Se&&Re._upsertCachedMetaData(Se,de.ts),qe&&Re._removeFromCachedMetaData(qe,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ke&&e.onMetaDataCreated(Re,ke),Se&&e.onMetaDataUpdated(Re,Se),qe&&e.onMetaDataDeleted(Re,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return Qe=Je.sent(),ze=e.as(R),Ke=ze.created,je=ze.updated,Ve=ze.deleted,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated(Qe,Ke),je&&e.onMetaCounterUpdated(Qe,je),Ve&&e.onMetaCounterDeleted(Qe,Ve)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(We=Je.sent(),E(We))throw We;return[3,58];case 58:return[2]}}))}))},e.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},e.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._openChannelHandlers.clear()},e.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:b(i("string",e)).throw(M.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,s;return t(this,(function(t){switch(t.label){case 0:return b(i("string",e)).throw(M.invalidParameters),n=new ce({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),s=a.as(he).channel,[4,this.upsertChannelsToCache([s])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},le),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)&&(i("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(M.invalidParameters),r=new de(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(he).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),me={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,i=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new oe(e,n)})),r}return e(t,n),t}(h),Ue=function(r){function a(e,n,t){return r.call(this,e,n,T.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,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,e=x.of(this._iid).requestQueue,n=new Ee(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(ge),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw M.queryInProgress;case 4:return[3,6];case 5:throw M.invalidParameters;case 6:return[2]}}))}))},a}(H),we=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p}),t}return e(t,n),t}(c),Te=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}return e(t,n),t}(h),Ne=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var be=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=T.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new f(e,n)})):[],a}return e(o,r),o.payloadify=function(e){return e?d(P(P({},G.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return f.payloadify(e)}))})):null},o.prototype.serialize=function(){return D(this)},o.prototype.isOperator=function(e){return e instanceof f?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new Ue(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,ye.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new pe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(fe),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new ve({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ce),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},me),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(M.invalidParameters),r=x.of(this._iid).requestQueue,o=new we(P({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Te).channel,this._update(l),[4,ye.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=P(P({},me),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ne({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,ye.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendUserMessage.call(this,e)},o.prototype.sendFileMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendFileMessage.call(this,e)},o}(G),Me=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=I,e.onUserExited=I,e.onChannelParticipantCountChanged=I,e.onPollUpdated=I,e.onPollVoted=I,e.onPollDeleted=I,e}return e(t,n),t}(ae)),Pe=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,s=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:c,show_metadata:h}),t}return e(t,n),t}(c),Oe=function(n){function t(e,t){var r=n.call(this,e,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(n){return new be(e,n)}))),r.ts="number"==typeof s?s:null,r}return e(t,n),t}(h),He=function(r){function s(e,n){var t,a,i,s,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=n.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=n.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(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 n(this,void 0,void 0,(function(){var e,n,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,e=x.of(this._iid).requestQueue,n=new Pe(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Oe),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,ye.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw M.queryInProgress;case 5:return[3,7];case 6:throw M.invalidParameters;case 7:return[2]}}))}))},s}(A),xe=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new ye(e,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new He(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=P({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=s,[2,this._manager.createChannel(n)]}))}))},a}(L);export{be as OpenChannel,Me as OpenChannelHandler,He as OpenChannelListQuery,xe as OpenChannelModule,Ue as ParticipantListQuery}; +import{_ as e,b as n,c as t,$ as r,m as a,a as i,i as s,A as o,aP as u,aQ as l,f as c,h,e as d,a9 as p,U as f,W as v,w as C,x as _,J as y,t as m,aC as E,y as g,aD as U,ah as w,O as T,aF as N,s as b,S as M,g as P,aJ as O,al as H,V as x,a2 as D,n as I,B as A,am as L}from"./lib/__bundle-a8f5769e.js";import{q as R,r as F,t as k,w as S,u as q,x as Q,y as z,P as K,z as j,A as V,C as W,E as B,f as G}from"./lib/__bundle-ad6d760f.js";import{C as X,a as J,O as Y,P as Z,M as $,T as ee,R as ne,U as te,A as re,B as ae}from"./lib/__bundle-e21f40c4.js";import{m as ie,c as se}from"./lib/__bundle-f20da9a5.js";import{P as oe}from"./lib/__bundle-ed97dd0a.js";import"./lib/__bundle-6bc4500a.js";var ue=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return null!==e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,null!==(r=this._channels.get(e))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),le={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},ce=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(c),he=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=null,r.channel=new be(e,t),r}return e(t,n),t}(h),de=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds,f=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p,is_ephemeral:f}),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}e(t,n)}(h);var pe=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),fe=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"SYEV",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),ve=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),Ce=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),_e={},ye=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return _e[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ue(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof v)i._handleEvent(e);else if(e instanceof C&&e.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(e){n={error:e}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),_e[e]=this),_e[e]}return e.of=function(e){return _e[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=m(e);return new be(this._iid,be.payloadify(n))},e.prototype.getChannelFromCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=y(e),r=n.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=n.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=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},e.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},e.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},e.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,i,s,o,u,l,c,h,d,p,f,v,C,_,m,b,M,P,H,x,D,I,A,L,G,ae,se,oe,ue,le,ce,he,de,pe,ve,_e,ye,me,Ee,ge,Ue,we,Te,Ne,be,Me,Pe,Oe,He,xe,De,Ie,Ae,Le,Re,Fe,ke,Se,qe,Qe,ze,Ke,je,Ve,We,Be,Ge,Xe=this;return t(this,(function(Je){switch(Je.label){case 0:switch(Je.trys.push([0,57,,58]),e.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"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return s=null,"MESG"===e.code?s=e.as(B):"FILE"===e.code?s=e.as(ie):"ADMM"!==e.code&&"BRDM"!=e.code||(s=e.as(re)),s?(r=s.message,a=s.isMentioned,r.channelType!==T.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,s,o,u;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())s=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),Je.label=3;case 3:return[3,56];case 4:return s=null,"MEDI"===e.code?s=e.as(V):"FEDI"===e.code?s=e.as(W):"AEDI"===e.code&&(s=e.as(te)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==T.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(l.url)&&(r.onMessageUpdated(l,o),u>0&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=6;case 6:return[3,56];case 7:return c=e.as(j),le=c.channelUrl,ce=c.channelType,h=c.messageId,ce!==T.OPEN?[3,9]:[4,this.getChannel(le,!0)];case 8:d=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=9;case 9:return[3,56];case 10:return p=e.as(ne),le=p.channelUrl,ce=p.channelType,f=p.event,ce!==T.OPEN?[3,12]:[4,this.getChannel(le,!0)];case 11:v=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated(v,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=12;case 12:return[3,56];case 13:return(C=e.as(ee).event).channelType!==T.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated(_,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=15;case 15:return[3,56];case 16:m=e.as($).openChannelMemberCounts,b=[],Je.label=17;case 17:Je.trys.push([17,22,23,24]),M=y(m),P=M.next(),Je.label=18;case 18:return P.done?[3,21]:(H=P.value,le=H.channelUrl,ge=H.participantCount,x=H.updatedAt,[4,this.getChannelFromCache(le)]);case 19:(D=Je.sent())&&D._updateParticipantCount(ge,x)&&b.push(D),Je.label=20;case 20:return P=M.next(),[3,18];case 21:return[3,24];case 22:return I=Je.sent(),Be={error:I},[3,24];case 23:try{P&&!P.done&&(Ge=M.return)&&Ge.call(M)}finally{if(Be)throw Be.error}return[7];case 24:return b.length>0?[4,this.upsertChannelsToCache(b)]:[3,26];case 25:A=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onChannelMemberCountChanged(A)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=26;case 26:return[3,56];case 27:return L=e.as(Z),G=L.event,ae=L.status,le=L.channelUrl,ce=L.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,29];case 28:se=Je.sent(),this._dispatcher.dispatch(new N({event:G,source:w.EVENT_POLL_UPDATED})),g(ae===O?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollDeleted(se,G.pollId)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollUpdated(se,G)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Je.label=29;case 29:return[3,56];case 30:return oe=e.as(K),ue=oe.event,le=oe.channelUrl,ce=oe.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,32];case 31:he=Je.sent(),this._dispatcher.dispatch(new U({event:ue,source:w.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollVoted(he,ue)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=32;case 32:return[3,56];case 33:if(!(de=e.as(X).event).isOpenChannelEvent)return[3,55];switch(de.category){case J.CHANNEL_ENTER:return[3,34];case J.CHANNEL_EXIT:return[3,36];case J.CHANNEL_OPERATOR_UPDATE:return[3,38];case J.USER_CHANNEL_MUTE:case J.USER_CHANNEL_UNMUTE:return[3,40];case J.USER_CHANNEL_BAN:case J.USER_CHANNEL_UNBAN:return[3,42];case J.CHANNEL_FREEZE:case J.CHANNEL_UNFREEZE:return[3,44];case J.CHANNEL_DELETED:return[3,46];case J.CHANNEL_PROP_CHANGED:return[3,49];case J.CHANNEL_META_DATA_CHANGED:return[3,51];case J.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Je.sent(),ve=e.as(fe),ge=ve.participantCount,_e=ve.user,ye=pe._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered(pe,_e),ye&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Je.sent(),Ee=e.as(Ce),ge=Ee.participantCount,Ue=Ee.user,we=me._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited(me,Ue),we&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Je.sent(),Ne=e.as(Y).operators,Te.operators=Ne,this.upsertChannelsToCache([Te]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(Te,Ne)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Je.sent(),Me=de.category===J.USER_CHANNEL_MUTE,Pe=e.as(Me?Q:z).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Me?e.onUserMuted(be,Pe):e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return Oe=Je.sent(),He=de.category===J.USER_CHANNEL_BAN,xe=e.as(He?S:q).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){He?e.onUserBanned(Oe,xe):e.onUserUnbanned(Oe,xe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return De=Je.sent(),Ie=e.as(k).freeze,De.isFrozen=Ie,this.upsertChannelsToCache([De]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen(De):e.onChannelUnfrozen(De)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Je.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Le=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Le)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Re=Je.sent(),Fe=e.as(F),ke=Fe.created,Se=Fe.updated,qe=Fe.deleted,ke&&Re._upsertCachedMetaData(ke,de.ts),Se&&Re._upsertCachedMetaData(Se,de.ts),qe&&Re._removeFromCachedMetaData(qe,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ke&&e.onMetaDataCreated(Re,ke),Se&&e.onMetaDataUpdated(Re,Se),qe&&e.onMetaDataDeleted(Re,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return Qe=Je.sent(),ze=e.as(R),Ke=ze.created,je=ze.updated,Ve=ze.deleted,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated(Qe,Ke),je&&e.onMetaCounterUpdated(Qe,je),Ve&&e.onMetaCounterDeleted(Qe,Ve)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(We=Je.sent(),E(We))throw We;return[3,58];case 58:return[2]}}))}))},e.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},e.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._openChannelHandlers.clear()},e.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:b(i("string",e)).throw(M.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,s;return t(this,(function(t){switch(t.label){case 0:return b(i("string",e)).throw(M.invalidParameters),n=new ce({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),s=a.as(he).channel,[4,this.upsertChannelsToCache([s])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},le),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)&&(i("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(M.invalidParameters),r=new de(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(he).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),me={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,i=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new oe(e,n)})),r}return e(t,n),t}(h),Ue=function(r){function a(e,n,t){return r.call(this,e,n,T.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,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,e=x.of(this._iid).requestQueue,n=new Ee(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(ge),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw M.queryInProgress;case 4:return[3,6];case 5:throw M.invalidParameters;case 6:return[2]}}))}))},a}(H),we=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p}),t}return e(t,n),t}(c),Te=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}return e(t,n),t}(h),Ne=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var be=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=T.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new f(e,n)})):[],a}return e(o,r),o.payloadify=function(e){return e?d(P(P({},G.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return f.payloadify(e)}))})):null},o.prototype.serialize=function(){return D(this)},o.prototype.isOperator=function(e){return e instanceof f?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new Ue(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,ye.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new pe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(fe),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new ve({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ce),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},me),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(M.invalidParameters),r=x.of(this._iid).requestQueue,o=new we(P({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Te).channel,this._update(l),[4,ye.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=P(P({},me),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ne({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,ye.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendUserMessage.call(this,e)},o.prototype.sendFileMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendFileMessage.call(this,e)},o}(G),Me=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=I,e.onUserExited=I,e.onChannelParticipantCountChanged=I,e.onPollUpdated=I,e.onPollVoted=I,e.onPollDeleted=I,e}return e(t,n),t}(ae)),Pe=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,s=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:c,show_metadata:h}),t}return e(t,n),t}(c),Oe=function(n){function t(e,t){var r=n.call(this,e,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(n){return new be(e,n)}))),r.ts="number"==typeof s?s:null,r}return e(t,n),t}(h),He=function(r){function s(e,n){var t,a,i,s,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=n.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=n.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(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 n(this,void 0,void 0,(function(){var e,n,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,e=x.of(this._iid).requestQueue,n=new Pe(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Oe),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,ye.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw M.queryInProgress;case 5:return[3,7];case 6:throw M.invalidParameters;case 7:return[2]}}))}))},s}(A),xe=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new ye(e,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new He(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=P({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=s,[2,this._manager.createChannel(n)]}))}))},a}(L);export{be as OpenChannel,Me as OpenChannelHandler,He as OpenChannelListQuery,xe as OpenChannelModule,Ue as ParticipantListQuery}; diff --git a/package.json b/package.json index 4a8aecc..c2e88e3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.9.0", + "version": "4.9.1", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index 8c40e32..0010779 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{_ as t,b as e,am as r,c as n,g as o,s,S as l}from"./lib/__bundle-2cf2dbb7.js";export{a7 as Poll,an as PollOption,ao as PollStatus}from"./lib/__bundle-2cf2dbb7.js";import{b as u,c,v as d,d as p,e as f,f as g,g as b}from"./lib/__bundle-b3187dac.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-b3187dac.js";var m=function(r){function a(){var t=null!==r&&r.apply(this,arguments)||this;return t.name="poll",t}return t(a,r),a.prototype.init=function(t,e){var a=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,l=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c}),this._manager=new u(t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c})},a.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(d(e)).throw(l.invalidParameters),[2,this._manager.create(e)]}))}))},a.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},p),t),s(f(e)).throw(l.invalidParameters),[2,this._manager.get(e)]}))}))},a.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},g),t),s(b(e)).throw(l.invalidParameters),[2,this._manager.getOption(e)]}))}))},a.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},a}(r);export{m as PollModule}; +import{_ as t,b as e,am as r,c as n,g as o,s,S as l}from"./lib/__bundle-a8f5769e.js";export{a7 as Poll,an as PollOption,ao as PollStatus}from"./lib/__bundle-a8f5769e.js";import{b as u,c,v as p,d,e as f,f as g,g as m}from"./lib/__bundle-6bc4500a.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-6bc4500a.js";var v=function(a){function r(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(r,a),r.prototype.init=function(t,e){var r=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,l=e.onlineDetector,c=e.cacheContext;a.prototype.init.call(this,t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c}),this._manager=new u(t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c})},r.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},c),t),s(p(e)).throw(l.invalidParameters),[2,this._manager.create(e)]}))}))},r.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},d),t),s(f(e)).throw(l.invalidParameters),[2,this._manager.get(e)]}))}))},r.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},g),t),s(m(e)).throw(l.invalidParameters),[2,this._manager.getOption(e)]}))}))},r.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},r}(r);export{v as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index be8feac..88ea83c 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;C(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.9.0",x=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var C,T,S,I,N,M=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===E.SESSION_REVOKED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:E.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},q=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null===e)return!0;var t=L("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(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator,u=void 0===o?null:o;r(this,e),this._customClearOrderComparator=null,this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),u?(this._clearOrder=i,this._customClearOrderComparator=u):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),ne=function(){function e(){r(this,e),this.sessionKey=null,this.authToken=null}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),re=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)}))},ae=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=re()}return s(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),se=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new ae({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new ae({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),ie=function(){function e(){r(this,e),this._dispatcher=new se}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),oe=s((function e(){r(this,e)})),ue=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};e.ChannelType=void 0,(B=e.ChannelType||(e.ChannelType={})).BASE="base",B.GROUP="group",B.OPEN="open",e.Role=void 0,(Q=e.Role||(e.Role={})).OPERATOR="operator",Q.NONE="none",e.MessageType=void 0,(K=e.MessageType||(e.MessageType={})).BASE="base",K.USER="user",K.FILE="file",K.ADMIN="admin",e.MessageTypeFilter=void 0,(W=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",W.USER="MESG",W.FILE="FILE",W.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(Y||(Y={})),e.MentionType=void 0,(Z=e.MentionType||(e.MentionType={})).USERS="users",Z.CHANNEL="channel",e.ReplyType=void 0,(J=e.ReplyType||(e.ReplyType={})).ALL="all",J.NONE="none",J.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(X=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",X.SUPPRESS="suppress",e.SendingStatus=void 0,($=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",$.SCHEDULED="scheduled",$.SUCCEEDED="succeeded",$.FAILED="failed",$.CANCELED="canceled";var ce,le="v3",he="/".concat(le,"/users"),de="/".concat(le,"/storage/file"),fe="/".concat(le,"/group_channels"),pe="/".concat(le,"/sdk/group_channels"),ve="/".concat(le,"/open_channels"),_e="/".concat(le,"/sdk/open_channels"),me="/".concat(le,"/search"),ge="/".concat(le,"/report"),ye="/".concat(le,"/emojis"),ke="/".concat(le,"/emoji_categories"),be="/".concat(le,"/polls"),Ee="/".concat(le,"/scheduled_messages"),we="/".concat(le,"/sdk/ui_kit/configuration"),xe="/".concat(le,"/sdk/statistics"),Ce=function(t){switch(t){case e.ChannelType.GROUP:return fe;case e.ChannelType.OPEN:return ve;default:return null}},Te=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ge,"/group_channels");case e.ChannelType.OPEN:return"".concat(ge,"/open_channels");default:return null}},Se=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ie=function(e,t,n){var r=Se(e.mentionType,e.mentionedUserIds,n),a=Se(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},Ne=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(o in t){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;q(u)?i.append(c,u,null!==(s=u.name)&&void 0!==s?s:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?i.append(c,String(u)):i=e(u,i,c)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(ce||(ce={}));var Me,Ae=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=re(),e}return s(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ue(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ue(this.params);return Object.keys(e).some((function(t){return q(e[t])}))?Ne(e):JSON.stringify(e)}}]),a}(oe),Oe=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(oe),Ue=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}(oe),Re=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.expires_in,i=e.reason,o=void 0===i?E.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case E.SESSION_KEY_EXPIRED:case E.SESSION_TOKEN_EXPIRED:case E.SESSION_REVOKED:a.error=new A({code:o})}return a}return s(n,[{key:"invalidateSessionToken",get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError}}]),n}(oe),Le=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}(oe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Me||(Me={}));var De=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ue({stat_type:e.type,ts:e.createdAt,data:ue(e.data)})}}]),e}(),Pe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Fe=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Ue&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Pe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(x.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(x.OS_VERSION,",").concat(x.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Le(new De({type:Me.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![ce.GET,ce.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:null),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Rv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return t_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),t.abrupt("return",new Oe(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:v.code})),this._statLogApiResult(e,d,v),v;case 37:throw _=A.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof A)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw A.requestCanceled;case 54:throw m=A.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),Ge=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=s?s.req_id:o,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),qe=function(){};function He(e){let t=e.length;for(;--t>=0;)e[t]=0}const je=256,ze=286,Ve=30,Be=15,Qe=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ke=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),We=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ze=new Array(576);He(Ze);const Je=new Array(60);He(Je);const Xe=new Array(512);He(Xe);const $e=new Array(256);He($e);const et=new Array(29);He(et);const tt=new Array(Ve);function nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let rt,at,st;function it(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}He(tt);const ot=e=>e<256?Xe[e]:Xe[256+(e>>>7)],ut=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{ct(e,n[2*t],n[2*t+1])},ht=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},dt=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Be;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ht(r[t]++,t))}},ft=e=>{let t;for(t=0;t{e.bi_valid>8?ut(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},vt=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?lt(e,a,t):(s=$e[a],lt(e,s+je+1,t),i=Qe[s],0!==i&&(a-=et[s],ct(e,a,i)),r--,s=ot(r),lt(e,s,n),i=Ke[s],0!==i&&(r-=tt[s],ct(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)_t(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],_t(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,_t(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=Be;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),dt(n,c,e.bl_count)},yt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{ct(e,0+(r?1:0),3),pt(e),ut(e,n),ut(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var wt=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(yt(e,e.dyn_ltree,e.l_desc.max_code),yt(e,e.dyn_dtree,e.d_desc.max_code),gt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Et(e,t,n,r):4===e.strategy||s===a?(ct(e,2+(r?1:0),3),mt(e,Ze,Je)):(ct(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(ct(e,t-257,5),ct(e,n-1,5),ct(e,r-4,4),a=0;a{bt||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(et[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*($e[n]+je+1)]++,e.dyn_dtree[2*ot(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),lt(e,256,Ze),(e=>{16===e.bi_valid?(ut(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ct=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Tt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var St=(e,t,n,r)=>{const a=Tt,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},It={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Nt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mt,_tr_stored_block:At,_tr_flush_block:Ot,_tr_tally:Ut,_tr_align:Rt}=xt,{Z_NO_FLUSH:Lt,Z_PARTIAL_FLUSH:Dt,Z_FULL_FLUSH:Pt,Z_FINISH:Ft,Z_BLOCK:Gt,Z_OK:qt,Z_STREAM_END:Ht,Z_STREAM_ERROR:jt,Z_DATA_ERROR:zt,Z_BUF_ERROR:Vt,Z_DEFAULT_COMPRESSION:Bt,Z_FILTERED:Qt,Z_HUFFMAN_ONLY:Kt,Z_RLE:Wt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Zt,Z_UNKNOWN:Jt,Z_DEFLATED:Xt}=Nt,$t=258,en=262,tn=42,nn=113,rn=666,an=(e,t)=>(e.msg=It[t],t),sn=e=>2*e-(e>4?9:0),on=e=>{let t=e.length;for(;--t>=0;)e[t]=0},un=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let cn=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},hn=(e,t)=>{Ot(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ln(e.strm)},dn=(e,t)=>{e.pending_buf[e.pending++]=t},fn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},pn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ct(e.adler,t,a,n):2===e.state.wrap&&(e.adler=St(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},vn=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-en?e.strstart-(e.w_size-en):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+$t;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},_n=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-en)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),un(e),r+=t),0===e.strm.avail_in)break;if(n=pn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=cn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=cn(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(pn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(pn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===Ft)&&t!==Lt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Ft&&0===e.strm.avail_in&&n===r?1:0,At(e,e.block_start,n,i),e.block_start+=n,ln(e.strm)),i?3:1)},gn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-en&&(e.match_length=vn(e,n)),e.match_length>=3)if(r=Ut(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=cn(e,e.ins_h,e.window[e.strstart+1]);else r=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=Ut(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(hn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Ut(e,0,e.window[e.strstart-1]),r&&hn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Ut(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2};function kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const bn=[new kn(0,0,0,0,mn),new kn(4,4,8,4,gn),new kn(4,5,16,8,gn),new kn(4,6,32,32,gn),new kn(4,4,16,16,yn),new kn(8,16,32,32,yn),new kn(8,16,128,128,yn),new kn(8,32,128,256,yn),new kn(32,128,258,1024,yn),new kn(32,258,258,4096,yn)];function En(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Xt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),on(this.dyn_ltree),on(this.dyn_dtree),on(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),on(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),on(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==tn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==nn&&t.status!==rn?1:0},xn=e=>{if(wn(e))return an(e,jt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?tn:nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mt(t),qt},Cn=e=>{const t=xn(e);var n;return t===qt&&((n=e.state).window_size=2*n.w_size,on(n.head),n.max_lazy_match=bn[n.level].max_lazy,n.good_match=bn[n.level].good_length,n.nice_match=bn[n.level].nice_length,n.max_chain_length=bn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Tn=(e,t,n,r,a,s)=>{if(!e)return jt;let i=1;if(t===Bt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==Xt||r<8||r>15||t<0||t>9||s<0||s>Yt||8===r&&1!==i)return an(e,jt);8===r&&(r=9);const o=new En;return e.state=o,o.strm=e,o.status=tn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Tn(e,t,Xt,15,8,Zt),deflateInit2:Tn,deflateReset:Cn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>wn(e)||2!==e.state.wrap?jt:(e.state.gzhead=t,qt),deflate:(e,t)=>{if(wn(e)||t>Gt||t<0)return e?an(e,jt):jt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===rn&&t!==Ft)return an(e,0===e.avail_out?Vt:jt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(ln(e),0===e.avail_out)return n.last_flush=-1,qt}else if(0===e.avail_in&&sn(t)<=sn(r)&&t!==Ft)return an(e,Vt);if(n.status===rn&&0!==e.avail_in)return an(e,Vt);if(n.status===tn&&0===n.wrap&&(n.status=nn),n.status===tn){let t=Xt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Kt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,fn(n,t),0!==n.strstart&&(fn(n,e.adler>>>16),fn(n,65535&e.adler)),e.adler=1,n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(57===n.status)if(e.adler=0,dn(n,31),dn(n,139),dn(n,8),n.gzhead)dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),dn(n,255&n.gzhead.time),dn(n,n.gzhead.time>>8&255),dn(n,n.gzhead.time>>16&255),dn(n,n.gzhead.time>>24&255),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(dn(n,255&n.gzhead.extra.length),dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=St(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,3),n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,ln(e),0!==n.pending)return n.last_flush=-1,qt;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(ln(e),0!==n.pending))return n.last_flush=-1,qt;dn(n,255&e.adler),dn(n,e.adler>>8&255),e.adler=0}if(n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(0!==e.avail_in||0!==n.lookahead||t!==Lt&&n.status!==rn){let r=0===n.level?mn(n,t):n.strategy===Kt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(_n(e),0===e.lookahead)){if(t===Lt)return 1;break}if(e.match_length=0,n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Wt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=$t){if(_n(e),e.lookahead<=$t&&t===Lt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+$t;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Ut(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):bn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=rn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),qt;if(2===r&&(t===Dt?Rt(n):t!==Gt&&(At(n,0,0,!1),t===Pt&&(on(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ln(e),0===e.avail_out))return n.last_flush=-1,qt}return t!==Ft?qt:n.wrap<=0?Ht:(2===n.wrap?(dn(n,255&e.adler),dn(n,e.adler>>8&255),dn(n,e.adler>>16&255),dn(n,e.adler>>24&255),dn(n,255&e.total_in),dn(n,e.total_in>>8&255),dn(n,e.total_in>>16&255),dn(n,e.total_in>>24&255)):(fn(n,e.adler>>>16),fn(n,65535&e.adler)),ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?qt:Ht)},deflateEnd:e=>{if(wn(e))return jt;const t=e.state.status;return e.state=null,t===nn?an(e,zt):qt},deflateSetDictionary:(e,t)=>{let n=t.length;if(wn(e))return jt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==tn||r.lookahead)return jt;if(1===a&&(e.adler=Ct(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(on(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,_n(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=cn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_n(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,qt},deflateInfo:"pako deflate (from Nodeca project)"};const In=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Nn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)In(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;An[254]=An[254]=1;var On={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Mn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+An[e[n]]>t?n:t}};var Un=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Rn=Object.prototype.toString,{Z_NO_FLUSH:Ln,Z_SYNC_FLUSH:Dn,Z_FULL_FLUSH:Pn,Z_FINISH:Fn,Z_OK:Gn,Z_STREAM_END:qn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:zn}=Nt;function Vn(e){this.options=Nn.assign({level:Hn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Sn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Gn)throw new Error(It[n]);if(t.header&&Sn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?On.string2buf(t.dictionary):"[object ArrayBuffer]"===Rn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Sn.deflateSetDictionary(this.strm,e),n!==Gn)throw new Error(It[n]);this._dict_set=!0}}function Bn(e,t){const n=new Vn(t);if(n.push(e,!0),n.err)throw n.msg||It[n.err];return n.result}Vn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Fn:Ln,"string"==typeof e?n.input=On.string2buf(e):"[object ArrayBuffer]"===Rn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===Dn||s===Pn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Sn.deflate(n,s),a===qn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Sn.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Gn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Vn.prototype.onData=function(e){this.chunks.push(e)},Vn.prototype.onEnd=function(e){e===Gn&&(this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qn={Deflate:Vn,deflate:Bn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bn(e,t)},constants:Nt};const Kn=16209;var Wn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C;const T=e.state;n=e.next_in,x=e.input,r=n+(e.avail_in-5),a=e.next_out,C=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)C[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=x[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=Kn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=Kn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)C[a++]=w[E++],C[a++]=w[E++],C[a++]=w[E++],k-=3;k&&(C[a++]=w[E++],k>1&&(C[a++]=w[E++]))}else{E=a-b;do{C[a++]=C[E++],C[a++]=C[E++],C[a++]=C[E++],k-=3}while(k>2);k&&(C[a++]=C[E++],k>1&&(C[a++]=C[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,x=0,C=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Yn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=A[i[_]-p],M=C[i[_]-p]):(N=96,M=0),c=1<>b)+l]=I<<24|N<<16|M|0}while(0!==l);for(c=1<>=1;if(0!==c?(x&=c-1,x+=c):x=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(x&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=x&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==x&&(a[f+x]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:tr,Z_BLOCK:nr,Z_TREES:rr,Z_OK:ar,Z_STREAM_END:sr,Z_NEED_DICT:ir,Z_STREAM_ERROR:or,Z_DATA_ERROR:ur,Z_MEM_ERROR:cr,Z_BUF_ERROR:lr,Z_DEFLATED:hr}=Nt,dr=16180,fr=16190,pr=16191,vr=16192,_r=16194,mr=16199,gr=16200,yr=16206,kr=16209,br=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Er(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const wr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(wr(e))return or;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=dr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,ar},Cr=e=>{if(wr(e))return or;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Tr=(e,t)=>{let n;if(wr(e))return or;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?or:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Cr(e))},Sr=(e,t)=>{if(!e)return or;const n=new Er;e.state=n,n.strm=e,n.window=null,n.mode=dr;const r=Tr(e,t);return r!==ar&&(e.state=null),r};let Ir,Nr,Mr=!0;const Ar=e=>{if(Mr){Ir=new Int32Array(512),Nr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(er(1,e.lens,0,288,Ir,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;er(2,e.lens,0,32,Nr,0,e.work,{bits:5}),Mr=!1}e.lencode=Ir,e.lenbits=9,e.distcode=Nr,e.distbits=5},Or=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveSr(e,15),inflateInit2:Sr,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x=0;const C=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(wr(e)||!e.output||!e.input&&0!==e.avail_in)return or;n=e.state,n.mode===pr&&(n.mode=vr),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=ar;e:for(;;)switch(n.mode){case dr:if(0===n.wrap){n.mode=vr;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=kr;break}if((15&c)!==hr){e.msg="unknown compression method",n.mode=kr;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,C[2]=c>>>16&255,C[3]=c>>>24&255,n.check=St(n.check,C,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=pr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Ar(n),n.mode=mr,t===rr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=kr;break}if(n.length=65535&c,c=0,l=0,n.mode=_r,t===rr)break e;case _r:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=pr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=er(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=kr;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=kr;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=kr;break}if(n.lenbits=9,T={bits:n.lenbits},w=er(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=kr;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=er(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=kr;break}if(n.mode=mr,t===rr)break e;case mr:n.mode=gr;case gr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Wn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===pr&&(n.back=-1);break}for(n.back=0;x=n.lencode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=pr;break}if(64&m){e.msg="invalid literal/length code",n.mode=kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;x=n.distcode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=gr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=gr;break;case yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(wr(e))return or;let t=e.state;return t.window&&(t.window=null),e.state=null,ar},inflateGetHeader:(e,t)=>{if(wr(e))return or;const n=e.state;return 0==(2&n.wrap)?or:(n.head=t,t.done=!1,ar)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return wr(e)?or:(r=e.state,0!==r.wrap&&r.mode!==fr?or:r.mode===fr&&(a=1,a=Ct(a,t,n,0),a!==r.check)?ur:(s=Or(e,t,n,n),s?(r.mode=16210,cr):(r.havedict=1,ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var Rr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Lr=Object.prototype.toString,{Z_NO_FLUSH:Dr,Z_FINISH:Pr,Z_OK:Fr,Z_STREAM_END:Gr,Z_NEED_DICT:qr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:jr,Z_MEM_ERROR:zr}=Nt;function Vr(e){this.options=Nn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Ur.inflateInit2(this.strm,t.windowBits);if(n!==Fr)throw new Error(It[n]);if(this.header=new Rr,Ur.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=On.string2buf(t.dictionary):"[object ArrayBuffer]"===Lr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ur.inflateSetDictionary(this.strm,t.dictionary),n!==Fr)))throw new Error(It[n])}function Br(e,t){const n=new Vr(t);if(n.push(e),n.err)throw n.msg||It[n.err];return n.result}Vr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Pr:Dr,"[object ArrayBuffer]"===Lr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=Ur.inflate(n,i),s===qr&&a&&(s=Ur.inflateSetDictionary(n,a),s===Fr?s=Ur.inflate(n,i):s===jr&&(s=qr));n.avail_in>0&&s===Gr&&n.state.wrap>0&&0!==e[n.next_in];)Ur.inflateReset(n),s=Ur.inflate(n,i);switch(s){case Hr:case jr:case qr:case zr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===Gr))if("string"===this.options.to){let e=On.utf8border(n.output,n.next_out),t=n.next_out-e,a=On.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Fr||0!==o){if(s===Gr)return s=Ur.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Vr.prototype.onData=function(e){this.chunks.push(e)},Vr.prototype.onEnd=function(e){e===Fr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qr={Inflate:Vr,inflate:Br,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Br(e,t)},ungzip:Br,constants:Nt};const{Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr}=Qn,{Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea}=Qr;var ta,na={Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr,Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea,constants:Nt},ra=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=na.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",ta.OPEN="OPEN",ta.CLOSED="CLOSED";var aa,sa=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ge.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Re(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ra(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",A.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=qe,t._ws.onmessage=qe,t._ws.onerror=qe,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw A.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(se),ia=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:re(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(oe),oa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}(oe),ua=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),ca=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new Fe(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new sa(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new oa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new ua,e.ackRequired){a=null,s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(null,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve(null)}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ae)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof ia)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(aa||(aa={}));var la,ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}(oe),da=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ca(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof ha){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case aa.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case aa.INITIALIZED:case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:case aa.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(A.connectionClosed):r.reject(A.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===aa.CONNECTING||this._currentConnectionStateType===aa.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ia)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new ua,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof Ae)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new ua,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=A.connectionRequired,this._logger.debug("fail api request",s),s;case 37:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(A.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),fa="sendbird@devicetokens",pa=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),va=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(he,"/").concat(s,"/session_key"),a.method=ce.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Ae),_a=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?null:o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(ia),ma=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(Oe),ga=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=s.new_key,i.error=s.error?new A(s.error):null,i}return s(n)}(Ge),ya=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),ka=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},ba=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Ea=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ba;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e){return new _a({authToken:e,expiringSession:!0,requestId:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ga),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new va({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,Ea((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(ma),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==aa.CONNECTED){t.next=25;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=25;break}if(!n){t.next=25;break}return t.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=21;break}return t.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),t.next=24;break;case 21:return t.next=23,this.clear();case 23:this.close();case 24:return t.abrupt("return");case 25:return t.prev=25,t.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),t.next=53;break;case 31:if(t.prev=31,t.t1=t.catch(25),!this._isSessionRelatedError(t.t1)){t.next=52;break}if(!n){t.next=49;break}return t.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=44;break}return t.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),t.next=47;break;case 44:return t.next=46,this.clear();case 46:this.close();case 47:t.next=50;break;case 49:throw t.t1;case 50:t.next=53;break;case 52:throw t.t1;case 53:case"end":return t.stop()}}),r,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ua;return wa((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)})):n.resolve(null);case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Ca.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(fa);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(fa,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Ca.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Sa=function(){function e(){r(this,e),this.type=aa.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),Ia=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new Ra,r);case 6:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Sa),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ma=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=aa.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Aa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Aa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,Ea((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new Oa,r);case 10:wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),M(n.t0)){n.next=23;break}if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ma({autoReconnect:!1}),r);case 20:wa((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new ua,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ua({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ma({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Na,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Aa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ma({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ua=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=aa.CONNECTING,t.name="connecting",t._authToken="",t._haltConnect=null,t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ea((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new Oa,r);case 8:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),M(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ra,r);case 20:wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ma({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Na,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Ra=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ua({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Sa),La=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(ia),Da=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new La;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Pa=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return s(e,null,[{key:"payloadify",value:function(e){return ue({last_updated_at:e.lastUpdatedAt})}}]),e}(),Fa=1048576,Ga=function(){function e(){var t,n,a,s,i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Fa:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(s=o.allow_sdk_log_ingestion)||void 0===s||s,this.uikitConfigInfo=new Pa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Fa,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Pa.payloadify(e.uikitConfigInfo):void 0}}}]),e}(),qa=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),Ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Ae),ja=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(Oe),za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Ae),Va=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(Oe),Ba=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Ae),Qa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata"),a}return s(n)}(Ae),Ka=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Wa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Ya=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(la=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",la.OFFLINE="offline",la.NON_AVAILABLE="nonavailable";var Za,Ja=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Ka(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ha({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ja),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new za({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Va),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ba({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Qa({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),u}(qa),Xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}(oe),$a=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ga(n),this.user=new Ja(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ds.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Xa({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},Ja.payloadify(e.user)),Ga.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),es=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new $a(e,s),i.deviceTokenLastDeletedAt=s.device_token_last_deleted_at,i.key=s.key,i.ekey=null!==(o=s.ekey)&&void 0!==o?o:"",i.error=s.error?new A(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=ds.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw A.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),a}(Ge),ts=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}(oe),ns=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.connectionHandlers,c=t.sessionManager,l=t.websocketClient,h=t.dispatcher,d=t.logger,f=t.entryState,p=void 0===f?new Ra:f;return r(this,a),(s=n.call(this))._currentState=null,s._loginTimer=null,s._logiProcessingTimer=null,s._unresolvedLogi=null,s._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=i,s.cacheContext=o,s.connectionHandlers=u,s._sessionManager=c,s._websocketClient=l,s._dispatcher=h,s._logger=d,s._currentState=p,s.sdkState.websocket.pingerDisabled||(s._pinger=new Da({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:d})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(es))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=null,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof es&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=null,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=this.sdkState,r=n.appId,a=n.appVersion,s=n.userId,i=n.extensions,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!this.sdkState.extensions.sb_uikit,h=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",d=i.sb_uikit?"u".concat(i.sb_uikit):"",f="JS/c".concat(x.SDK_VERSION,"/").concat(h,"/").concat(d);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(x.OS_VERSION),"&sv=").concat(encodeURIComponent(x.SDK_VERSION),"&ai=").concat(r).concat(a?"&av=".concat(a):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(t)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new ts({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new Le(new De({type:Me.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(A.connectionCanceled)),r=this._url(e),a=new ua,this._connectionRequestQueue.push(a),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=null,s._rejectConnectionRequest(A.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(r)),t.abrupt("return",a.promise);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(es.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),a}(se),rs=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new ns(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===aa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===aa.CONNECTING||e.type===aa.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),as=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(De),ss=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return De.payloadify(e)}))},a}return s(n)}(Ae),is=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Za||(Za={}));var os,us=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Za.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t.commandEventContext=null,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=re(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Za.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.API_RESULT||e.type===Me.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Za.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return De.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof as){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new ss({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof A)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Za.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Za.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new De({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,ka(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Le){var t=e.statLog;s.put(t)}else if(e instanceof ts){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Za.ENABLED:Za.COLLECT_ONLY:s.enabledState=Za.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Za.DISABLED){t.next=7;break}return e instanceof as?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof as&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=is(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)}}]),a}(se);e.LogLevel=void 0,(os=e.LogLevel||(e.LogLevel={}))[os.NONE=0]="NONE",os[os.VERBOSE=1]="VERBOSE",os[os.DEBUG=2]="DEBUG",os[os.INFO=3]="INFO",os[os.WARN=4]="WARN",os[os.ERROR=5]="ERROR";var cs,ls=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?ue({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),bs=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return e?ue({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),Es=function(){function e(t){r(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return e?ue({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}(),ws=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new Es(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Es.payloadify(e.defaultImage):null}):null}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),this.name=null,this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?ue({name:e.name,volume:e.volume}):null}}]),e}(),Cs=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).role=null,i.isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),a}(Ja);e.ScheduledStatus=void 0,(ms=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",ms.SENT="sent",ms.FAILED="failed",ms.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(gs||(gs={}));var Ts,Ss=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Is=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,a),(i=n.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null;var E=s.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new Ja(i._iid,e)})):null;var w=s.mentioned_user_ids;i.mentionedUserIds=null!=w?w:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=s.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=s.thread_info?new _s(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new ks(e)})):[];for(var x=null!==(f=s.metaarray)&&void 0!==f?f:{},C=null!==(p=s.metaarray_key_order)&&void 0!==p?p:Object.keys(x).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Ss(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return Ja.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?_s.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ks.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return bs.payloadify(e)})),og_tag:ws.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:xs.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}},{key:"_getParentMessageInfoPayload",value:function(e){return e?ue({type:e.messageType,ts:e.createdAt,user:Cs.payloadify(e.sender),message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}):null}}]),a}(qa),Ns=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=s.user?new Cs(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=s.scheduled_status,s.scheduled_status){case gs.SENT:case gs.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case gs.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case gs.FAILED:case gs.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case gs.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Cs.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),a}(Is),Ms=function(){function e(t){var n,a;r(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?ue({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),As={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Os=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Us=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).message=null,s.translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info,d=ue(Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}));s.parentMessage=Vs(t,d)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Is),Rs=function(){function e(t){var n,a;r(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ts||(Ts={}));var Ls="removed",Ds=function(e){switch(e){case Ts.OPEN:return Ts.OPEN;case Ts.CLOSED:return Ts.CLOSED}},Ps=function(e){return!e||e.text&&L("string",e.text)},Fs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),n}(qa),Gs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=Ts.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=Ds(a.status))&&void 0!==h?h:Ts.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Fs(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Ds(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Fs(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Ka(this)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Fs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),n}(qa),qs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Rs(e)})):[],s._poll=n.poll?new Gs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info,_=ue(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}));s.parentMessage=Vs(t,ue(_))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Rs.payloadify(e)})),poll:Gs.payloadify(e._poll),parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Hs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c;r(this,n),(s=t.call(this,e)).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=a.url,s.fileName=null!==(i=a.file_name)&&void 0!==i?i:null,s.mimeType=null!==(o=a.file_type)&&void 0!==o?o:null,s.fileSize=null!==(u=a.file_size)&&void 0!==u?u:0;var l=ds.of(s._iid).sessionManager;return s._requireAuth=null!==(c=a.require_auth)&&void 0!==c&&c,s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(l.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}}}]),n}(qa),js=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.fileInfoList=null!==(o=null===(i=n.files)||void 0===i?void 0:i.map((function(e){return new Hs(t,e)})))&&void 0!==o?o:[],s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var d=n.parent_message_info,f=Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(h=d.file)||void 0===h?void 0:h.require_auth});s.parentMessage=Vs(t,f)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ns),zs=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return qs.payloadify(t);case e.MessageType.FILE:return Bs.payloadify(t);case e.MessageType.ADMIN:return Us.payloadify(t)}return null},Vs=function(e,t){switch(t.type){case"MESG":return new qs(e,t);case"FILE":return js._isMultipleFilesMessagePayload(t)?new js(e,t):new Bs(e,t);case"ADMM":case"BRDM":return new Us(e,t)}return null},Bs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.name=null,s.size=0,s.type=null,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=null!==(i=n.file)&&void 0!==i?i:null;s.plainUrl=(null!==(c=null!==(o=null==E?void 0:E.url)&&void 0!==o?o:n.url)&&void 0!==c?c:"").split("?auth=")[0],s.name=null!==(h=null!==(l=null==E?void 0:E.name)&&void 0!==l?l:n.name)&&void 0!==h?h:"File",s.size=null!==(f=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==f?f:0,s.data=null!==(v=null!==(p=null==E?void 0:E.data)&&void 0!==p?p:n.custom)&&void 0!==v?v:"",s.type=E?null!==(_=E.type)&&void 0!==_?_:"":null!==(m=n.type)&&void 0!==m?m:"";var w=ds.of(s._iid).sessionManager;if(s.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var x=n.parent_message_info,C=ue(Object.assign(Object.assign({},x),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:x.file,url:null===(k=x.file)||void 0===k?void 0:k.url,require_auth:null===(b=x.file)||void 0===b?void 0:b.require_auth}));s.parentMessage=Vs(t,C)}return s}return s(u,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Qs=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ue({channel_url:t.channelUrl,files:Zs(t.files),url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),Ks=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a),s=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=ce.POST,s.path="".concat(Ce(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue({message_type:e.MessageType.FILE,user_id:t.userId,files:Zs(t.files),url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return Ms.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return bs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),s}return s(a)}(Ae),Ws=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new js(e,s):new Bs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Ys=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;r(this,n),(s=t.call(this,e,a)).message=a.files&&a.files.length>=2?new js(e,a):new Bs(e,a);var u=ds.of(e).sdkState;return s.isMentioned=Se(s.message.mentionType,null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:s.message.mentionedUsers.map((function(e){return e.userId})),u.userId),s.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,s}return s(n)}(Oe);function Zs(e){return null==e?void 0:e.map((function(e){var t,n;return ue({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return Ms.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var Js;!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"}(Js||(Js={}));var Xs=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===aa.CONNECTED||this._connectionState===aa.CONNECTING||this._connectionState===aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return s=new Qs(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ws),u=o.message,t.abrupt("return",u);case 10:return c=new Ks(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,h=l.as(Ys),d=h.message,t.abrupt("return",d);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._queueMap.get(e.url))){t.next=57;break}if(r.isResolving){t.next=56;break}r.isResolving=!0,a=[],s=!0,i=y(r.messageQueue),t.prev=7,i.s();case 9:if((o=i.n()).done){t.next=39;break}u=o.value,t.t0=u.state,t.next=t.t0===Js.PENDING||t.t0===Js.UPLOADING?14:t.t0===Js.UPLOADED?17:t.t0===Js.FAILED?35:37;break;case 14:return s=!1,a.push(u),t.abrupt("break",37);case 17:if(!s){t.next=33;break}return t.prev=18,u.state=Js.SENDING,t.next=22,this._sendFileMessage(e,u);case 22:return c=t.sent,u.deferred.resolve(c),t.next=26,ka(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),u.deferred.reject(t.t1);case 31:t.next=34;break;case 33:a.push(u);case 34:return t.abrupt("break",37);case 35:return u.deferred.reject(u.error.code===E.REQUEST_CANCELED?A.fileUploadCanceled:u.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(l=r.isResolveRequestPending,r.messageQueue=a,r.isResolving=!1,r.isResolveRequestPending=!1,!l){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:r.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),n,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._queueMap.get(e.url),!(s=a.messageQueue.find((function(e){return e.state===Js.PENDING})))){t.next=29;break}if(!s.multipleFileUploadInfo){t.next=18;break}if(i=s.multipleFileUploadInfo,o=i.uploadIndex,u=i.uploadCount,c=i.requestHandler,l=s.params,h=l.fileInfoList[o],!q(h.file)||(null===(n=h._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=12;break}return t.next=10,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 10:t.next=13;break;case 12:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new ps({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(vs),h=l.url,d=l.fileSize,f=void 0===d?r.fileSize:d,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size,r.fileUrl=h,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new ps({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:h=t.sent,d=h.as(vs),f=d.url,p=d.fileSize,v=void 0===p?c.fileSize:p,_=d.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=d.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(s=c.mimeType)&&void 0!==s?s:c.file.type,c.fileSize=null!==(i=c.fileSize)&&void 0!==i?i:c.file.size,c.file=null,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),o=this._queueMap.get(e.url),u=new ua,c={requestId:n,params:r,state:Js.PENDING,deferred:u},$s(r)&&(l={uploadIndex:0,uploadCount:r.fileInfoList.length,requestHandler:a},c.multipleFileUploadInfo=l),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Js.PENDING:i.state=Js.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Js.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function $s(e){return"fileInfoList"in e}var ei,ti={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ni=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},ri={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ai=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(ei=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ei.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ei.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ei.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ei.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ei.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ei.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ei.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ei.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ei.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ei.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ei.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ei.REQUEST_MESSAGE="REQUEST_MESSAGE",ei.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ei.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ei.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ei.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ei.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ei.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ei.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ei.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ei.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ei.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ei.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ei.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ei.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var si,ii=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},oi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a}return s(n)}(oe),ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}(oe),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}(oe),hi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=null,a.source=null,a.event=s,a.source=i,a}return s(n)}(oe),fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(Ae),pi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,f=e.isInclusive,p=e.reverse,v=e.messageTypeFilter,_=e.customTypesFilter,m=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,k=e.includeReactions,b=e.parentMessageId,E=e.includeThreadInfo,w=e.includeParentMessageInfo,x=e.showSubchannelMessagesOnly,C=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue({is_sdk:!0,prev_limit:h,next_limit:d,include:f,reverse:p,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:_,sender_ids:m,include_reply_type:g,with_sorted_meta_array:y,include_reactions:k,parent_message_id:b,include_thread_info:E,include_parent_message_info:w,show_subchannel_message_only:x,include_poll_details:!0,checking_continuous_messages:C}),a}return s(n)}(Ae),_i=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),mi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(Ae),gi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Vs(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),yi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Ae),ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),bi={},Ei=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new Xs(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),bi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Wa(t);switch(n.messageType){case e.MessageType.USER:return new qs(this._iid,qs.payloadify(n));case e.MessageType.FILE:return js._isMultipleFilesMessageSerializedData(n)?new js(this._iid,js.payloadify(n)):new Bs(this._iid,Bs.payloadify(n));case e.MessageType.ADMIN:return new Us(this._iid,Us.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return ue({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,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Wa(e);return new Cs(this._iid,Cs.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new fi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(pi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new yi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(ki),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new vi(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(_i),d=h.messages,this._dispatcher.dispatch(new oi({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new vi(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},As),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(_i),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new oi({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new mi(ue(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ri),s))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(gi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new oi({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ui({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return bi[e]}}]),n}(),wi=function(){function t(){r(this,t),this._onPending=qe,this._onFailed=qe,this._onSucceeded=qe}return s(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),xi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new _s(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(qa),Ci={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ti=function(t){return L("string",t.channelUrl)&&L("string",t.channelType)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)},Si=function(){function e(t,n){var a;r(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),Ii=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(me,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(Ae),Ni=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Vs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Oe);e.MessageSearchOrder=void 0,(si=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",si.TIMESTAMP="ts";var Mi,Ai,Oi,Ui=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ii(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ni),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Ri=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(Si),Li=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=Ei.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),Di={channelUrl:null,scheduledMessageId:0},Pi=function(e){return L("string",e.channelUrl)&&L("number",e.scheduledMessageId)},Fi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=qe,e}return s(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(wi),Gi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ei(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ci),e),Ya(Ti(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Di),e),Ya(Pi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.POST,a.path=be,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),Hi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),ji=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),zi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),Bi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Fs(e,a),s}return s(n)}(Oe),Qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Ae),Ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new Gs(e,t):null}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),Wi={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Yi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Zi={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Ji=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&L("number",t.pollOptionId)},Xi={channelUrl:null,channelType:null,pollId:null},$i=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},eo={},to=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,eo[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Wa(e);return new Gs(this._iid,Gs.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya($i(e)).throw(A.invalidParameters),r=new ji(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(zi),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Yi(e)).throw(A.invalidParameters),r=e.data,a=new qi(Object.assign(Object.assign({},e),{data:r})),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Hi),o=i.poll,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Ji(e)).throw(A.invalidParameters),r=new Vi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Bi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Qi(ue({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Ki),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new li({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return eo[e]}}]),n}(),no=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),ro=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),ao=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=be,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Ae),so=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Gs(e,t)})),s.token=a.next,s}return s(n)}(Oe),io=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new ao(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(so),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),oo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Ae),uo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new Ja(e,t)})),s.token=a.next,s}return s(n)}(Oe),co=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new oo(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(uo),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),lo=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new to(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Wi),e),Ya(Yi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Xi),e),Ya($i(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Zi),e),Ya(Ji(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(fs),ho={profileImage:null,profileUrl:null,nickname:null},fo=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},po=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=qe,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=qe,this.onSessionRefreshed=qe,this.onSessionClosed=qe}))),vo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=qe,this.onReconnectStarted=qe,this.onReconnectSucceeded=qe,this.onReconnectFailed=qe,this.onDisconnected=qe}))),_o=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=qe,this.onTotalUnreadMessageCountUpdated=qe}))),mo="GroupChannel",go=100,yo="Message";e.GroupChannelListOrder=void 0,(Mi=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Mi.CHRONOLOGICAL="chronological",Mi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Mi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ai=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Oi=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Oi.SCHEDULED_AT="scheduled_at";var ko,bo=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Eo=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ns))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ns&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ko||(ko={}));var wo,xo=function(e){switch(e){case ko.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ko.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Co={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},To=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(Ja,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(bs,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(xs,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},So=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Io=Object.assign(Object.assign({},Co),{message:null,translationTargetLanguages:null,pollId:null}),No=function(e){var t;return ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},Mo=function(e){return To(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(wo||(wo={}));var Ao,Oo,Uo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Ro=function(e){return e===wo.BLOB||e===wo.FILE},Lo=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Do=Object.assign(Object.assign({},Co),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Po=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&q(r)&&(e.messageParams.file=r),e.messageParams):ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=r?r:null===(t=e.messageParams)||void 0===t?void 0:t.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},Fo=function(e){return To(e)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Go=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},qo=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"}(Ao||(Ao={})),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"}(Oo||(Oo={}));var Ho,jo={},zo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Ao.PROCESSING,this._queue=[],this._activationQueue=[],jo[t]&&!a.forceCreate||(this.nodeId=qo(),this.key=t,Go()&&(a.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=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Oo.NEWNODE:n._sendSync();break;case Oo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Oo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,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:Oo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Oo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Oo.REQUEST_LOCK:n._requestLock(t);break;case Oo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Oo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Oo.REMOVENODE)}))),jo[t]=this),jo[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Ao.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:qo(),key:this.key,op:e,data:n.data,ts:Date.now()};return Go()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Oo.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&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Oo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Oo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Ao.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Oo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Oo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Oo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),Vo=Object.assign(Object.assign({},Io),{scheduledAt:null}),Bo=Object.assign(Object.assign({},Co),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Qo=Object.assign(Object.assign({},Co),{fileInfoList:null}),Ko=function(e){return(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Wo="UnsentMessage",Yo={},Zo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,Yo[e]=d(s),s._mutex=new zo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Wo)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw A.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof qs?(e.messageParams&&(n.messageParams=So(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},So(t)),{scheduledAt:t.scheduledAt})))):e instanceof Bs?(e.messageParams&&(n.messageParams=Lo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Lo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof js&&e.messageParams&&(n.messageParams=function(e){return e?ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Ei.of(this._iid),a=this._deserialize(e),!e.messageParams){n.next=23;break}if(!(a instanceof qs)){n.next=8;break}s=e.messageParams,a.messageParams=r.buildUserMessageCreateParamsFromSerializedData(s,a),n.next=23;break;case 8:if(!(a instanceof Bs)){n.next=17;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!Ro(i.fileType)){n.next=14;break}return n.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=n.sent;case 14:a.messageParams=r.buildFileMessageCreateParamsFromSerializedData(i,a),n.next=23;break;case 17:if(!(a instanceof js)){n.next=23;break}if(!(o=e.messageParams)||!o.fileInfoList){n.next=23;break}return a.messageParams=r.buildMultipleFilesMessageCreateParamsFromSerializedData(o,a),n.next=23,Promise.all(a.messageParams.fileInfoList.map((function(e){return b(l,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Ro(null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)){t.next=4;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:e.file=t.sent;case 4:case"end":return t.stop()}}),n,this)})))})));case 23:if(!(a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){n.next=36;break}if(!(a instanceof qs)){n.next=29;break}u=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=r.buildScheduledUserMessageCreateParamsFromSerializedData(u,a),n.next=36;break;case 29:if(!(a instanceof Bs)){n.next=36;break}if(!(c=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof c.fileKey||!Ro(c.fileType)){n.next=35;break}return n.next=34,this.collection.getBlob(c.fileKey);case 34:c.file=n.sent;case 35:a.scheduledInfo.scheduledMessageParams=r.buildScheduledFileMessageCreateParamsFromSerializedData(c,a);case 36:return n.abrupt("return",a);case 37:case"end":return n.stop()}}),n,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=void 0===n?null:n,a=e.filter,s=void 0===a?new Eo:a,i=e.order,o=void 0===i?ko.CHANNEL_LATEST:i,u=e.sendingStatus,c=void 0===u?null:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d;return b(this,void 0,void 0,t().mark((function e(){var n,a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=xo(o),a={"/where":function(e){return!!(o!==ko.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&s.match(d._deserialize(e))}},r&&(a.channelUrl=r),c&&(a.sendingStatus=c),i={where:a,index:n,backward:h},e.next=8,this.collection.query(i);case 8:return u=e.sent,e.next=11,u.fetch({});case 11:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return b(d,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:ko.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs||e instanceof js)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof Bs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Uo(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=wo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Uo(s.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=n.sent,s.fileKey=i,s.fileType=wo.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof js)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return b(u,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(s=n.file)||!Uo(s)){t.next=8;break}return t.next=4,this.collection.saveBlob(s,this._getFileInfoBlobKey(e.reqId,r));case 4:i=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=i,n._uploadedMetaData.fileType=wo.BLOB;case 8:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Yo[e]}}]),a}(qa),Jo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:mo,keyName:"url",index:[bo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),bo(e.GroupChannelListOrder.CHRONOLOGICAL),bo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:yo,keyName:"messageId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:Wo,keyName:"reqId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},Xo={},$o=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,Xo[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(yo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?go:a,i=e.filter,o=void 0===i?new Eo:i,u=e.order,c=void 0===u?ko.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d,p=e.isPollOnly,v=void 0!==p&&p;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=xo(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case ko.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:ko.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:xo(ko.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:xo(ko.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=xo(ko.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Uo(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Xo[e]}}]),a}(qa),eu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},tu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?eu:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._pauseDelayTimer=null,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"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")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(se),nu=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:ce.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}(oe),au={},su=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,au[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof ha)switch(e.stateType){case aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=Zo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new ru({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return au[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Ho||(Ho={}));var iu,ou=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new Ja(e,r),blockee:new Ja(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new Ja(e,t)})):[]}}}]),e}(),uu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}(oe);e.GroupChannelEventSource=void 0,(iu=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",iu.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",iu.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",iu.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",iu.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",iu.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",iu.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",iu.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",iu.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",iu.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",iu.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",iu.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",iu.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",iu.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",iu.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",iu.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",iu.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",iu.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",iu.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",iu.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",iu.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",iu.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",iu.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",iu.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",iu.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",iu.REQUEST_CHANNEL="REQUEST_CHANNEL",iu.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",iu.REFRESH_CHANNEL="REFRESH_CHANNEL",iu.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",iu.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",iu.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var cu,lu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.data,u=void 0===o?null:o;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.data=u,a}return s(n)}(oe),du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new ou(s),i}return s(n)}(Ge),vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=void 0===i?null:i,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,f=void 0===d?null:d;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s)),a.params=ue({nickname:o,profile_url:c,profile_file:h,preferred_languages:f}),a}return s(n)}(Ae),_u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=null,s.user=new Ja(e,Object.assign({},a)),s}return s(n)}(Oe),mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Ae),gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(Ae),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Ae),Eu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Ae),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Ae),xu=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(Oe),Cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Ae),Tu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Su=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Ae),Iu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Mu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(Ae),Ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Ru=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Ae),Du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Ae),Fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),Hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Ae),ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Ae),Vu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Ae),Qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Ae),Wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new Ja(e,t)})),updatedUsers:a.updated.map((function(t){return new Ja(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Oe),Yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(Ae),Zu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Oe),Ju=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Ae),Xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),$u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s}return s(n)}(Oe),ec=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Ae),nc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(Oe),rc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Ae),ac=s((function e(t){r(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),sc=s((function e(t){var n,a,s;r(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(n=t.id)&&void 0!==n?n:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(s=t.url)&&void 0!==s?s:"",this.emojis=t.emojis?t.emojis.map((function(e){return new ac(e)})):[]})),ic=s((function e(t){r(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new sc(e)})):[]})),oc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path=ke,e}return s(n)}(Ae),uc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new ic(a),s}return s(n)}(Oe),cc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Ae),lc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new sc(a),s}return s(n)}(Oe),hc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ye,"/").concat(s),a}return s(n)}(Ae),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new ac(a),s}return s(n)}(Oe),fc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path="".concat(we),e}return s(n)}(Ae),pc=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;r(this,n);var o=null!=a?a:{};return(s=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return s(n)}(Oe),vc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=he,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Ae),_c=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),mc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new vc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(_c),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),gc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Ae),yc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),kc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new gc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(yc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),bc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Ae),Ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),wc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new bc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(Ec),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),xc={},Cc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),xc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,xc[n]=this),xc[n]}return s(e,null,[{key:"get",value:function(e){return xc[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_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",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"}(cu||(cu={}));var Tc,Sc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?cu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:cu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:cu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:cu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:cu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:cu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:cu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:cu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:cu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:cu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:cu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:cu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:cu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:cu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:cu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:cu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:cu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:cu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:cu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:cu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:cu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Tc||(Tc={}));var Ic,Nc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw Sc.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},Mc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Sc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Ac=function(e,t){for(var n=0,r=0;r>>0)%t},Oc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Uc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(Mc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Mc(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Mc(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Mc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Rc=function(){},Lc=function(){return Promise.resolve()},Dc=function(e){return e},Pc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ic||(Ic={}));var Fc,Gc,qc,Hc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Dc:u,l=t.backward,h=void 0===l?Lc:l,d=t.forward,f=void 0===d?Lc:d,p=t.complete,v=void 0===p?Rc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),jc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Mc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Mc(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw Sc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Wc(e,t)).concat(n,".").concat(r)},Zc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Yc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o}});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Wc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Fc||(Fc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Gc||(Gc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(qc||(qc={}));var Jc,Xc=[Gc.PENDING,Gc.VOLATILE],$c={},el=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),$c[n]||(this.dbname=n,this._items=[],this._limit=s,$c[n]=this),$c[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qc.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,state:r===qc.PERSISTENT?Gc.PERSISTENT:Gc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===qc.PERSISTENT&&(s.state=Gc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===qc.PERSISTENT&&(r.state=Gc.PERSISTENT),t!==qc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Xc.includes(this._items[t].state)&&Xc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Gc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Gc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Gc.VOLATILE}))}}],[{key:"get",value:function(e){return $c[e]}}]),e}(),tl=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Bc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Bc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=el.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=el.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Ac)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Kc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=el.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=nl.createFromCacheItem(i),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Cc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=el.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?nl.createFromCacheItem(u):new nl({blockId:s,keyName:this.keyName,items:[],limit:i}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Kc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:el.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),al={},sl=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Bc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return al[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Fc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Fc.ERROR,this.indexerKey,(function(){return n.abort()}))),al[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Sc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Mc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=el.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,qc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Kc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,qc.NO_CACHE);case 17:if(c=e.sent,l=nl.createFromCacheItem(c)){h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Nc(this._origin);case 35:al[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return el.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete al[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Nc(this._origin)}},{key:"abort",value:function(){this._table=Nc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in al)delete al[e]}}]),e}(),il=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Tc.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return sl.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new zo(function(e,t){return"".concat(Bc(e,t),".lock")}(a,s)),this._blobContainer=new Zc({dbname:a,collectionName:s,store:c}),this._transaction=new tl({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Tc.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=Cc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new rl({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return sl.createKey(e)})),u=a?a.indexes.map((function(e){return sl.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(sl.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Qc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Tc.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Tc.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=sl.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===sl.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Sc.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Qc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Sc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Nc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Sc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new zc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Sc.collectionNotReady}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new jc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Uc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)&&i.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw Sc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),ul={},cl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return ul[this.dbname]},set:function(e){ul[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ul[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(ul[this.dbname]));case 4:throw Sc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=6;break}return t.next=3,Oc(this.delay);case 3:return t.abrupt("return",ul[this.dbname][e]?Object.assign({key:e},ul[this.dbname][e]):null);case 6:throw Sc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,ul[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,ul[this.dbname][s]&&delete ul[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,ul[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(s=a.set())){t.next=5;break}throw s;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=12;break}if(i=s.value,!(o=this.observer[i.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Oc(this.delay);case 2:ul[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ol),ll="NestDBStore",hl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=ll,e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return s(a,[{key:"_getObjectStore",value:function(e){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);throw Sc.storeNotInitialized}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,n){var a=r._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!Go()){e.next=13;break}if(!(Go()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Sc.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Sc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Sc.storeNotAvailableInPrivateBrowsing)}else t(Sc.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Sc.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,new Promise((function(t,n){if(r._indexedDb){var a=r._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ll,{keyPath:"key"})})),a.addEventListener("success",(function(e){return t(e.target.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}else n(Sc.storeNotAvailable)}));case 5:this._database=t.sent;case 6:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),a}(ol),dl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new bl(e,t)}))),s}return s(n)}(Oe),Rl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ol(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ul),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),Ll=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Ae),Dl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new bl(e,t.user)}))),s}return s(n)}(Oe),Pl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ll(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Dl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.ReportCategory=void 0,(yl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",yl.HARASSING="harassing",yl.SUSPICIOUS="suspicious",yl.INAPPROPRIATE="inappropriate";var Fl,Gl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),Hl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Ae),jl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=null,s.endAt=null,s.remainingDuration=null,s.description=null;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(Oe),zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Ae),Vl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Bl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Ae),Ql=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(Oe),Kl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Ae),Wl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Yl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),Zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Ae),Jl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),Xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Ae),$l=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),eh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Ae),th=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),nh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Ae),rh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),ah=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Ae),sh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),oh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params=null,a}return s(n)}(Ae),uh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params=null,a}return s(n)}(Ae),ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Ae),lh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),hh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),dh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),fh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Ae),ph=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).memberCount=null,i.joinedMemberCount=null,i.user=new bl(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(Ge),vh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),_h=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),mh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Ae),gh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(Ge),yh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Ae),kh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=ce.POST,s.path="".concat(ge,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(Ae),bh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(Ae),Eh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ue({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),wh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"MESG",s)).message=new qs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),xh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(s=t.appleCriticalAlertOptions)||void 0===s?void 0:s.serialize(),poll_id:t.pollId})})}return s(a)}(ia),Ch=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new qs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Th=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return s(a)}(ia),Sh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Bs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Ih=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Ae),Nh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(Ge),Mh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Ah=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(a),s}return s(n)}(Oe),Oh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Uh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(Object.assign({},a)),s}return s(n)}(Oe),Rh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Ae),Lh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Dh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),Ph=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Fh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),Gh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),qh=function(e){return L("string",e.title,!0)&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Hh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),jh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),zh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Vh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Ae),Bh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Qh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Ae),Kh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Wh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Ae),Yh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Zh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Jh=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ue({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(ia),Xh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=null,i.channelUrl=null,i.channelType=null,i.event=new ro(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),$h=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).url="",s.channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new Ja(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(s._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=ue(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Pl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Li(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Gl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new ql({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Hl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(jl),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new zl({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Vl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new zl({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Vl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new Bl({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Ql),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new Kl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Wl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Zl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(Jl),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Xl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as($l),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new eh({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(th),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new eh({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(th),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new nh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(rh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(sh),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(sh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(sh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new oh({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new uh({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new ch({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new hh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new fh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new vh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new mh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new mh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("number",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("string",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=ds.of(this._iid).sessionManager;return ue({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return bs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:Cs.payloadify(s.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return Ja.payloadify(e)}))})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new qs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:t.fileName,size:t.fileSize,type:t.mimeType,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),s=new Bs(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),s=new js(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Io),e);return Ya(Mo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=a,c=Date.now(),l=new wi;return u||(u=this._generateRequestId(),ka(2).then((function(){var a=new Eh(Object.assign(Object.assign({},n),{channelUrl:r.url,channelType:r.channelType,reqId:u}));o.send(a).then((function(n){var a=n.as(wh).message;i.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var s=r._createPendingUserMessage(n,u,c),o=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(s,a,o),i.dispatch(new oi({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a,s));case 1:case"end":return e.stop()}}),e)})))}))}))}));var s=r._createPendingUserMessage(n,u,c);i.dispatch(new oi({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,s));case 1:case"end":return e.stop()}}),e)})))}))}))),l}},{key:"_autoResendUserMessage",value:function(e){return Ya(e instanceof qs).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ua,s=null!==(n=e.messageParams)&&void 0!==n?n:No(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cl),n),Ya(L("number",e)&&Tl(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new xh(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ch),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Ya(!r.poll).throw(A.notSupportedError),c=new ua,l=null!==(a=r.messageParams)&&void 0!==a?a:Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Rh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Lh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=ds.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();ka(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Dh(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(Ph).message;wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Do),e);return Ya(Fo(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t=Object.assign(Object.assign({},Qo),e),n=ds.of(this._iid);Ya(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return To(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Ko(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Ya(!r).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new wi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingFileMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingFileMessage(n,o,u),l=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(i,a,l),s.dispatch(new oi({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_autoResendFileMessage",value:function(e){Ya(e instanceof Bs).throw(A.invalidParameters);var t=ds.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new Fi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingMultipleFilesMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n,c).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingMultipleFilesMessage(n,o,u);r._markMessageAsFailed(i,a),s.dispatch(new oi({messages:[i],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=ds.of(this._iid).requestQueue,o=new Fh(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(Gh).message;wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(M(i))throw i;ka(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Ya(e.every((function(e){return Fo(Object.assign(Object.assign({},Do),e))}))).throw(A.invalidParameters);var t,n=new wi,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||q(n)||q(null===(r=e.messageParams)||void 0===r?void 0:r.file),Ya(e instanceof Bs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ua,o=Po(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Sl),n),Ya(L("number",e)&&Il(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Th(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Sh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=Ei.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof Bs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ua,l=Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1}),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=ds.of(this._iid),a=r.requestQueue,s=new Ih({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Mh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Ah),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Oh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Uh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new xh({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Ch),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Th({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Sh),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new yh({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ja&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new kh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ns&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new bh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&qh(n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Hh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(jh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new zh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Vh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Bh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Qh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Kh),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=new Wh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Yh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Zh({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new Jh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as(Xh),d=h.event,u.dispatch(new di({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)).throw(A.invalidParameters),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e,!0)),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new io(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new co(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:Ja.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),u}(qa),ed=null,td=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=a;var o=ds.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new nu({logger:f,connectionDelegate:{reconnect:function(){var t=ds.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){ds.of(e).connectionManager.disconnect()}}});var _=new su(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new tu({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof ha){if(n.stateType===aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof Ge){if("USEV"===n.code){var r=n.as(pu).event;if(r.category===Ho.FRIEND_DISCOVERED){var a=ou.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof oa){var s=ds.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof Xa?c.preference.set(i._getUserProfileCacheKey(u.userId),$a.payloadify(n.userProfile)):n instanceof Re&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return ds.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return ds.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=ds.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return ds.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ds.of(this._iid).logger.level},set:function(e){ds.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ds.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ds.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ds.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ds.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ds.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ds.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=ds.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof cl?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ds.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.store=new cl,t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=ds.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=30;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=27;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==Jc.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new gl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Jo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Jo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new uu(this._iid,{userId:e}));case 15:a.userId=e,t.next=25;break;case 18:return t.prev=18,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=23,this._safeInitializeStore(c);case 23:throw a.userId=e,A.databaseError;case 25:t.next=30;break;case 27:return t.next=29,this._safeInitializeStore(c);case 29:a.userId=e;case 30:case"end":return t.stop()}}),n,this,[[6,18]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),r=$o.of(this._iid),a=Zo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,t.prev=2,t.next=5,this.initializeCache(e);case 5:c=ds.of(this._iid),c.dispatcher.dispatch(new fu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=ds.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 14:return t.next=16,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 16:return t.next=18,i.preference.get(this._getUserProfileCacheKey(e));case 18:return(d=t.sent)&&new $a(this._iid,d).apply(),t.next=22,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 22:return t.prev=22,t.next=25,o.connect(n);case 25:return t.prev=25,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.finish(25);case 29:return t.abrupt("return",this.currentUser);case 30:case"end":return t.stop()}}),r,this,[[2,9],[22,,25,29]])})))}},{key:"reconnect",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Ya(e instanceof po).throw(A.invalidParameters),ds.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Ya(L("string",e)&&t instanceof _o).throw(A.invalidParameters),ds.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ds.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ds.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Ya(L("string",e)&&t instanceof vo).throw(A.invalidParameters),ds.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ds.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ds.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new kc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ui(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new io(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new co(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Wa(e);return new Ja(this._iid,Ja.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ho),e),Ya(fo(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new vu(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(_u),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new vu({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(_u),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new gu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new ku({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new Eu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new mu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new yu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new bu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Cu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tu),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Su({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Iu),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Nu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Mu),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=ds.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Au({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Ou),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Uu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ru),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Lu({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Du),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new wu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(xu),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Gu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(qu).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Hu({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(ju).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new zu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Vu).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTemplate,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Bu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Qu).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Pu({userId:a.userId,blockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,unblockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ku({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Wu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(nc),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new rc({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Yu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Zu),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ju({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as($u),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ec({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new oc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(uc),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new cc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(lc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new hc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(dc),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),Ya(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new fc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(pc),o=i.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=void 0===r?null:r,s=e.modules,i=void 0===s?[]:s,o=e.options,u=void 0===o?new H:o,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,m=e.localCacheEnabled,g=void 0!==m&&m,y=e.localCacheConfig,k=void 0===y?new te:y,b=e.localCacheEncryption,E=e.useAsyncStorageStore,w=void 0===E?null:E,x=e.appStateToggleEnabled,C=void 0===x||x;if(!ed||p){var T="su-".concat(re()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},I=new cl({encryption:S});l||(I=Pe()?w?new dl({AsyncStorage:w,encryption:S}):new cl({encryption:S}):new hl({encryption:S})),new ds(T,{appId:t,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:I,encryption:S,logLevel:v,localCacheEnabled:g,localCacheConfig:k,debugMode:l,appStateToggleEnabled:C});var N=[new Gi,new lo],M=new n(T,u,[].concat(_(i),N));return ed||(ed=M),M}return ed}},{key:"instance",get:function(){return ed}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Fl=e.MemberState||(e.MemberState={})).NONE="none",Fl.JOINED="joined",Fl.INVITED="invited",Fl.LEFT="left";var nd,rd,ad,sd,id,od,ud,cd,ld=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,Object.prototype.hasOwnProperty.call(s,"is_muted")&&(i.isMuted=s.is_muted),Object.prototype.hasOwnProperty.call(s,"is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),Object.prototype.hasOwnProperty.call(s,"is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),a}(bl),hd=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new Ja(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(qa);e.PublicChannelFilter=void 0,(nd=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",nd.PUBLIC="public",nd.PRIVATE="private",e.MyMemberStateFilter=void 0,(rd=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",rd.JOINED="joined_only",rd.INVITED="invited_only",rd.INVITED_BY_FRIEND="invited_by_friend",rd.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(ad=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",ad.SUPER="super",ad.NON_SUPER="nonsuper",ad.BROADCAST_ONLY="broadcast_only",ad.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(sd=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",sd.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(id=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",id.UNHIDDEN="unhidden_only",id.HIDDEN="hidden_only",id.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",id.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(od=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",od.OPERATOR="operator",od.NONOPERATOR="nonoperator",e.QueryType=void 0,(ud=e.QueryType||(e.QueryType={})).AND="AND",ud.OR="OR",e.GroupChannelSearchField=void 0,(cd=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",cd.CHANNEL_NAME="channel_name";var dd,fd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),pd=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(mo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Uf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(f&&f===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(u=t.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(qa);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(dd||(dd={}));var vd,_d=function(){function t(e){r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),md={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},gd=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},yd={customTypes:null,includeEmpty:!1,includeFrozen:!0},kd=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},bd={myMemberStateFilter:e.MyMemberStateFilter.ALL},Ed=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(vd=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",vd.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",vd.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",vd.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",vd.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",vd.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",vd.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",vd.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",vd.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var wd,xd={keys:[]},Cd=function(t){return F(e.UnreadItemKey,t.keys)},Td={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},Sd=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Id={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},Nd=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Md=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_,m=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof hu)){n.next=27;break}r=e.channels,a=e.source,u=e.data,c=r.filter((function(e){return e instanceof Vp})),l=s.filterOffsetChanged(c),h=y(l),n.prev=5,h.s();case 7:if((d=h.n()).done){n.next=13;break}return f=d.value,n.next=11,i.removeUnderOffset(f.url,f.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(c);case 23:p=n.sent,this._broadcastUpdateEvent(p,a,u),n.next=39;break;case 27:if(!(e instanceof du)){n.next=36;break}return v=e.channelUrls,_=e.source,n.next=31,s.remove(v);case 31:return n.next=33,xa((function(){return b(m,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(v),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:this._broadcastRemoveEvent(v,_),n.next=39;break;case 36:if(!(e instanceof uu)){n.next=39;break}return n.next=39,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){r.value.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ad=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,x=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof oi)){n.next=14;break}if(r=e.messages,a=e.source,s=r.filter((function(e){return e.messageId>0})),u=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(s);case 2:return e.next=4,o.remove(s.map((function(e){return e instanceof Ns?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(s,a);case 8:if(!(u.length>0)){n.next=12;break}return n.next=11,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(u);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(u,a);case 12:n.next=61;break;case 14:if(!(e instanceof ui)){n.next=21;break}return c=e.messageIds,l=e.source,n.next=18,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(c);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(c,l),n.next=61;break;case 21:if(!(e instanceof ci)){n.next=28;break}return h=e.reqId,d=e.source,n.next=25,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([h]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(h,d),n.next=61;break;case 28:if(!(e instanceof li)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return i.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof hi)){n.next=52;break}return m=e.event,g=e.source,n.next=45,i.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof di)){n.next=61;break}return k=e.event,E=e.source,n.next=56,i.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(k,E);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Od=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},yd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return s(n)}(Ae),Ud=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Vp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Oe),Rd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?pe:fe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Vp(e,a),s}return s(n)}(Oe),Dd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,x=e.metadataValues,C=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:f,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:x,metadata_value_startswith:C,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(Ae),Pd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Vp(e,t)}))),s.ts=null!=u?u:null,s}return s(n)}(Oe),Fd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Ae),Gd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(Oe),qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params={item_keys:o},a}return s(n)}(Ae),Hd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(Oe),jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Ae),zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Vd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Ae),Bd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ee,"/count"),a.params={channel_url:s,status:Wd(i)},o&&(a.params.message_type=o),a}return s(n)}(Ae),Kd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(Oe),Wd=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(gs.PENDING);break;case e.ScheduledStatus.SENT:n.push(gs.IN_QUEUE),n.push(gs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(gs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(gs.FAILED)}})),n}},Yd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,x=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path=fe,a.params=ue({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:x,message_survival_seconds:E}),a}return s(n)}(Ae),Zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s.isCreated=a.is_created,s}return s(n)}(Oe),Jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Ae),Xd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new _d(s),i}return s(n)}(Ge),$d=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),ef=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new ld(e,t)})):[new ld(e,s.data)],i}return s(n)}(Xd),nf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(Ae),rf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new ld(i._iid,s.data),i}return s(n)}(Xd),af=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Ae),sf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),of=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitees,v=void 0===p?[]:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitees=v.map((function(t){return new ld(e,t)})),i}return s(n)}(Xd),uf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Ae),cf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitee,v=void 0===p?null:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitee=v?new ld(e,v):null,i}return s(n)}(Xd),lf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(ia),hf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new hd(e,s),i}return s(n)}(Ge),df=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}return s(n)}(Ae),ff=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(Ge),pf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:o,allow_auto_unhide:u},a}return s(n)}(Ae),vf=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=s.data.allow_auto_unhide,i.hidePreviousMessages=s.data.hide_previous_messages),i.messageOffsetTimestamp=s.ts_message_offset,i}return s(n)}(Ge),mf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),gf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),yf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),kf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new Ja(i._iid,e)})),i}return s(n)}(Xd),Ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(Ge),wf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(ia),xf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Us(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Cf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Us(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ys(s),i}return s(n)}(Ge),Sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new xi(e,s),i}return s(n)}(Ge),If=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new no(e,s),i.status=Ds(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),Nf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=n.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(C=n.metadataValues)&&void 0!==C?C:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Ka(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Uf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,this,this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Mf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return r.abrupt("break",335);case 81:return q=n.as(ff),H=q.channelUrl,j=q.deliveredStateUpdate,z=void 0===j?{}:j,V=this._groupChannelCache.isCachedInMemory(H),r.next=85,this.getChannel(H,!0);case 85:if(B=r.sent,V)for(Q in z)B._updateUndeliveredMemberState(Q,z[Q]);return Object.keys(z).some((function(e){return e!==cn._sdkState.userId}))&&(this._dispatcher.dispatch(new hu({channels:[B],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUndeliveredMemberStatusUpdated(B)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 89:if(K=n.as(Tf),W=K.channelUrl,Y=K.channelType,Z=K.event,Y!==e.ChannelType.GROUP){r.next=99;break}return r.next=93,this.getChannel(W,!0);case 93:return J=r.sent,r.next=96,this.getMessageFromCache(Z.messageId);case 96:(X=r.sent)&&(X.applyReactionEvent(Z),this._dispatcher.dispatch(new oi({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onReactionUpdated(J,Z)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return r.abrupt("break",335);case 100:if($=n.as(Sf),(ee=$.event).channelType!==e.ChannelType.GROUP){r.next=110;break}return r.next=104,this.getChannel(ee.channelUrl,!0);case 104:return te=r.sent,r.next=107,this.getMessageFromCache(ee.targetMessageId);case 107:(ne=r.sent)&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new oi({messages:[ne],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onThreadInfoUpdated(te,ee)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return r.abrupt("break",335);case 111:re=n.as(Ef),ae=re.groupChannelMemberCounts,se=[],ie=y(ae),r.prev=114,ie.s();case 116:if((oe=ie.n()).done){r.next=125;break}return ue=oe.value,ce=ue.channelUrl,le=ue.memberCount,he=ue.joinedMemberCount,de=ue.updatedAt,r.next=121,this.getChannelFromCache(ce);case 121:(fe=r.sent)&&fe._setLatestMemberCount(le,he,de)&&se.push(fe);case 123:r.next=116;break;case 125:r.next=130;break;case 127:r.prev=127,r.t2=r.catch(114),ie.e(r.t2);case 130:return r.prev=130,ie.f(),r.finish(130);case 133:return se.length>0&&(this._dispatcher.dispatch(new hu({channels:se,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(se)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 135:if(pe=n.as(If),ve=pe.event,_e=pe.status,me=pe.channelUrl,ge=pe.channelType,!me||ge!==e.ChannelType.GROUP){r.next=142;break}return r.next=139,this.getChannel(me,!0);case 139:ye=r.sent,this._dispatcher.dispatch(new hi({event:ve,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(_e===Ls?function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(ye,ve.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(ye,ve)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return r.abrupt("break",335);case 143:if(ke=n.as(Xh),be=ke.event,Ee=ke.channelUrl,we=ke.channelType,!Ee||we!==e.ChannelType.GROUP){r.next=150;break}return r.next=147,this.getChannel(Ee,!0);case 147:xe=r.sent,this._dispatcher.dispatch(new di({event:be,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(xe,be)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return r.abrupt("break",335);case 151:if(Ce=n.as(Xd),!(Te=Ce.event).isGroupChannelEvent){r.next=323;break}r.t3=Te.category,r.next=r.t3===dd.CHANNEL_JOIN?156:r.t3===dd.CHANNEL_LEAVE?165:r.t3===dd.CHANNEL_OPERATOR_UPDATE?181:r.t3===dd.CHANNEL_INVITE?192:r.t3===dd.CHANNEL_DECLINE_INVITE?202:r.t3===dd.TYPING_START||r.t3===dd.TYPING_END?210:r.t3===dd.USER_CHANNEL_MUTE||r.t3===dd.USER_CHANNEL_UNMUTE?219:r.t3===dd.USER_CHANNEL_BAN?246:r.t3===dd.USER_CHANNEL_UNBAN?259:r.t3===dd.CHANNEL_FREEZE||r.t3===dd.CHANNEL_UNFREEZE?265:r.t3===dd.CHANNEL_HIDE?273:r.t3===dd.CHANNEL_UNHIDE?283:r.t3===dd.CHANNEL_DELETED?290:r.t3===dd.CHANNEL_PROP_CHANGED?296:r.t3===dd.CHANNEL_META_DATA_CHANGED?302:r.t3===dd.CHANNEL_META_COUNTERS_CHANGED?311:r.t3===dd.PINNED_MESSAGE_CHANGED?317:323;break;case 156:return r.next=158,this.getChannel(Te.channelUrl,!0);case 158:return Se=r.sent,Ie=n.as(tf),Ne=Ie.memberCount,Me=Ie.joinedMemberCount,Ae=Ie.members,Oe=!1,Ae.forEach((function(t){Se.isExclusive||Se.isSuper||Se.isBroadcast?Oe=Oe||Se._setLatestMemberCount(Ne,Me,Te.ts):(t.state=e.MemberState.JOINED,Se.addMember(t,Te.ts),cn._updateJoinedMemberCount(Se)),t.userId===cn._sdkState.userId&&(Se.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new hu({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ae);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Se,r)}}catch(e){n.e(e)}finally{n.f()}Se.isBroadcast&&Oe&&e.onChannelMemberCountChanged([Se])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 165:if(!(Ue=this._leftChannels.get(Te.channelUrl))){r.next=170;break}r.t4=Ue.channel,r.next=173;break;case 170:return r.next=172,this.getChannel(Te.channelUrl,!0);case 172:r.t4=r.sent;case 173:return Re=r.t4,Le=n.as(rf),De=Le.memberCount,Pe=Le.joinedMemberCount,Fe=Le.member,Ge=!1,qe=ds.of(this._iid),He=qe.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(De,Pe,Te.ts):(He.enabledChannelMemberShipHistory?(Re.members.find((function(e){return e.userId===Fe.userId})).state=e.MemberState.LEFT,Re.memberCount=De):Re.removeMember(Fe),this._updateJoinedMemberCount(Re)),Fe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new du({channelUrls:[Re.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Re,Fe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 181:return r.next=183,this.getChannel(Te.channelUrl,!0);case 183:je=r.sent,ze=n.as(bf),Ve=ze.operators,Be=Ve.map((function(e){return e.userId})),Qe=y(je.members);try{for(Qe.s();!(Ke=Qe.n()).done;)(We=Ke.value).role=Be.includes(We.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Qe.e(e)}finally{Qe.f()}return je.myRole=Be.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new hu({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 192:return r.next=194,this.getChannel(Te.channelUrl,!0);case 194:Ye=r.sent,Ze=n.as(of),Je=Ze.memberCount,Xe=Ze.joinedMemberCount,$e=Ze.inviter,(et=Ze.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),tt=y(et);try{for(tt.s();!(nt=tt.n()).done;)rt=nt.value,Ye.isExclusive||Ye.isSuper||Ye.isBroadcast?Ye._setLatestMemberCount(Je,Xe,Te.ts):Ye.addMember(rt,Te.ts),this._sdkState.userId===rt.userId&&(Ye.hiddenState=e.HiddenState.UNHIDDEN,Ye.myMemberState!==e.MemberState.JOINED&&(Ye.myMemberState=e.MemberState.INVITED),Ye.invitedAt=Te.ts)}catch(e){tt.e(e)}finally{tt.f()}return this._dispatcher.dispatch(new hu({channels:[Ye],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ye,$e,et)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 202:return r.next=204,this.getChannel(Te.channelUrl,!0);case 204:return at=r.sent,st=n.as(cf),it=st.memberCount,ot=st.joinedMemberCount,ut=st.inviter,ct=st.invitee,at.isExclusive||at.isSuper||at.isBroadcast?at._setLatestMemberCount(it,ot,Te.ts):at.removeMember(ct),this._sdkState.userId===ct.userId?(at.invitedAt=0,at.myMemberState=e.MemberState.NONE,at.isPublic?this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new du({channelUrls:[at.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(at,ut,ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 210:return r.next=212,this.getChannel(Te.channelUrl,!0);case 212:return lt=r.sent,ht=Te.category===dd.TYPING_START,dt=n.as(ht?gf:kf),ft=dt.user,lt._updateTypingStatus(ft,ht?Te.ts:0),this._dispatcher.dispatch(new hu({channels:[lt],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 219:return r.next=221,this.getChannel(Te.channelUrl,!0);case 221:pt=r.sent,vt=Te.category===dd.USER_CHANNEL_MUTE,_t=n.as(vt?lh:dh),(mt=_t.user).userId===this._sdkState.userId&&(pt.myMutedState=vt?e.MutedState.MUTED:e.MutedState.UNMUTED,pt._myMutedRemainingTime=mt.restrictionInfo.remainingDuration),gt=y(pt.members),r.prev=226,gt.s();case 228:if((yt=gt.n()).done){r.next=235;break}if((kt=yt.value).userId!==mt.userId){r.next=233;break}return kt.isMuted=vt,r.abrupt("break",235);case 233:r.next=228;break;case 235:r.next=240;break;case 237:r.prev=237,r.t5=r.catch(226),gt.e(r.t5);case 240:return r.prev=240,gt.f(),r.finish(240);case 243:return this._dispatcher.dispatch(new hu({channels:[pt],source:vt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:mt.userId})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vt?e.onUserMuted(pt,mt):e.onUserUnmuted(pt,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 246:if(!(bt=this._leftChannels.get(Te.channelUrl))){r.next=251;break}r.t6=bt.channel,r.next=254;break;case 251:return r.next=253,this.getChannel(Te.channelUrl,!0);case 253:r.t6=r.sent;case 254:return Et=r.t6,this._markAsLeave(Et),wt=n.as(ph),xt=wt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Et,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 259:return r.next=261,this.getChannel(Te.channelUrl,!0);case 261:return Ct=r.sent,Tt=n.as(_h),St=Tt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(Ct,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 265:return r.next=267,this.getChannel(Te.channelUrl,!0);case 267:return It=r.sent,Nt=n.as(gh),Mt=Nt.freeze,It.isFrozen=Mt,this._dispatcher.dispatch(new hu({channels:[It],source:Mt?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Mt?e.onChannelFrozen(It):e.onChannelUnfrozen(It)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 273:return r.next=275,this.getChannel(Te.channelUrl,!0);case 275:return At=r.sent,Ot=n.as(_f),Ut=Ot.allowAutoUnhide,Rt=Ot.hidePreviousMessages,Lt=Ot.messageOffsetTimestamp,null!==Ut&&(At.hiddenState=Ut?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Rt&&Rt&&At._updateUnreadCount(0,0),null!==Lt&&(At.messageOffsetTimestamp=Lt),this._dispatcher.dispatch(new hu({channels:[At],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 283:return r.next=285,this.getChannel(Te.channelUrl,!0);case 285:return(Dt=r.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new hu({channels:[Dt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 290:return r.next=292,this.getChannel(Te.channelUrl,!0);case 292:return Pt=r.sent,this._dispatcher.dispatch(new du({channelUrls:[Te.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 296:return r.next=298,this.getChannelWithoutCache(Te.channelUrl,!0);case 298:return Ft=r.sent,this._dispatcher.dispatch(new hu({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 302:return r.next=304,this.getChannel(Te.channelUrl,!0);case 304:return Gt=r.sent,qt=n.as(Yl),Ht=qt.created,jt=qt.updated,zt=qt.deleted,Ht&&Gt._upsertCachedMetaData(Ht,Te.ts),jt&&Gt._upsertCachedMetaData(jt,Te.ts),zt&&Gt._removeFromCachedMetaData(zt,Te.ts),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ht&&e.onMetaDataCreated(Gt,Ht),jt&&e.onMetaDataUpdated(Gt,jt),zt&&e.onMetaDataDeleted(Gt,zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 311:return r.next=313,this.getChannel(Te.channelUrl,!0);case 313:return Vt=r.sent,Bt=n.as(ih),Qt=Bt.created,Kt=Bt.updated,Wt=Bt.deleted,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Qt&&e.onMetaCounterCreated(Vt,Qt),Kt&&e.onMetaCounterUpdated(Vt,Kt),Wt&&e.onMetaCounterDeleted(Vt,Wt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 317:return r.next=319,this.getChannel(Te.channelUrl,!0);case 319:return Yt=r.sent,Zt=n.as(Af),Jt=Zt.pinnedMessageIds,Xt=Zt.latestPinnedMessage,($t=Zt.ts)>Yt._pinnedMessagesUpdatedAt&&(Yt.pinnedMessageIds=Jt,Yt.lastPinnedMessage=Xt,Yt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new hu({channels:[Yt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(Yt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Yt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",323);case 323:return r.abrupt("break",335);case 324:en=n.as(pu),tn=en.event,r.t7=tn.category,r.next=r.t7===Ho.USER_BLOCK?328:r.t7===Ho.USER_UNBLOCK?331:334;break;case 328:return nn=ou.getDataAsUserBlockEvent(this._iid,tn),rn=nn.blocker,an=nn.blockee,this._groupChannelCache.block(rn.userId,an.userId),r.abrupt("break",334);case 331:return sn=ou.getDataAsUserBlockEvent(this._iid,tn),on=sn.blocker,un=sn.blockee,this._groupChannelCache.unblock(on.userId,un.userId),r.abrupt("break",334);case 334:return r.abrupt("break",335);case 335:r.next=341;break;case 337:if(r.prev=337,r.t8=r.catch(0),!M(r.t8)){r.next=341;break}throw r.t8;case 341:case"end":return r.stop()}}),r,this,[[0,337],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)).throw(A.invalidParameters),s=new Rd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Ld),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Rd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Ld),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new du({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new hu({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new du({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Dd(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Pd),c=u.channels,l=u.token,this._dispatcher.dispatch(new hu({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:go;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:go;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Mf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},yd),r),Ya((L("string",n)||L("number",n))&&kd(s)).throw(A.invalidParameters),i=new Od(ue({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(Ud),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new hu({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new du({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},bd),e),Ya(Ed(r)).throw(A.invalidParameters),a=new Fd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Gd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},xd),e),Ya(Cd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new qd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Hd),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ue({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new jd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(zd),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Td),e),Ya(Sd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Vd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Bd),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Id),e),Ya(Nd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Qd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Kd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ds.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ds.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ds.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=null),a=new Yd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(Zd),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Ya(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Jd({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Ya(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new Jd({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Of[e]}},{key:"clear",value:function(e){Of[e]&&delete Of[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(wd||(wd={}));var Rf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._worker=null,s._state=wd.IDLE,s._semaphore=null,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===wd.IDLE}},{key:"isRunning",get:function(){return this._state===wd.RUNNING}},{key:"isDone",get:function(){return this._state===wd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Mf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._prevSyncLoopCount<1,i.nextToken=this._metadata.range.top,this._metadata.previousComplete=u.length0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Mf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._nextSyncLoopCount<1,i.nextToken=this._metadata.range.bottom,v.debug("message background next sync progress",i),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",i);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=ds.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=ds.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,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:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Pf[e]||(Pf[e]={}),Pf[e][t.url]||(Pf[e][t.url]=new n({_iid:e,channel:t})),Pf[e][t.url].ref++,Pf[e][t.url]}},{key:"clear",value:function(e,t){Pf[e]&&Pf[e][t]&&(Pf[e][t].close(),delete Pf[e])}}]),n}(),Gf={},qf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=o;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Rf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=Ei.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Gf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Gf[e]||(Gf[e]={}),Gf[e][t.url]||(Gf[e][t.url]=new n({_iid:e,channel:t})),Gf[e][t.url].ref++,Gf[e][t.url]}},{key:"clear",value:function(e,t){Gf[e]&&Gf[e][t]&&(Gf[e][t].close(),delete Gf[e])}}]),n}(),Hf={},jf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=s,this._channel=i;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Rf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=ds.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=to.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof A&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Hf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Hf[t]||(Hf[t]={}),Hf[t][n.url]||(Hf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Hf[t][n.url].ref++,Hf[t][n.url]}}]),e}(),zf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ue({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!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(Ae),Vf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Vs(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Vs(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(Oe),Bf=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},Qf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Kf=function(e,t,n){if(e.length>0){for(var r=Qf(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:Wf(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Wf=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a}},Yf=function(e,t){return t instanceof Ns?e.findIndex((function(e){return e instanceof Ns&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Zf=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Jf=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},Xf=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var $f,ep,tp,np=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;wa((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),rp=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=a,this._key="mc-".concat(re()),this.filter=null!=u?u:new Eo,this._channel=o,this._syncRange=new Mf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+Xf,this._limit=l||go;var h=Uf.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Qf(n,i._channel);if(s>=0){switch(i._channel=n[s],r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;ds.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;ds.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}wa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(r),lu(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),wa((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(ii(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=ds.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=Ff.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=qf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=jf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Rf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof ha)switch(n.stateType){case aa.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Yf(this._messages,l)<0){Yf(this._unsentMessages,l)<0&&o.push(l);var h=Jf(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ns){Yf(this._unsentMessages,l)<0&&Yf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=Yf(this._messages,l);if(d<0){var f=Yf(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=Jf(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Ns){var m=Yf(this._unsentMessages,l);m<0?Yf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}ii(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Df(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=Zf(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=Zf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=Zf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=Yf(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=Yf(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=Jf(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Ns){var f=Yf(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Df(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return ii(n)&&i.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Uf.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Ei.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,x,C,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=Uf.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,Ea((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,x,C,T,S,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=ds.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new zf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Vf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,x=m.nextMessages,C=void 0===x?[]:x,T=m.nextHasmore,S=m.isContinuousNextMessages,g?wa((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,M=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,N].concat(_(C.map((function(e){return e.createdAt}))))),h.dispatch(new oi({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new oi({messages:C,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,A),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(M,A)),IA&&this._nextFill.start(A));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=ds.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,x=0,C=0;C=p&&x++;this._hasPrevious=w>=f,this._hasNext=x>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof A&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+Xf,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){Uf.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=null,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new Lf(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)}},{key:"initialize",value:function(n){var r=this,a=new np;this._messages=[],this._unsentMessages=[],this._syncRange=new Mf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),xa((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(M(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=ds.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(M(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=ds.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,xa((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,xa((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Uf.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=ds.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=Uf.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),ap={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},sp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},ip={hidePreviousMessages:!1,allowAutoUnhide:!0},op=function(e){return L("boolean",e.hidePreviousMessages)&&L("boolean",e.allowAutoUnhide)},up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),cp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new ld(e,t)}))),s}return s(n)}(Oe);e.MutedMemberFilter=void 0,($f=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",$f.MUTED="muted",$f.UNMUTED="unmuted",e.MemberListOrder=void 0,(ep=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",ep.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(tp=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",tp.JOINED="joined_only",tp.INVITED="invited_only",tp.INVITED_BY_FRIEND="invited_by_friend",tp.INVITED_BY_NON_FRIEND="invited_by_non_friend";var lp,hp,dp,fp=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new up(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(cp),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),pp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),vp=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Vp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Oe),_p=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a.params=ue({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(Ae),mp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),gp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),yp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Ae),kp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Ae),bp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(Oe),Ep=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Ae),wp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),xp=Object.assign(Object.assign({},wl),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Cp=function(e){return xl(e)&&L("number",e.scheduledAt,!0)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Tp=Object.assign(Object.assign({},Cl),{scheduledAt:null}),Sp=function(e){return Tl(e)&&L("number",e.scheduledAt,!0)},Ip=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Np=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),Mp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),Op=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Ae),Up=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Ae),Rp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Lp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Pp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),Fp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),Gp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Vs(e,a.message),s}return s(n)}(qa),qp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ue({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(Ae),Hp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).hasMore=null,s.token=null;var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new Gp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Oe),jp=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new qp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Hp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.CountPreference=void 0,(lp=e.CountPreference||(e.CountPreference={})).ALL="all",lp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",lp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",lp.OFF="off",e.MutedState=void 0,(hp=e.MutedState||(e.MutedState={})).MUTED="muted",hp.UNMUTED="unmuted",e.HiddenState=void 0,(dp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",dp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",dp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var zp,Vp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,x,C,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new ld(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new Ja(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(x=n.unread_mention_count)&&void 0!==x?x:0),s.pinnedMessageIds=null!==(C=n.pinned_message_ids)&&void 0!==C?C:[],s.lastPinnedMessage=n.latest_pinned_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Ns&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ds.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=ds.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Ka(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rp(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jp(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof ld?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Ns&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ds.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)>=e.createdAt&&s.push(i))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)0&&void 0!==arguments[0]&&arguments[0],n=ds.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new hd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:ld.payloadify(a),ts:s})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=ds.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Rd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Ld),c=u.channel,this._update(c),s.dispatch(new hu({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ap),n),Ya(sp(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new _p(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(mp),h=l.channel,this._update(h),i.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e.every((function(e){return e instanceof Ja}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new af({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(sf),l=c.channel,this._update(l),s.dispatch(new hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new $d({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(ef),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new nf({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new pp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(vp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new uf({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Uf.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Uf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Fi,a=ds.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(t){var s=Uf.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Uf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Ns&&(s=ds.of(this._iid),s.dispatcher.dispatch(new ci({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ip),n),Ya(op(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new pf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(vf),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new yp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new gp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new lf({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(hf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)}))),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new df({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new mf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new yf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Vo),e),Ya(function(e){return Mo(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new wi;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Tp),n),Ya(Sp(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Mp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ph),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Bo),e),Ya(function(e){return To(e)&&L("number",e.scheduledAt)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new wi;return ka(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);wa((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),q(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},xp),n),Ya(Cp(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Ip(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=ds.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Np),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Ap({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Op({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Lp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Dp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Up({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Rp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.CountPreference,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new kp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(bp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Ep({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(wp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Pp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Fp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!q(e.file)){t.next=11;break}return r=ds.of(this._iid),a=r.requestQueue,s=new ps({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(vs),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return ld.payloadify(e)})),last_message:zs(e.lastMessage),inviter:e.inviter?Ja.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:zs(e.lastPinnedMessage)})):null}}]),u}($h),Bp={},Qp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=u;var c,l=ds.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Rf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,s=Uf.of(this._iid),t.next=9,s.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,o=i.channels,u=i.token,r.hasNext=o.length>=this._limit&&!!u,r.nextToken=u,this._metadata.token=u,(a=this._metadata.range).extends.apply(a,_(o.map((function(e){return e.createdAt})))),this._metadata.completed=!r.hasNext,f.debug("channel background sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:r.hasNext=!1,r.nextToken="";case 33:return t.abrupt("return",r);case 34:case"end":return t.stop()}}),n,this,[[5,22]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Mf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=ds.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Bp[this._iid])}}],[{key:"of",value:function(e){return Bp[e]||(Bp[e]=new n({_iid:e})),Bp[e].ref++,Bp[e]}},{key:"clear",value:function(e){Bp[e]&&(Bp[e].close(),delete Bp[e])}}]),n}(),Kp={},Wp=function(){function n(a){var s=this,i=a._iid;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var o,u=ds.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Rf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",this._metadata.token),t.prev=4,a=Uf.of(this._iid),t.next=8,a.getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return s=t.sent,i=s.hasMore,o=s.token,r.hasNext=i,r.nextToken=o,this._metadata.token=o,c.debug("channel changelog sync progress",r),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Kp[this._iid])}}],[{key:"of",value:function(e){return Kp[e]||(Kp[e]=new n({_iid:e})),Kp[e].ref++,Kp[e]}},{key:"clear",value:function(e){Kp[e]&&(Kp[e].close(),delete Kp[e])}}]),n}(),Yp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new fd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=ds.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Qp.of(a),this._backgroundSync.resume()),this._changelogSync=Wp.of(a),this._changelogSync.resume(),Uf.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(lu(t)){var n=e.filter((function(e){return i.filter.match(e,h.userId)})),r=e.filter((function(e){return!i.filter.match(e,h.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)}}),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof ha&&(e.stateType===aa.CONNECTED?i._isGetRemoteChannelsSucceeded||b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===aa.LOGOUT&&i.dispose())}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Kf(this.channels,h,this.order),f=d.place,p=d.oldPosition;if(-1===p)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==p?this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(p,1),this.channels.splice(p0){var v,_=y(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=Qf(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}lu(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new Lf(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return lu(n)&&s.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),r=this.channels.length>0?Bf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=ds.of(this._iid),a=r.cacheContext,s=[],!a.localCacheEnabled||!this._backgroundSync.completed){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=s.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:s=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Uf.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),Zp=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=ce.GET,s.path=fe,s.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b}),s}return s(a)}(Ae),Jp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Vp(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe);e.MembershipFilter=void 0,(zp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",zp.JOINED="joined";var Xp,$p=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=ds.of(this._iid),a=r.requestQueue,r.dispatcher,s=new Zp(Object.assign(Object.assign({},this),{token:this._token})),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(Jp),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),ev=s((function e(){r(this,e),this.onUserMuted=qe,this.onUserUnmuted=qe,this.onUserBanned=qe,this.onUserUnbanned=qe,this.onChannelChanged=qe,this.onChannelDeleted=qe,this.onChannelFrozen=qe,this.onChannelUnfrozen=qe,this.onOperatorUpdated=qe,this.onChannelMemberCountChanged=qe,this.onMetaDataCreated=qe,this.onMetaDataUpdated=qe,this.onMetaDataDeleted=qe,this.onMetaCounterCreated=qe,this.onMetaCounterUpdated=qe,this.onMetaCounterDeleted=qe,this.onMessageReceived=qe,this.onMessageUpdated=qe,this.onMessageDeleted=qe,this.onMentionReceived=qe,this.onReactionUpdated=qe,this.onThreadInfoUpdated=qe})),tv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=qe,e.onUserLeft=qe,e.onUserReceivedInvitation=qe,e.onUserDeclinedInvitation=qe,e.onChannelHidden=qe,e.onUnreadMemberStatusUpdated=qe,e.onUndeliveredMemberStatusUpdated=qe,e.onTypingStatusUpdated=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e.onPinnedMessageUpdated=qe,e}return s(n)}(ev),nv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(tv),rv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ee),a.params=ue({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h}),a}return s(n)}(Ae),av=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),sv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new rv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(av),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),iv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Uf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Nf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new $p(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new sv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Ya(L("string",e)&&t instanceof nv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Ya(L("string",e)).throw(A.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},yd),n),Ya(L("string",e)&&kd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},yd),n),Ya(L("number",e)&&kd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},bd),e),Ya(Ed(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},md),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Ya(F("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),ov=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(n=this._channels.get(e))&&void 0!==n?n:null);case 1:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(qa),uv={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},cv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},lv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?_e:ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),hv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Sv(e,a),s}return s(n)}(Oe),dv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=ce.POST,a.path=ve,a.params=ue({channel_url:s,cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h}),a}return s(n)}(Ae),fv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),pv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(Xd),vv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),_v=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(Xd),mv={},gv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),mv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new ov(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof Ge)a._handleEvent(e);else if(e instanceof ha&&e.stateType===aa.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),mv[e]=this),mv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Wa(e);return new Sv(this._iid,Sv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,x,C,T,S,I,N,A,O,U,R,L,D,P,F,G,q,H,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,xe,Ce,Te,Se,Ie,Ne,Me,Ae,Oe,Ue,Re,Le,De=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as(wh):"FILE"===n.code?a=n.as(Ws):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(xf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived(u,i),o&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(Ch):"FEDI"===n.code?c=n.as(Sh):"AEDI"===n.code&&(c=n.as(Cf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated(f,h),d>0&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(Nh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Tf),E=k.channelUrl,w=k.channelType,x=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:C=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(C.url)&&a.onReactionUpdated(C,x)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(Sf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(Ef),A=N.openChannelMemberCounts,O=[],U=y(A),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(H=n.as(If),j=H.event,z=H.status,V=H.channelUrl,B=H.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new hi({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(z===Ls?function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as(Xh),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new di({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as(Xd),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===dd.CHANNEL_ENTER?94:r.t2===dd.CHANNEL_EXIT?101:r.t2===dd.CHANNEL_OPERATOR_UPDATE?108:r.t2===dd.USER_CHANNEL_MUTE||r.t2===dd.USER_CHANNEL_UNMUTE?116:r.t2===dd.USER_CHANNEL_BAN||r.t2===dd.USER_CHANNEL_UNBAN?123:r.t2===dd.CHANNEL_FREEZE||r.t2===dd.CHANNEL_UNFREEZE?130:r.t2===dd.CHANNEL_DELETED?138:r.t2===dd.CHANNEL_PROP_CHANGED?145:r.t2===dd.CHANNEL_META_DATA_CHANGED?150:r.t2===dd.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(pv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return se=r.sent,ie=n.as(_v),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,he=n.as(bf),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(le,de)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===dd.USER_CHANNEL_MUTE,ve=n.as(pe?lh:dh),_e=ve.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted(fe,_e):e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===dd.USER_CHANNEL_BAN,ye=n.as(ge?ph:_h),ke=ye.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned(me,ke):e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return be=r.sent,Ee=n.as(gh),we=Ee.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen(be):e.onChannelUnfrozen(be)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return xe=r.sent,r.next=143,this.removeChannelsFromCache([xe.url]);case 143:return wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return Ce=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Ce)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(Yl),Ie=Se.created,Ne=Se.updated,Me=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Me&&Te._removeFromCachedMetaData(Me,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated(Te,Ne),Me&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Ae=r.sent,Oe=n.as(ih),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted(Ae,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!M(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),a=new lv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(hv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},uv),e),Ya(cv(r)).throw(A.invalidParameters),a=new dv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(hv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return mv[e]}}]),n}(),yv={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},kv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},bv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=ce.GET,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Ae),Ev=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new El(e,t)})),s}return s(n)}(Oe),wv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new bv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ev),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),xv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a.params=ue({cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l}),a}return s(n)}(Ae),Cv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Sv(e,a),s}return s(n)}(Oe),Tv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Sv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new Ja(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Ka(this)}},{key:"isOperator",value:function(e){return e instanceof Ja?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new wv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=gv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new fv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(pv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),gv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new vv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(_v),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),gv.of(this._iid).setExitedToCache(this),Ei.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},yv),e),Ya(kv(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new xv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Cv),c=u.channel,this._update(c),l=gv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},yv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Tv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=gv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},$h.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Ja.payloadify(e)}))})):null}}]),u}($h),Iv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=qe,e.onUserExited=qe,e.onChannelParticipantCountChanged=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e}return s(n)}(ev),Nv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Iv),Mv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=ce.GET,a.path=ve,a.params=ue({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(Ae),Av=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Sv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe),Ov=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Mv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Av),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=gv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),Uv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new gv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ov(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},uv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(fs);Xp=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function Gv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function qv(e){return"string"!=typeof e&&(e=String(e)),e}function Hv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Dv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function jv(e){this.map={},e instanceof jv?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function zv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Vv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Bv(e){var t=new FileReader,n=Vv(t);return t.readAsArrayBuffer(e),n}function Qv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Kv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Dv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Dv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Dv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Dv.arrayBuffer&&Dv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Qv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Dv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Fv(e))?this._bodyArrayBuffer=Qv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Dv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Dv.blob&&(this.blob=function(){var e=zv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=zv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Bv)}),this.text=function(){var e,t,n,r=zv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Vv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Zv(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function Jv(e,t){if(!(this instanceof Jv))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new jv(t.headers),this.url=t.url||"",this._initBody(e)}Yv.prototype.clone=function(){return new Yv(this,{body:this._bodyInit})},Kv.call(Yv.prototype),Kv.call(Jv.prototype),Jv.prototype.clone=function(){return new Jv(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new jv(this.headers),url:this.url})},Jv.error=function(){var e=new Jv(null,{status:0,statusText:""});return e.type="error",e};var Xv=[301,302,303,307,308];Jv.redirect=function(e,t){if(-1===Xv.indexOf(t))throw new RangeError("Invalid status code");return new Jv(null,{status:t,headers:{location:e}})};var $v=Lv.DOMException;try{new $v}catch(an){($v=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),$v.prototype.constructor=$v}function e_(e,t){return new Promise((function(r,a){var s=new Yv(e,t);if(s.signal&&s.signal.aborted)return a(new $v("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new jv,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new Jv(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new $v("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Lv.location.href?Lv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Dv.blob?i.responseType="blob":Dv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof jv?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,qv(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}e_.polyfill=!0,Lv.fetch||(Lv.fetch=e_,Lv.Headers=jv,Lv.Request=Yv,Lv.Response=Jv);var t_=Object.freeze({__proto__:null});return e.AdminMessage=Us,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=mc,e.BannedUserListQuery=Pl,e.BaseChannel=$h,e.BaseMessage=Is,e.BlockedUserListQuery=kc,e.CachedChannelInfo=ee,e.ConnectionHandler=vo,e.Emoji=ac,e.EmojiCategory=sc,e.EmojiContainer=ic,e.FileMessage=Bs,e.FriendListQuery=wc,e.GroupChannel=Vp,e.GroupChannelCollection=Yp,e.GroupChannelEventContext=Lf,e.GroupChannelFilter=fd,e.GroupChannelHandler=nv,e.GroupChannelListQuery=Nf,e.GroupChannelModule=iv,e.LocalCacheConfig=te,e.Member=ld,e.MemberListQuery=fp,e.MemoryStore=cl,e.MessageCollection=rp,e.MessageCollectionInitHandler=np,e.MessageEventContext=Df,e.MessageFilter=Eo,e.MessageMetaArray=bs,e.MessageModule=Gi,e.MessageRequestHandler=wi,e.MessageSearchQuery=Ui,e.MultipleFilesMessage=js,e.MultipleFilesMessageRequestHandler=Fi,e.MutedUserListQuery=Rl,e.OGImage=Es,e.OGMetaData=ws,e.OpenChannel=Sv,e.OpenChannelHandler=Nv,e.OpenChannelListQuery=Ov,e.OpenChannelModule=Uv,e.OperatorListQuery=Al,e.Participant=El,e.ParticipantListQuery=wv,e.PinnedMessage=Gp,e.PinnedMessageListQuery=jp,e.Plugin=Rs,e.PreviousMessageListQuery=Li,e.PublicGroupChannelListQuery=$p,e.Reaction=ks,e.ReactionEvent=ys,e.ReadStatus=hd,e.RestrictedUser=bl,e.RestrictionInfo=kl,e.ScheduledMessageListQuery=sv,e.SendbirdChat=td,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Cs,e.SessionHandler=po,e.ThreadInfo=_s,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=Ms,e.UIKitConfigInfo=Pa,e.UploadedFileInfo=Hs,e.User=Ja,e.UserEventHandler=_o,e.UserMessage=qs,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;C(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.9.1",x=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var C,T,S,I,N,M=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===E.SESSION_REVOKED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:E.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},q=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null===e)return!0;var t=L("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(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator,u=void 0===o?null:o;r(this,e),this._customClearOrderComparator=null,this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),u?(this._clearOrder=i,this._customClearOrderComparator=u):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),ne=function(){function e(){r(this,e),this.sessionKey=null,this.authToken=null}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),re=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)}))},ae=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=re()}return s(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),se=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new ae({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new ae({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),ie=function(){function e(){r(this,e),this._dispatcher=new se}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),oe=s((function e(){r(this,e)})),ue=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};e.ChannelType=void 0,(B=e.ChannelType||(e.ChannelType={})).BASE="base",B.GROUP="group",B.OPEN="open",e.Role=void 0,(Q=e.Role||(e.Role={})).OPERATOR="operator",Q.NONE="none",e.MessageType=void 0,(K=e.MessageType||(e.MessageType={})).BASE="base",K.USER="user",K.FILE="file",K.ADMIN="admin",e.MessageTypeFilter=void 0,(W=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",W.USER="MESG",W.FILE="FILE",W.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(Y||(Y={})),e.MentionType=void 0,(Z=e.MentionType||(e.MentionType={})).USERS="users",Z.CHANNEL="channel",e.ReplyType=void 0,(J=e.ReplyType||(e.ReplyType={})).ALL="all",J.NONE="none",J.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(X=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",X.SUPPRESS="suppress",e.SendingStatus=void 0,($=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",$.SCHEDULED="scheduled",$.SUCCEEDED="succeeded",$.FAILED="failed",$.CANCELED="canceled";var ce,le="v3",he="/".concat(le,"/users"),de="/".concat(le,"/storage/file"),fe="/".concat(le,"/group_channels"),pe="/".concat(le,"/sdk/group_channels"),ve="/".concat(le,"/open_channels"),_e="/".concat(le,"/sdk/open_channels"),me="/".concat(le,"/search"),ge="/".concat(le,"/report"),ye="/".concat(le,"/emojis"),ke="/".concat(le,"/emoji_categories"),be="/".concat(le,"/polls"),Ee="/".concat(le,"/scheduled_messages"),we="/".concat(le,"/sdk/ui_kit/configuration"),xe="/".concat(le,"/sdk/statistics"),Ce=function(t){switch(t){case e.ChannelType.GROUP:return fe;case e.ChannelType.OPEN:return ve;default:return null}},Te=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ge,"/group_channels");case e.ChannelType.OPEN:return"".concat(ge,"/open_channels");default:return null}},Se=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ie=function(e,t,n){var r=Se(e.mentionType,e.mentionedUserIds,n),a=Se(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},Ne=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(o in t){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;q(u)?i.append(c,u,null!==(s=u.name)&&void 0!==s?s:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?i.append(c,String(u)):i=e(u,i,c)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(ce||(ce={}));var Me,Ae=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=re(),e}return s(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ue(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ue(this.params);return Object.keys(e).some((function(t){return q(e[t])}))?Ne(e):JSON.stringify(e)}}]),a}(oe),Oe=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(oe),Ue=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}(oe),Re=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.expires_in,i=e.reason,o=void 0===i?E.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case E.SESSION_KEY_EXPIRED:case E.SESSION_TOKEN_EXPIRED:case E.SESSION_REVOKED:a.error=new A({code:o})}return a}return s(n,[{key:"invalidateSessionToken",get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError}}]),n}(oe),Le=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}(oe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Me||(Me={}));var De=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ue({stat_type:e.type,ts:e.createdAt,data:ue(e.data)})}}]),e}(),Pe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Fe=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Ue&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Pe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(x.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(x.OS_VERSION,",").concat(x.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Le(new De({type:Me.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![ce.GET,ce.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:null),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Rv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return t_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),t.abrupt("return",new Oe(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:v.code})),this._statLogApiResult(e,d,v),v;case 37:throw _=A.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof A)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw A.requestCanceled;case 54:throw m=A.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),Ge=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=s?s.req_id:o,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),qe=function(){};function He(e){let t=e.length;for(;--t>=0;)e[t]=0}const je=256,ze=286,Ve=30,Be=15,Qe=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ke=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),We=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ze=new Array(576);He(Ze);const Je=new Array(60);He(Je);const Xe=new Array(512);He(Xe);const $e=new Array(256);He($e);const et=new Array(29);He(et);const tt=new Array(Ve);function nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let rt,at,st;function it(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}He(tt);const ot=e=>e<256?Xe[e]:Xe[256+(e>>>7)],ut=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{ct(e,n[2*t],n[2*t+1])},ht=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},dt=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Be;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ht(r[t]++,t))}},ft=e=>{let t;for(t=0;t{e.bi_valid>8?ut(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},vt=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?lt(e,a,t):(s=$e[a],lt(e,s+je+1,t),i=Qe[s],0!==i&&(a-=et[s],ct(e,a,i)),r--,s=ot(r),lt(e,s,n),i=Ke[s],0!==i&&(r-=tt[s],ct(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)_t(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],_t(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,_t(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=Be;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),dt(n,c,e.bl_count)},yt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{ct(e,0+(r?1:0),3),pt(e),ut(e,n),ut(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var wt=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(yt(e,e.dyn_ltree,e.l_desc.max_code),yt(e,e.dyn_dtree,e.d_desc.max_code),gt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Et(e,t,n,r):4===e.strategy||s===a?(ct(e,2+(r?1:0),3),mt(e,Ze,Je)):(ct(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(ct(e,t-257,5),ct(e,n-1,5),ct(e,r-4,4),a=0;a{bt||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(et[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*($e[n]+je+1)]++,e.dyn_dtree[2*ot(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),lt(e,256,Ze),(e=>{16===e.bi_valid?(ut(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ct=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Tt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var St=(e,t,n,r)=>{const a=Tt,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},It={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Nt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mt,_tr_stored_block:At,_tr_flush_block:Ot,_tr_tally:Ut,_tr_align:Rt}=xt,{Z_NO_FLUSH:Lt,Z_PARTIAL_FLUSH:Dt,Z_FULL_FLUSH:Pt,Z_FINISH:Ft,Z_BLOCK:Gt,Z_OK:qt,Z_STREAM_END:Ht,Z_STREAM_ERROR:jt,Z_DATA_ERROR:zt,Z_BUF_ERROR:Vt,Z_DEFAULT_COMPRESSION:Bt,Z_FILTERED:Qt,Z_HUFFMAN_ONLY:Kt,Z_RLE:Wt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Zt,Z_UNKNOWN:Jt,Z_DEFLATED:Xt}=Nt,$t=258,en=262,tn=42,nn=113,rn=666,an=(e,t)=>(e.msg=It[t],t),sn=e=>2*e-(e>4?9:0),on=e=>{let t=e.length;for(;--t>=0;)e[t]=0},un=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let cn=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},hn=(e,t)=>{Ot(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ln(e.strm)},dn=(e,t)=>{e.pending_buf[e.pending++]=t},fn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},pn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ct(e.adler,t,a,n):2===e.state.wrap&&(e.adler=St(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},vn=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-en?e.strstart-(e.w_size-en):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+$t;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},_n=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-en)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),un(e),r+=t),0===e.strm.avail_in)break;if(n=pn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=cn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=cn(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(pn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(pn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===Ft)&&t!==Lt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Ft&&0===e.strm.avail_in&&n===r?1:0,At(e,e.block_start,n,i),e.block_start+=n,ln(e.strm)),i?3:1)},gn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-en&&(e.match_length=vn(e,n)),e.match_length>=3)if(r=Ut(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=cn(e,e.ins_h,e.window[e.strstart+1]);else r=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=Ut(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(hn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Ut(e,0,e.window[e.strstart-1]),r&&hn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Ut(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2};function kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const bn=[new kn(0,0,0,0,mn),new kn(4,4,8,4,gn),new kn(4,5,16,8,gn),new kn(4,6,32,32,gn),new kn(4,4,16,16,yn),new kn(8,16,32,32,yn),new kn(8,16,128,128,yn),new kn(8,32,128,256,yn),new kn(32,128,258,1024,yn),new kn(32,258,258,4096,yn)];function En(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Xt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),on(this.dyn_ltree),on(this.dyn_dtree),on(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),on(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),on(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==tn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==nn&&t.status!==rn?1:0},xn=e=>{if(wn(e))return an(e,jt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?tn:nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mt(t),qt},Cn=e=>{const t=xn(e);var n;return t===qt&&((n=e.state).window_size=2*n.w_size,on(n.head),n.max_lazy_match=bn[n.level].max_lazy,n.good_match=bn[n.level].good_length,n.nice_match=bn[n.level].nice_length,n.max_chain_length=bn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Tn=(e,t,n,r,a,s)=>{if(!e)return jt;let i=1;if(t===Bt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==Xt||r<8||r>15||t<0||t>9||s<0||s>Yt||8===r&&1!==i)return an(e,jt);8===r&&(r=9);const o=new En;return e.state=o,o.strm=e,o.status=tn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Tn(e,t,Xt,15,8,Zt),deflateInit2:Tn,deflateReset:Cn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>wn(e)||2!==e.state.wrap?jt:(e.state.gzhead=t,qt),deflate:(e,t)=>{if(wn(e)||t>Gt||t<0)return e?an(e,jt):jt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===rn&&t!==Ft)return an(e,0===e.avail_out?Vt:jt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(ln(e),0===e.avail_out)return n.last_flush=-1,qt}else if(0===e.avail_in&&sn(t)<=sn(r)&&t!==Ft)return an(e,Vt);if(n.status===rn&&0!==e.avail_in)return an(e,Vt);if(n.status===tn&&0===n.wrap&&(n.status=nn),n.status===tn){let t=Xt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Kt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,fn(n,t),0!==n.strstart&&(fn(n,e.adler>>>16),fn(n,65535&e.adler)),e.adler=1,n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(57===n.status)if(e.adler=0,dn(n,31),dn(n,139),dn(n,8),n.gzhead)dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),dn(n,255&n.gzhead.time),dn(n,n.gzhead.time>>8&255),dn(n,n.gzhead.time>>16&255),dn(n,n.gzhead.time>>24&255),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(dn(n,255&n.gzhead.extra.length),dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=St(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,3),n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,ln(e),0!==n.pending)return n.last_flush=-1,qt;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(ln(e),0!==n.pending))return n.last_flush=-1,qt;dn(n,255&e.adler),dn(n,e.adler>>8&255),e.adler=0}if(n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(0!==e.avail_in||0!==n.lookahead||t!==Lt&&n.status!==rn){let r=0===n.level?mn(n,t):n.strategy===Kt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(_n(e),0===e.lookahead)){if(t===Lt)return 1;break}if(e.match_length=0,n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Wt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=$t){if(_n(e),e.lookahead<=$t&&t===Lt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+$t;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Ut(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):bn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=rn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),qt;if(2===r&&(t===Dt?Rt(n):t!==Gt&&(At(n,0,0,!1),t===Pt&&(on(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ln(e),0===e.avail_out))return n.last_flush=-1,qt}return t!==Ft?qt:n.wrap<=0?Ht:(2===n.wrap?(dn(n,255&e.adler),dn(n,e.adler>>8&255),dn(n,e.adler>>16&255),dn(n,e.adler>>24&255),dn(n,255&e.total_in),dn(n,e.total_in>>8&255),dn(n,e.total_in>>16&255),dn(n,e.total_in>>24&255)):(fn(n,e.adler>>>16),fn(n,65535&e.adler)),ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?qt:Ht)},deflateEnd:e=>{if(wn(e))return jt;const t=e.state.status;return e.state=null,t===nn?an(e,zt):qt},deflateSetDictionary:(e,t)=>{let n=t.length;if(wn(e))return jt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==tn||r.lookahead)return jt;if(1===a&&(e.adler=Ct(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(on(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,_n(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=cn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_n(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,qt},deflateInfo:"pako deflate (from Nodeca project)"};const In=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Nn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)In(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;An[254]=An[254]=1;var On={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Mn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+An[e[n]]>t?n:t}};var Un=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Rn=Object.prototype.toString,{Z_NO_FLUSH:Ln,Z_SYNC_FLUSH:Dn,Z_FULL_FLUSH:Pn,Z_FINISH:Fn,Z_OK:Gn,Z_STREAM_END:qn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:zn}=Nt;function Vn(e){this.options=Nn.assign({level:Hn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Sn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Gn)throw new Error(It[n]);if(t.header&&Sn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?On.string2buf(t.dictionary):"[object ArrayBuffer]"===Rn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Sn.deflateSetDictionary(this.strm,e),n!==Gn)throw new Error(It[n]);this._dict_set=!0}}function Bn(e,t){const n=new Vn(t);if(n.push(e,!0),n.err)throw n.msg||It[n.err];return n.result}Vn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Fn:Ln,"string"==typeof e?n.input=On.string2buf(e):"[object ArrayBuffer]"===Rn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===Dn||s===Pn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Sn.deflate(n,s),a===qn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Sn.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Gn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Vn.prototype.onData=function(e){this.chunks.push(e)},Vn.prototype.onEnd=function(e){e===Gn&&(this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qn={Deflate:Vn,deflate:Bn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bn(e,t)},constants:Nt};const Kn=16209;var Wn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C;const T=e.state;n=e.next_in,x=e.input,r=n+(e.avail_in-5),a=e.next_out,C=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)C[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=x[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=Kn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=Kn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)C[a++]=w[E++],C[a++]=w[E++],C[a++]=w[E++],k-=3;k&&(C[a++]=w[E++],k>1&&(C[a++]=w[E++]))}else{E=a-b;do{C[a++]=C[E++],C[a++]=C[E++],C[a++]=C[E++],k-=3}while(k>2);k&&(C[a++]=C[E++],k>1&&(C[a++]=C[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,x=0,C=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Yn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=A[i[_]-p],M=C[i[_]-p]):(N=96,M=0),c=1<>b)+l]=I<<24|N<<16|M|0}while(0!==l);for(c=1<>=1;if(0!==c?(x&=c-1,x+=c):x=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(x&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=x&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==x&&(a[f+x]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:tr,Z_BLOCK:nr,Z_TREES:rr,Z_OK:ar,Z_STREAM_END:sr,Z_NEED_DICT:ir,Z_STREAM_ERROR:or,Z_DATA_ERROR:ur,Z_MEM_ERROR:cr,Z_BUF_ERROR:lr,Z_DEFLATED:hr}=Nt,dr=16180,fr=16190,pr=16191,vr=16192,_r=16194,mr=16199,gr=16200,yr=16206,kr=16209,br=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Er(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const wr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(wr(e))return or;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=dr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,ar},Cr=e=>{if(wr(e))return or;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Tr=(e,t)=>{let n;if(wr(e))return or;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?or:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Cr(e))},Sr=(e,t)=>{if(!e)return or;const n=new Er;e.state=n,n.strm=e,n.window=null,n.mode=dr;const r=Tr(e,t);return r!==ar&&(e.state=null),r};let Ir,Nr,Mr=!0;const Ar=e=>{if(Mr){Ir=new Int32Array(512),Nr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(er(1,e.lens,0,288,Ir,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;er(2,e.lens,0,32,Nr,0,e.work,{bits:5}),Mr=!1}e.lencode=Ir,e.lenbits=9,e.distcode=Nr,e.distbits=5},Or=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveSr(e,15),inflateInit2:Sr,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x=0;const C=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(wr(e)||!e.output||!e.input&&0!==e.avail_in)return or;n=e.state,n.mode===pr&&(n.mode=vr),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=ar;e:for(;;)switch(n.mode){case dr:if(0===n.wrap){n.mode=vr;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=kr;break}if((15&c)!==hr){e.msg="unknown compression method",n.mode=kr;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,C[2]=c>>>16&255,C[3]=c>>>24&255,n.check=St(n.check,C,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=pr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Ar(n),n.mode=mr,t===rr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=kr;break}if(n.length=65535&c,c=0,l=0,n.mode=_r,t===rr)break e;case _r:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=pr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=er(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=kr;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=kr;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=kr;break}if(n.lenbits=9,T={bits:n.lenbits},w=er(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=kr;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=er(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=kr;break}if(n.mode=mr,t===rr)break e;case mr:n.mode=gr;case gr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Wn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===pr&&(n.back=-1);break}for(n.back=0;x=n.lencode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=pr;break}if(64&m){e.msg="invalid literal/length code",n.mode=kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;x=n.distcode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=gr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=gr;break;case yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(wr(e))return or;let t=e.state;return t.window&&(t.window=null),e.state=null,ar},inflateGetHeader:(e,t)=>{if(wr(e))return or;const n=e.state;return 0==(2&n.wrap)?or:(n.head=t,t.done=!1,ar)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return wr(e)?or:(r=e.state,0!==r.wrap&&r.mode!==fr?or:r.mode===fr&&(a=1,a=Ct(a,t,n,0),a!==r.check)?ur:(s=Or(e,t,n,n),s?(r.mode=16210,cr):(r.havedict=1,ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var Rr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Lr=Object.prototype.toString,{Z_NO_FLUSH:Dr,Z_FINISH:Pr,Z_OK:Fr,Z_STREAM_END:Gr,Z_NEED_DICT:qr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:jr,Z_MEM_ERROR:zr}=Nt;function Vr(e){this.options=Nn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Ur.inflateInit2(this.strm,t.windowBits);if(n!==Fr)throw new Error(It[n]);if(this.header=new Rr,Ur.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=On.string2buf(t.dictionary):"[object ArrayBuffer]"===Lr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ur.inflateSetDictionary(this.strm,t.dictionary),n!==Fr)))throw new Error(It[n])}function Br(e,t){const n=new Vr(t);if(n.push(e),n.err)throw n.msg||It[n.err];return n.result}Vr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Pr:Dr,"[object ArrayBuffer]"===Lr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=Ur.inflate(n,i),s===qr&&a&&(s=Ur.inflateSetDictionary(n,a),s===Fr?s=Ur.inflate(n,i):s===jr&&(s=qr));n.avail_in>0&&s===Gr&&n.state.wrap>0&&0!==e[n.next_in];)Ur.inflateReset(n),s=Ur.inflate(n,i);switch(s){case Hr:case jr:case qr:case zr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===Gr))if("string"===this.options.to){let e=On.utf8border(n.output,n.next_out),t=n.next_out-e,a=On.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Fr||0!==o){if(s===Gr)return s=Ur.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Vr.prototype.onData=function(e){this.chunks.push(e)},Vr.prototype.onEnd=function(e){e===Fr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qr={Inflate:Vr,inflate:Br,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Br(e,t)},ungzip:Br,constants:Nt};const{Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr}=Qn,{Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea}=Qr;var ta,na={Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr,Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea,constants:Nt},ra=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=na.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",ta.OPEN="OPEN",ta.CLOSED="CLOSED";var aa,sa=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ge.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Re(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ra(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",A.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=qe,t._ws.onmessage=qe,t._ws.onerror=qe,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw A.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(se),ia=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:re(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(oe),oa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}(oe),ua=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),ca=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new Fe(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new sa(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new oa(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new ua,e.ackRequired){a=null,s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(null,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve(null)}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ae)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof ia)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(aa||(aa={}));var la,ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}(oe),da=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ca(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof ha){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case aa.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case aa.INITIALIZED:case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:case aa.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(A.connectionClosed):r.reject(A.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===aa.CONNECTING||this._currentConnectionStateType===aa.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ia)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new ua,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof Ae)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new ua,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=A.connectionRequired,this._logger.debug("fail api request",s),s;case 37:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(A.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),fa="sendbird@devicetokens",pa=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),va=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(he,"/").concat(s,"/session_key"),a.method=ce.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Ae),_a=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?null:o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(ia),ma=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(Oe),ga=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=s.new_key,i.error=s.error?new A(s.error):null,i}return s(n)}(Ge),ya=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),ka=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},ba=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Ea=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ba;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e){return new _a({authToken:e,expiringSession:!0,requestId:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ga),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new va({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,Ea((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(ma),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==aa.CONNECTED){t.next=25;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=25;break}if(!n){t.next=25;break}return t.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=21;break}return t.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),t.next=24;break;case 21:return t.next=23,this.clear();case 23:this.close();case 24:return t.abrupt("return");case 25:return t.prev=25,t.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),t.next=53;break;case 31:if(t.prev=31,t.t1=t.catch(25),!this._isSessionRelatedError(t.t1)){t.next=52;break}if(!n){t.next=49;break}return t.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=44;break}return t.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),t.next=47;break;case 44:return t.next=46,this.clear();case 46:this.close();case 47:t.next=50;break;case 49:throw t.t1;case 50:t.next=53;break;case 52:throw t.t1;case 53:case"end":return t.stop()}}),r,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ua;return wa((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)})):n.resolve(null);case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Ca.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(fa);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(fa,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Ca.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Sa=function(){function e(){r(this,e),this.type=aa.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),Ia=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new Ra,r);case 6:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Sa),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ma=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=aa.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Aa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Aa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,Ea((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new Oa,r);case 10:wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),M(n.t0)){n.next=23;break}if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ma({autoReconnect:!1}),r);case 20:wa((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new ua,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ua({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ma({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Na,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Aa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ma({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ua=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=aa.CONNECTING,t.name="connecting",t._authToken="",t._haltConnect=null,t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ea((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new Oa,r);case 8:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),M(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ra,r);case 20:wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ma({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Na,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Ra=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ua({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Sa),La=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(ia),Da=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new La;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Pa=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return s(e,null,[{key:"payloadify",value:function(e){return ue({last_updated_at:e.lastUpdatedAt})}}]),e}(),Fa=1048576,Ga=function(){function e(){var t,n,a,s,i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Fa:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(s=o.allow_sdk_log_ingestion)||void 0===s||s,this.uikitConfigInfo=new Pa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Fa,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Pa.payloadify(e.uikitConfigInfo):void 0}}}]),e}(),qa=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),Ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Ae),ja=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(Oe),za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Ae),Va=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(Oe),Ba=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Ae),Qa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata"),a}return s(n)}(Ae),Ka=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Wa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Ya=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(la=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",la.OFFLINE="offline",la.NON_AVAILABLE="nonavailable";var Za,Ja=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Ka(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ha({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ja),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new za({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Va),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ba({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Qa({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),u}(qa),Xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}(oe),$a=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ga(n),this.user=new Ja(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ds.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Xa({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},Ja.payloadify(e.user)),Ga.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),es=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new $a(e,s),i.deviceTokenLastDeletedAt=s.device_token_last_deleted_at,i.key=s.key,i.ekey=null!==(o=s.ekey)&&void 0!==o?o:"",i.error=s.error?new A(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=ds.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw A.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),a}(Ge),ts=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}(oe),ns=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.connectionHandlers,c=t.sessionManager,l=t.websocketClient,h=t.dispatcher,d=t.logger,f=t.entryState,p=void 0===f?new Ra:f;return r(this,a),(s=n.call(this))._currentState=null,s._loginTimer=null,s._logiProcessingTimer=null,s._unresolvedLogi=null,s._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=i,s.cacheContext=o,s.connectionHandlers=u,s._sessionManager=c,s._websocketClient=l,s._dispatcher=h,s._logger=d,s._currentState=p,s.sdkState.websocket.pingerDisabled||(s._pinger=new Da({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:d})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(es))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=null,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof es&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=null,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=this.sdkState,r=n.appId,a=n.appVersion,s=n.userId,i=n.extensions,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!this.sdkState.extensions.sb_uikit,h=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",d=i.sb_uikit?"u".concat(i.sb_uikit):"",f="JS/c".concat(x.SDK_VERSION,"/").concat(h,"/").concat(d);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(x.OS_VERSION),"&sv=").concat(encodeURIComponent(x.SDK_VERSION),"&ai=").concat(r).concat(a?"&av=".concat(a):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(t)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new ts({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new Le(new De({type:Me.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(A.connectionCanceled)),r=this._url(e),a=new ua,this._connectionRequestQueue.push(a),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=null,s._rejectConnectionRequest(A.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(r)),t.abrupt("return",a.promise);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(es.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),a}(se),rs=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new ns(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===aa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===aa.CONNECTING||e.type===aa.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),as=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(De),ss=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return De.payloadify(e)}))},a}return s(n)}(Ae),is=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Za||(Za={}));var os,us=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Za.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t.commandEventContext=null,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=re(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Za.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.API_RESULT||e.type===Me.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Za.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return De.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof as){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new ss({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof A)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Za.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Za.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new De({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,ka(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Le){var t=e.statLog;s.put(t)}else if(e instanceof ts){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Za.ENABLED:Za.COLLECT_ONLY:s.enabledState=Za.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Za.DISABLED){t.next=7;break}return e instanceof as?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof as&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=is(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)}}]),a}(se);e.LogLevel=void 0,(os=e.LogLevel||(e.LogLevel={}))[os.NONE=0]="NONE",os[os.VERBOSE=1]="VERBOSE",os[os.DEBUG=2]="DEBUG",os[os.INFO=3]="INFO",os[os.WARN=4]="WARN",os[os.ERROR=5]="ERROR";var cs,ls=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?ue({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),bs=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return e?ue({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),Es=function(){function e(t){r(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return e?ue({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}(),ws=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new Es(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Es.payloadify(e.defaultImage):null}):null}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),this.name=null,this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?ue({name:e.name,volume:e.volume}):null}}]),e}(),Cs=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).role=null,i.isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),a}(Ja);e.ScheduledStatus=void 0,(ms=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",ms.SENT="sent",ms.FAILED="failed",ms.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(gs||(gs={}));var Ts,Ss=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Is=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,a),(i=n.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null;var E=s.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new Ja(i._iid,e)})):null;var w=s.mentioned_user_ids;i.mentionedUserIds=null!=w?w:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=s.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=s.thread_info?new _s(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new ks(e)})):[];for(var x=null!==(f=s.metaarray)&&void 0!==f?f:{},C=null!==(p=s.metaarray_key_order)&&void 0!==p?p:Object.keys(x).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Ss(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return Ja.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?_s.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ks.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return bs.payloadify(e)})),og_tag:ws.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:xs.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}},{key:"_getParentMessageInfoPayload",value:function(e){return e?ue({type:e.messageType,ts:e.createdAt,user:Cs.payloadify(e.sender),message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}):null}}]),a}(qa),Ns=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=s.user?new Cs(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=s.scheduled_status,s.scheduled_status){case gs.SENT:case gs.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case gs.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case gs.FAILED:case gs.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case gs.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Cs.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),a}(Is),Ms=function(){function e(t){var n,a;r(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?ue({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),As={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Os=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Us=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).message=null,s.translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info,d=ue(Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}));s.parentMessage=Vs(t,d)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Is),Rs=function(){function e(t){var n,a;r(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ts||(Ts={}));var Ls="removed",Ds=function(e){switch(e){case Ts.OPEN:return Ts.OPEN;case Ts.CLOSED:return Ts.CLOSED}},Ps=function(e){return!e||e.text&&L("string",e.text)},Fs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),n}(qa),Gs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=Ts.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=Ds(a.status))&&void 0!==h?h:Ts.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Fs(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Ds(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Fs(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Ka(this)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Fs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),n}(qa),qs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Rs(e)})):[],s._poll=n.poll?new Gs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info,_=ue(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}));s.parentMessage=Vs(t,ue(_))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Rs.payloadify(e)})),poll:Gs.payloadify(e._poll),parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Hs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c;r(this,n),(s=t.call(this,e)).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=a.url,s.fileName=null!==(i=a.file_name)&&void 0!==i?i:null,s.mimeType=null!==(o=a.file_type)&&void 0!==o?o:null,s.fileSize=null!==(u=a.file_size)&&void 0!==u?u:0;var l=ds.of(s._iid).sessionManager;return s._requireAuth=null!==(c=a.require_auth)&&void 0!==c&&c,s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(l.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}}}]),n}(qa),js=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.fileInfoList=null!==(o=null===(i=n.files)||void 0===i?void 0:i.map((function(e){return new Hs(t,e)})))&&void 0!==o?o:[],s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var d=n.parent_message_info,f=Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(h=d.file)||void 0===h?void 0:h.require_auth});s.parentMessage=Vs(t,f)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ns),zs=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return qs.payloadify(t);case e.MessageType.FILE:return Bs.payloadify(t);case e.MessageType.ADMIN:return Us.payloadify(t)}return null},Vs=function(e,t){switch(t.type){case"MESG":return new qs(e,t);case"FILE":return js._isMultipleFilesMessagePayload(t)?new js(e,t):new Bs(e,t);case"ADMM":case"BRDM":return new Us(e,t)}return null},Bs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.name=null,s.size=0,s.type=null,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=null!==(i=n.file)&&void 0!==i?i:null;s.plainUrl=(null!==(c=null!==(o=null==E?void 0:E.url)&&void 0!==o?o:n.url)&&void 0!==c?c:"").split("?auth=")[0],s.name=null!==(h=null!==(l=null==E?void 0:E.name)&&void 0!==l?l:n.name)&&void 0!==h?h:"File",s.size=null!==(f=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==f?f:0,s.data=null!==(v=null!==(p=null==E?void 0:E.data)&&void 0!==p?p:n.custom)&&void 0!==v?v:"",s.type=E?null!==(_=E.type)&&void 0!==_?_:"":null!==(m=n.type)&&void 0!==m?m:"";var w=ds.of(s._iid).sessionManager;if(s.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var x=n.parent_message_info,C=ue(Object.assign(Object.assign({},x),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:x.file,url:null===(k=x.file)||void 0===k?void 0:k.url,require_auth:null===(b=x.file)||void 0===b?void 0:b.require_auth}));s.parentMessage=Vs(t,C)}return s}return s(u,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Qs=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ue({channel_url:t.channelUrl,files:Zs(t.files),url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),Ks=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a),s=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=ce.POST,s.path="".concat(Ce(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue({message_type:e.MessageType.FILE,user_id:t.userId,files:Zs(t.files),url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return Ms.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return bs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),s}return s(a)}(Ae),Ws=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new js(e,s):new Bs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Ys=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;r(this,n),(s=t.call(this,e,a)).message=a.files&&a.files.length>=2?new js(e,a):new Bs(e,a);var u=ds.of(e).sdkState;return s.isMentioned=Se(s.message.mentionType,null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:s.message.mentionedUsers.map((function(e){return e.userId})),u.userId),s.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,s}return s(n)}(Oe);function Zs(e){return null==e?void 0:e.map((function(e){var t,n;return ue({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return Ms.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var Js;!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"}(Js||(Js={}));var Xs=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===aa.CONNECTED||this._connectionState===aa.CONNECTING||this._connectionState===aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return s=new Qs(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ws),u=o.message,t.abrupt("return",u);case 10:return c=new Ks(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,h=l.as(Ys),d=h.message,t.abrupt("return",d);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._queueMap.get(e.url))){t.next=57;break}if(r.isResolving){t.next=56;break}r.isResolving=!0,a=[],s=!0,i=y(r.messageQueue),t.prev=7,i.s();case 9:if((o=i.n()).done){t.next=39;break}u=o.value,t.t0=u.state,t.next=t.t0===Js.PENDING||t.t0===Js.UPLOADING?14:t.t0===Js.UPLOADED?17:t.t0===Js.FAILED?35:37;break;case 14:return s=!1,a.push(u),t.abrupt("break",37);case 17:if(!s){t.next=33;break}return t.prev=18,u.state=Js.SENDING,t.next=22,this._sendFileMessage(e,u);case 22:return c=t.sent,u.deferred.resolve(c),t.next=26,ka(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),u.deferred.reject(t.t1);case 31:t.next=34;break;case 33:a.push(u);case 34:return t.abrupt("break",37);case 35:return u.deferred.reject(u.error.code===E.REQUEST_CANCELED?A.fileUploadCanceled:u.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(l=r.isResolveRequestPending,r.messageQueue=a,r.isResolving=!1,r.isResolveRequestPending=!1,!l){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:r.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),n,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._queueMap.get(e.url),!(s=a.messageQueue.find((function(e){return e.state===Js.PENDING})))){t.next=29;break}if(!s.multipleFileUploadInfo){t.next=18;break}if(i=s.multipleFileUploadInfo,o=i.uploadIndex,u=i.uploadCount,c=i.requestHandler,l=s.params,h=l.fileInfoList[o],!q(h.file)||(null===(n=h._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=12;break}return t.next=10,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 10:t.next=13;break;case 12:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new ps({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(vs),h=l.url,d=l.fileSize,f=void 0===d?r.fileSize:d,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size,r.fileUrl=h,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new ps({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:h=t.sent,d=h.as(vs),f=d.url,p=d.fileSize,v=void 0===p?c.fileSize:p,_=d.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=d.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(s=c.mimeType)&&void 0!==s?s:c.file.type,c.fileSize=null!==(i=c.fileSize)&&void 0!==i?i:c.file.size,c.file=null,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),o=this._queueMap.get(e.url),u=new ua,c={requestId:n,params:r,state:Js.PENDING,deferred:u},$s(r)&&(l={uploadIndex:0,uploadCount:r.fileInfoList.length,requestHandler:a},c.multipleFileUploadInfo=l),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Js.PENDING:i.state=Js.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Js.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function $s(e){return"fileInfoList"in e}var ei,ti={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ni=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},ri={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ai=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(ei=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ei.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ei.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ei.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ei.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ei.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ei.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ei.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ei.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ei.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ei.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ei.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ei.REQUEST_MESSAGE="REQUEST_MESSAGE",ei.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ei.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ei.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ei.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ei.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ei.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ei.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ei.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ei.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ei.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ei.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ei.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ei.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var si,ii=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},oi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a}return s(n)}(oe),ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}(oe),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}(oe),hi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=null,a.source=null,a.event=s,a.source=i,a}return s(n)}(oe),fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(Ae),pi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,f=e.isInclusive,p=e.reverse,v=e.messageTypeFilter,_=e.customTypesFilter,m=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,k=e.includeReactions,b=e.parentMessageId,E=e.includeThreadInfo,w=e.includeParentMessageInfo,x=e.showSubchannelMessagesOnly,C=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue({is_sdk:!0,prev_limit:h,next_limit:d,include:f,reverse:p,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:_,sender_ids:m,include_reply_type:g,with_sorted_meta_array:y,include_reactions:k,parent_message_id:b,include_thread_info:E,include_parent_message_info:w,show_subchannel_message_only:x,include_poll_details:!0,checking_continuous_messages:C}),a}return s(n)}(Ae),_i=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),mi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(Ae),gi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Vs(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),yi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Ae),ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),bi={},Ei=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new Xs(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),bi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Wa(t);switch(n.messageType){case e.MessageType.USER:return new qs(this._iid,qs.payloadify(n));case e.MessageType.FILE:return js._isMultipleFilesMessageSerializedData(n)?new js(this._iid,js.payloadify(n)):new Bs(this._iid,Bs.payloadify(n));case e.MessageType.ADMIN:return new Us(this._iid,Us.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return ue({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,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Wa(e);return new Cs(this._iid,Cs.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new fi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(pi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new yi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(ki),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new vi(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(_i),d=h.messages,this._dispatcher.dispatch(new oi({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new vi(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},As),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(_i),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new oi({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new mi(ue(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ri),s))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(gi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new oi({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ui({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return bi[e]}}]),n}(),wi=function(){function t(){r(this,t),this._onPending=qe,this._onFailed=qe,this._onSucceeded=qe}return s(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),xi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new _s(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(qa),Ci={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ti=function(t){return L("string",t.channelUrl)&&L("string",t.channelType)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)},Si=function(){function e(t,n){var a;r(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),Ii=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(me,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(Ae),Ni=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Vs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Oe);e.MessageSearchOrder=void 0,(si=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",si.TIMESTAMP="ts";var Mi,Ai,Oi,Ui=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ii(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ni),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Ri=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(Si),Li=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=Ei.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),Di={channelUrl:null,scheduledMessageId:0},Pi=function(e){return L("string",e.channelUrl)&&L("number",e.scheduledMessageId)},Fi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=qe,e}return s(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(wi),Gi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ei(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ci),e),Ya(Ti(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Di),e),Ya(Pi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.POST,a.path=be,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),Hi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),ji=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),zi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),Bi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Fs(e,a),s}return s(n)}(Oe),Qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Ae),Ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new Gs(e,t):null}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),Wi={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Yi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Zi={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Ji=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&L("number",t.pollOptionId)},Xi={channelUrl:null,channelType:null,pollId:null},$i=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},eo={},to=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,eo[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Wa(e);return new Gs(this._iid,Gs.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya($i(e)).throw(A.invalidParameters),r=new ji(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(zi),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Yi(e)).throw(A.invalidParameters),r=e.data,a=new qi(Object.assign(Object.assign({},e),{data:r})),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Hi),o=i.poll,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Ji(e)).throw(A.invalidParameters),r=new Vi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Bi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Qi(ue({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Ki),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new li({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return eo[e]}}]),n}(),no=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),ro=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),ao=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=be,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Ae),so=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Gs(e,t)})),s.token=a.next,s}return s(n)}(Oe),io=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new ao(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(so),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),oo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Ae),uo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new Ja(e,t)})),s.token=a.next,s}return s(n)}(Oe),co=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new oo(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(uo),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),lo=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new to(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Wi),e),Ya(Yi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Xi),e),Ya($i(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Zi),e),Ya(Ji(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(fs),ho={profileImage:null,profileUrl:null,nickname:null},fo=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},po=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=qe,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=qe,this.onSessionRefreshed=qe,this.onSessionClosed=qe}))),vo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=qe,this.onReconnectStarted=qe,this.onReconnectSucceeded=qe,this.onReconnectFailed=qe,this.onDisconnected=qe}))),_o=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=qe,this.onTotalUnreadMessageCountUpdated=qe}))),mo="GroupChannel",go=100,yo="Message";e.GroupChannelListOrder=void 0,(Mi=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Mi.CHRONOLOGICAL="chronological",Mi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Mi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ai=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Oi=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Oi.SCHEDULED_AT="scheduled_at";var ko,bo=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Eo=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ns))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ns&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ko||(ko={}));var wo,xo=function(e){switch(e){case ko.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ko.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Co={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},To=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(Ja,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(bs,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(xs,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},So=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Io=Object.assign(Object.assign({},Co),{message:null,translationTargetLanguages:null,pollId:null}),No=function(e){var t;return ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},Mo=function(e){return To(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(wo||(wo={}));var Ao,Oo,Uo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Ro=function(e){return e===wo.BLOB||e===wo.FILE},Lo=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Do=Object.assign(Object.assign({},Co),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Po=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&q(r)&&(e.messageParams.file=r),e.messageParams):ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=r?r:null===(t=e.messageParams)||void 0===t?void 0:t.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},Fo=function(e){return To(e)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Go=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},qo=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"}(Ao||(Ao={})),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"}(Oo||(Oo={}));var Ho,jo={},zo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Ao.PROCESSING,this._queue=[],this._activationQueue=[],jo[t]&&!a.forceCreate||(this.nodeId=qo(),this.key=t,Go()&&(a.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=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Oo.NEWNODE:n._sendSync();break;case Oo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Oo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,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:Oo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Oo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Oo.REQUEST_LOCK:n._requestLock(t);break;case Oo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Oo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Oo.REMOVENODE)}))),jo[t]=this),jo[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Ao.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:qo(),key:this.key,op:e,data:n.data,ts:Date.now()};return Go()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Oo.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&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Oo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Oo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Ao.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Oo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Oo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Oo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),Vo=Object.assign(Object.assign({},Io),{scheduledAt:null}),Bo=Object.assign(Object.assign({},Co),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Qo=Object.assign(Object.assign({},Co),{fileInfoList:null}),Ko=function(e){return(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Wo="UnsentMessage",Yo={},Zo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,Yo[e]=d(s),s._mutex=new zo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Wo)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw A.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof qs?(e.messageParams&&(n.messageParams=So(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},So(t)),{scheduledAt:t.scheduledAt})))):e instanceof Bs?(e.messageParams&&(n.messageParams=Lo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Lo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof js&&e.messageParams&&(n.messageParams=function(e){return e?ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Ei.of(this._iid),a=this._deserialize(e),!e.messageParams){n.next=23;break}if(!(a instanceof qs)){n.next=8;break}s=e.messageParams,a.messageParams=r.buildUserMessageCreateParamsFromSerializedData(s,a),n.next=23;break;case 8:if(!(a instanceof Bs)){n.next=17;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!Ro(i.fileType)){n.next=14;break}return n.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=n.sent;case 14:a.messageParams=r.buildFileMessageCreateParamsFromSerializedData(i,a),n.next=23;break;case 17:if(!(a instanceof js)){n.next=23;break}if(!(o=e.messageParams)||!o.fileInfoList){n.next=23;break}return a.messageParams=r.buildMultipleFilesMessageCreateParamsFromSerializedData(o,a),n.next=23,Promise.all(a.messageParams.fileInfoList.map((function(e){return b(l,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Ro(null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)){t.next=4;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:e.file=t.sent;case 4:case"end":return t.stop()}}),n,this)})))})));case 23:if(!(a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){n.next=36;break}if(!(a instanceof qs)){n.next=29;break}u=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=r.buildScheduledUserMessageCreateParamsFromSerializedData(u,a),n.next=36;break;case 29:if(!(a instanceof Bs)){n.next=36;break}if(!(c=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof c.fileKey||!Ro(c.fileType)){n.next=35;break}return n.next=34,this.collection.getBlob(c.fileKey);case 34:c.file=n.sent;case 35:a.scheduledInfo.scheduledMessageParams=r.buildScheduledFileMessageCreateParamsFromSerializedData(c,a);case 36:return n.abrupt("return",a);case 37:case"end":return n.stop()}}),n,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=void 0===n?null:n,a=e.filter,s=void 0===a?new Eo:a,i=e.order,o=void 0===i?ko.CHANNEL_LATEST:i,u=e.sendingStatus,c=void 0===u?null:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d;return b(this,void 0,void 0,t().mark((function e(){var n,a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=xo(o),a={"/where":function(e){return!!(o!==ko.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&s.match(d._deserialize(e))}},r&&(a.channelUrl=r),c&&(a.sendingStatus=c),i={where:a,index:n,backward:h},e.next=8,this.collection.query(i);case 8:return u=e.sent,e.next=11,u.fetch({});case 11:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return b(d,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:ko.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs||e instanceof js)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof Bs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Uo(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=wo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Uo(s.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=n.sent,s.fileKey=i,s.fileType=wo.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof js)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return b(u,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(s=n.file)||!Uo(s)){t.next=8;break}return t.next=4,this.collection.saveBlob(s,this._getFileInfoBlobKey(e.reqId,r));case 4:i=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=i,n._uploadedMetaData.fileType=wo.BLOB;case 8:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Yo[e]}}]),a}(qa),Jo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:mo,keyName:"url",index:[bo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),bo(e.GroupChannelListOrder.CHRONOLOGICAL),bo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:yo,keyName:"messageId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:Wo,keyName:"reqId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},Xo={},$o=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,Xo[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(yo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?go:a,i=e.filter,o=void 0===i?new Eo:i,u=e.order,c=void 0===u?ko.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d,p=e.isPollOnly,v=void 0!==p&&p;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=xo(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case ko.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:ko.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:xo(ko.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:xo(ko.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=xo(ko.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Uo(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Xo[e]}}]),a}(qa),eu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},tu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?eu:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._pauseDelayTimer=null,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"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")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(se),nu=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:ce.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}(oe),au={},su=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,au[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof ha)switch(e.stateType){case aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=Zo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new ru({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return au[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Ho||(Ho={}));var iu,ou=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new Ja(e,r),blockee:new Ja(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new Ja(e,t)})):[]}}}]),e}(),uu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}(oe);e.GroupChannelEventSource=void 0,(iu=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",iu.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",iu.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",iu.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",iu.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",iu.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",iu.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",iu.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",iu.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",iu.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",iu.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",iu.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",iu.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",iu.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",iu.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",iu.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",iu.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",iu.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",iu.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",iu.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",iu.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",iu.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",iu.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",iu.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",iu.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",iu.REQUEST_CHANNEL="REQUEST_CHANNEL",iu.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",iu.REFRESH_CHANNEL="REFRESH_CHANNEL",iu.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",iu.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",iu.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var cu,lu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.data,u=void 0===o?null:o;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.data=u,a}return s(n)}(oe),du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new ou(s),i}return s(n)}(Ge),vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=void 0===i?null:i,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,f=void 0===d?null:d;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s)),a.params=ue({nickname:o,profile_url:c,profile_file:h,preferred_languages:f}),a}return s(n)}(Ae),_u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=null,s.user=new Ja(e,Object.assign({},a)),s}return s(n)}(Oe),mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Ae),gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(Ae),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Ae),Eu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Ae),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Ae),xu=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(Oe),Cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Ae),Tu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Su=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Ae),Iu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Mu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(Ae),Ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Ru=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Ae),Du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Ae),Fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),Hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Ae),ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Ae),Vu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Ae),Qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Ae),Wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new Ja(e,t)})),updatedUsers:a.updated.map((function(t){return new Ja(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Oe),Yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(Ae),Zu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Oe),Ju=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Ae),Xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),$u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s}return s(n)}(Oe),ec=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Ae),nc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(Oe),rc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Ae),ac=s((function e(t){r(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),sc=s((function e(t){var n,a,s;r(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(n=t.id)&&void 0!==n?n:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(s=t.url)&&void 0!==s?s:"",this.emojis=t.emojis?t.emojis.map((function(e){return new ac(e)})):[]})),ic=s((function e(t){r(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new sc(e)})):[]})),oc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path=ke,e}return s(n)}(Ae),uc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new ic(a),s}return s(n)}(Oe),cc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Ae),lc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new sc(a),s}return s(n)}(Oe),hc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ye,"/").concat(s),a}return s(n)}(Ae),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new ac(a),s}return s(n)}(Oe),fc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path="".concat(we),e}return s(n)}(Ae),pc=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;r(this,n);var o=null!=a?a:{};return(s=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return s(n)}(Oe),vc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=he,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Ae),_c=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),mc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new vc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(_c),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),gc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Ae),yc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),kc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new gc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(yc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),bc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Ae),Ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),wc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new bc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(Ec),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),xc={},Cc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),xc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,xc[n]=this),xc[n]}return s(e,null,[{key:"get",value:function(e){return xc[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_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",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"}(cu||(cu={}));var Tc,Sc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?cu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:cu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:cu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:cu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:cu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:cu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:cu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:cu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:cu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:cu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:cu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:cu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:cu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:cu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:cu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:cu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:cu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:cu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:cu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:cu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:cu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Tc||(Tc={}));var Ic,Nc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw Sc.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},Mc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Sc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Ac=function(e,t){for(var n=0,r=0;r>>0)%t},Oc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Uc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(Mc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Mc(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Mc(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Mc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Rc=function(){},Lc=function(){return Promise.resolve()},Dc=function(e){return e},Pc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ic||(Ic={}));var Fc,Gc,qc,Hc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Dc:u,l=t.backward,h=void 0===l?Lc:l,d=t.forward,f=void 0===d?Lc:d,p=t.complete,v=void 0===p?Rc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),jc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Mc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Mc(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw Sc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Wc(e,t)).concat(n,".").concat(r)},Zc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Yc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o}});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Wc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Fc||(Fc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Gc||(Gc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(qc||(qc={}));var Jc,Xc=[Gc.PENDING,Gc.VOLATILE],$c={},el=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),$c[n]||(this.dbname=n,this._items=[],this._limit=s,$c[n]=this),$c[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qc.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,state:r===qc.PERSISTENT?Gc.PERSISTENT:Gc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===qc.PERSISTENT&&(s.state=Gc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===qc.PERSISTENT&&(r.state=Gc.PERSISTENT),t!==qc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Xc.includes(this._items[t].state)&&Xc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Gc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Gc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Gc.VOLATILE}))}}],[{key:"get",value:function(e){return $c[e]}}]),e}(),tl=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Bc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Bc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=el.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=el.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Ac)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Kc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=el.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=nl.createFromCacheItem(i),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Cc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=el.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?nl.createFromCacheItem(u):new nl({blockId:s,keyName:this.keyName,items:[],limit:i}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Kc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:el.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),al={},sl=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Bc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return al[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Fc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Fc.ERROR,this.indexerKey,(function(){return n.abort()}))),al[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Sc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Mc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=el.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,qc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Kc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,qc.NO_CACHE);case 17:if(c=e.sent,l=nl.createFromCacheItem(c)){h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Nc(this._origin);case 35:al[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return el.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete al[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Nc(this._origin)}},{key:"abort",value:function(){this._table=Nc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in al)delete al[e]}}]),e}(),il=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Tc.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return sl.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new zo(function(e,t){return"".concat(Bc(e,t),".lock")}(a,s)),this._blobContainer=new Zc({dbname:a,collectionName:s,store:c}),this._transaction=new tl({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Tc.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=Cc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new rl({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return sl.createKey(e)})),u=a?a.indexes.map((function(e){return sl.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(sl.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Qc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Tc.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Tc.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=sl.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===sl.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Sc.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Qc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Sc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Nc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Sc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new zc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Sc.collectionNotReady}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new jc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Uc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)&&i.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw Sc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),ul={},cl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return ul[this.dbname]},set:function(e){ul[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ul[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(ul[this.dbname]));case 4:throw Sc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=6;break}return t.next=3,Oc(this.delay);case 3:return t.abrupt("return",ul[this.dbname][e]?Object.assign({key:e},ul[this.dbname][e]):null);case 6:throw Sc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,ul[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,ul[this.dbname][s]&&delete ul[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,ul[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(s=a.set())){t.next=5;break}throw s;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=12;break}if(i=s.value,!(o=this.observer[i.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Oc(this.delay);case 2:ul[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ol),ll="NestDBStore",hl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=ll,e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return s(a,[{key:"_getObjectStore",value:function(e){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);throw Sc.storeNotInitialized}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,n){var a=r._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!Go()){e.next=13;break}if(!(Go()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Sc.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Sc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Sc.storeNotAvailableInPrivateBrowsing)}else t(Sc.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Sc.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,new Promise((function(t,n){if(r._indexedDb){var a=r._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ll,{keyPath:"key"})})),a.addEventListener("success",(function(e){return t(e.target.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}else n(Sc.storeNotAvailable)}));case 5:this._database=t.sent;case 6:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),a}(ol),dl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new bl(e,t)}))),s}return s(n)}(Oe),Rl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ol(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ul),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),Ll=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Ae),Dl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new bl(e,t.user)}))),s}return s(n)}(Oe),Pl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ll(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Dl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.ReportCategory=void 0,(yl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",yl.HARASSING="harassing",yl.SUSPICIOUS="suspicious",yl.INAPPROPRIATE="inappropriate";var Fl,Gl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),Hl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Ae),jl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=null,s.endAt=null,s.remainingDuration=null,s.description=null;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(Oe),zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Ae),Vl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Bl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Ae),Ql=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(Oe),Kl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Ae),Wl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Yl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),Zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Ae),Jl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),Xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Ae),$l=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),eh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Ae),th=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),nh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Ae),rh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),ah=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Ae),sh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),oh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params=null,a}return s(n)}(Ae),uh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params=null,a}return s(n)}(Ae),ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Ae),lh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),hh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),dh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),fh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Ae),ph=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).memberCount=null,i.joinedMemberCount=null,i.user=new bl(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(Ge),vh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),_h=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new bl(e,s.data),i}return s(n)}(Ge),mh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Ae),gh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(Ge),yh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Ae),kh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=ce.POST,s.path="".concat(ge,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(Ae),bh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(Ae),Eh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ue({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),wh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"MESG",s)).message=new qs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),xh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(s=t.appleCriticalAlertOptions)||void 0===s?void 0:s.serialize(),poll_id:t.pollId})})}return s(a)}(ia),Ch=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new qs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Th=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return s(a)}(ia),Sh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Bs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Ih=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Ae),Nh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(Ge),Mh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Ah=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(a),s}return s(n)}(Oe),Oh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Uh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(Object.assign({},a)),s}return s(n)}(Oe),Rh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Ae),Lh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Dh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),Ph=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Fh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),Gh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),qh=function(e){return L("string",e.title,!0)&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Hh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),jh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),zh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Vh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Ae),Bh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Qh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Ae),Kh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Wh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Ae),Yh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Zh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Jh=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ue({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(ia),Xh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=null,i.channelUrl=null,i.channelType=null,i.event=new ro(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),$h=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).url="",s.channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new Ja(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(s._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=ue(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Al(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Pl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Li(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Gl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new ql({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Hl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(jl),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new zl({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Vl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new zl({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Vl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new Bl({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Ql),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new Kl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Wl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Zl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(Jl),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Xl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as($l),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new eh({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(th),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new eh({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(th),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new nh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(rh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(sh),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(sh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new ah({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(sh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new oh({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new uh({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new ch({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new hh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new fh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new vh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new mh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new mh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("number",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("string",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=ds.of(this._iid).sessionManager;return ue({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return bs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:Cs.payloadify(s.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return Ja.payloadify(e)}))})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new qs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,s,i,o,u,c,l=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(s=t.file)||void 0===s?void 0:s.name,size:null!==(i=t.fileSize)&&void 0!==i?i:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),h=new Bs(this._iid,l);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),s=new js(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Io),e);return Ya(Mo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=a,c=Date.now(),l=new wi;return u||(u=this._generateRequestId(),ka(2).then((function(){var a=new Eh(Object.assign(Object.assign({},n),{channelUrl:r.url,channelType:r.channelType,reqId:u}));o.send(a).then((function(n){var a=n.as(wh).message;i.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var s=r._createPendingUserMessage(n,u,c),o=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(s,a,o),i.dispatch(new oi({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a,s));case 1:case"end":return e.stop()}}),e)})))}))}))}));var s=r._createPendingUserMessage(n,u,c);i.dispatch(new oi({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,s));case 1:case"end":return e.stop()}}),e)})))}))}))),l}},{key:"_autoResendUserMessage",value:function(e){return Ya(e instanceof qs).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ua,s=null!==(n=e.messageParams)&&void 0!==n?n:No(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cl),n),Ya(L("number",e)&&Tl(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new xh(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ch),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Ya(!r.poll).throw(A.notSupportedError),c=new ua,l=null!==(a=r.messageParams)&&void 0!==a?a:Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Rh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Lh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=ds.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();ka(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Dh(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(Ph).message;wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Do),e);return Ya(Fo(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t=Object.assign(Object.assign({},Qo),e),n=ds.of(this._iid);Ya(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return To(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Ko(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Ya(!r).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new wi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingFileMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingFileMessage(n,o,u),l=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(i,a,l),s.dispatch(new oi({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_autoResendFileMessage",value:function(e){Ya(e instanceof Bs).throw(A.invalidParameters);var t=ds.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new Fi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingMultipleFilesMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n,c).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingMultipleFilesMessage(n,o,u);r._markMessageAsFailed(i,a),s.dispatch(new oi({messages:[i],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=ds.of(this._iid).requestQueue,o=new Fh(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(Gh).message;wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(M(i))throw i;ka(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Ya(e.every((function(e){return Fo(Object.assign(Object.assign({},Do),e))}))).throw(A.invalidParameters);var t,n=new wi,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||q(n)||q(null===(r=e.messageParams)||void 0===r?void 0:r.file),Ya(e instanceof Bs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ua,o=Po(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Sl),n),Ya(L("number",e)&&Il(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Th(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Sh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=Ei.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof Bs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ua,l=Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1}),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=ds.of(this._iid),a=r.requestQueue,s=new Ih({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Mh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Ah),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Oh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Uh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new xh({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Ch),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Th({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Sh),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new yh({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ja&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new kh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ns&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new bh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&qh(n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Hh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(jh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new zh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Vh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Bh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Qh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Kh),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=new Wh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Yh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Zh({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new Jh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as(Xh),d=h.event,u.dispatch(new di({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)).throw(A.invalidParameters),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e,!0)),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new io(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new co(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:Ja.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),u}(qa),ed=null,td=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=a;var o=ds.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new nu({logger:f,connectionDelegate:{reconnect:function(){var t=ds.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){ds.of(e).connectionManager.disconnect()}}});var _=new su(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new tu({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof ha){if(n.stateType===aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof Ge){if("USEV"===n.code){var r=n.as(pu).event;if(r.category===Ho.FRIEND_DISCOVERED){var a=ou.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof oa){var s=ds.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof Xa?c.preference.set(i._getUserProfileCacheKey(u.userId),$a.payloadify(n.userProfile)):n instanceof Re&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return ds.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return ds.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=ds.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return ds.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ds.of(this._iid).logger.level},set:function(e){ds.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ds.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ds.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ds.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ds.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ds.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ds.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=ds.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof cl?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ds.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.store=new cl,t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=ds.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=30;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=27;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==Jc.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new gl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Jo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Jo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new uu(this._iid,{userId:e}));case 15:a.userId=e,t.next=25;break;case 18:return t.prev=18,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=23,this._safeInitializeStore(c);case 23:throw a.userId=e,A.databaseError;case 25:t.next=30;break;case 27:return t.next=29,this._safeInitializeStore(c);case 29:a.userId=e;case 30:case"end":return t.stop()}}),n,this,[[6,18]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),r=$o.of(this._iid),a=Zo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,t.prev=2,t.next=5,this.initializeCache(e);case 5:c=ds.of(this._iid),c.dispatcher.dispatch(new fu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=ds.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 14:return t.next=16,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 16:return t.next=18,i.preference.get(this._getUserProfileCacheKey(e));case 18:return(d=t.sent)&&new $a(this._iid,d).apply(),t.next=22,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 22:return t.prev=22,t.next=25,o.connect(n);case 25:return t.prev=25,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.finish(25);case 29:return t.abrupt("return",this.currentUser);case 30:case"end":return t.stop()}}),r,this,[[2,9],[22,,25,29]])})))}},{key:"reconnect",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Ya(e instanceof po).throw(A.invalidParameters),ds.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Ya(L("string",e)&&t instanceof _o).throw(A.invalidParameters),ds.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ds.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ds.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Ya(L("string",e)&&t instanceof vo).throw(A.invalidParameters),ds.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ds.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ds.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new kc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ui(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new io(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new co(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Wa(e);return new Ja(this._iid,Ja.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ho),e),Ya(fo(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new vu(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(_u),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new vu({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(_u),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new gu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new ku({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new Eu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new mu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new yu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new bu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Cu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tu),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Su({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Iu),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Nu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Mu),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=ds.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Au({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Ou),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Uu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ru),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Lu({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Du),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new wu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(xu),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Gu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(qu).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Hu({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(ju).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new zu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Vu).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTemplate,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Bu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Qu).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Pu({userId:a.userId,blockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,unblockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ku({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Wu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(nc),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new rc({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Yu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Zu),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ju({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as($u),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ec({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new oc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(uc),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new cc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(lc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new hc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(dc),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),Ya(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new fc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(pc),o=i.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=void 0===r?null:r,s=e.modules,i=void 0===s?[]:s,o=e.options,u=void 0===o?new H:o,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,m=e.localCacheEnabled,g=void 0!==m&&m,y=e.localCacheConfig,k=void 0===y?new te:y,b=e.localCacheEncryption,E=e.useAsyncStorageStore,w=void 0===E?null:E,x=e.appStateToggleEnabled,C=void 0===x||x;if(!ed||p){var T="su-".concat(re()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},I=new cl({encryption:S});l||(I=Pe()?w?new dl({AsyncStorage:w,encryption:S}):new cl({encryption:S}):new hl({encryption:S})),new ds(T,{appId:t,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:I,encryption:S,logLevel:v,localCacheEnabled:g,localCacheConfig:k,debugMode:l,appStateToggleEnabled:C});var N=[new Gi,new lo],M=new n(T,u,[].concat(_(i),N));return ed||(ed=M),M}return ed}},{key:"instance",get:function(){return ed}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Fl=e.MemberState||(e.MemberState={})).NONE="none",Fl.JOINED="joined",Fl.INVITED="invited",Fl.LEFT="left";var nd,rd,ad,sd,id,od,ud,cd,ld=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,Object.prototype.hasOwnProperty.call(s,"is_muted")&&(i.isMuted=s.is_muted),Object.prototype.hasOwnProperty.call(s,"is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),Object.prototype.hasOwnProperty.call(s,"is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),a}(bl),hd=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new Ja(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(qa);e.PublicChannelFilter=void 0,(nd=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",nd.PUBLIC="public",nd.PRIVATE="private",e.MyMemberStateFilter=void 0,(rd=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",rd.JOINED="joined_only",rd.INVITED="invited_only",rd.INVITED_BY_FRIEND="invited_by_friend",rd.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(ad=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",ad.SUPER="super",ad.NON_SUPER="nonsuper",ad.BROADCAST_ONLY="broadcast_only",ad.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(sd=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",sd.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(id=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",id.UNHIDDEN="unhidden_only",id.HIDDEN="hidden_only",id.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",id.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(od=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",od.OPERATOR="operator",od.NONOPERATOR="nonoperator",e.QueryType=void 0,(ud=e.QueryType||(e.QueryType={})).AND="AND",ud.OR="OR",e.GroupChannelSearchField=void 0,(cd=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",cd.CHANNEL_NAME="channel_name";var dd,fd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),pd=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(mo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Uf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(f&&f===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(u=t.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(qa);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(dd||(dd={}));var vd,_d=function(){function t(e){r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),md={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},gd=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},yd={customTypes:null,includeEmpty:!1,includeFrozen:!0},kd=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},bd={myMemberStateFilter:e.MyMemberStateFilter.ALL},Ed=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(vd=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",vd.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",vd.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",vd.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",vd.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",vd.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",vd.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",vd.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",vd.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var wd,xd={keys:[]},Cd=function(t){return F(e.UnreadItemKey,t.keys)},Td={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},Sd=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Id={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},Nd=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Md=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_,m=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof hu)){n.next=27;break}r=e.channels,a=e.source,u=e.data,c=r.filter((function(e){return e instanceof Vp})),l=s.filterOffsetChanged(c),h=y(l),n.prev=5,h.s();case 7:if((d=h.n()).done){n.next=13;break}return f=d.value,n.next=11,i.removeUnderOffset(f.url,f.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(c);case 23:p=n.sent,this._broadcastUpdateEvent(p,a,u),n.next=39;break;case 27:if(!(e instanceof du)){n.next=36;break}return v=e.channelUrls,_=e.source,n.next=31,s.remove(v);case 31:return n.next=33,xa((function(){return b(m,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(v),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:this._broadcastRemoveEvent(v,_),n.next=39;break;case 36:if(!(e instanceof uu)){n.next=39;break}return n.next=39,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){r.value.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ad=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,x=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof oi)){n.next=14;break}if(r=e.messages,a=e.source,s=r.filter((function(e){return e.messageId>0})),u=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(s);case 2:return e.next=4,o.remove(s.map((function(e){return e instanceof Ns?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(s,a);case 8:if(!(u.length>0)){n.next=12;break}return n.next=11,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(u);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(u,a);case 12:n.next=61;break;case 14:if(!(e instanceof ui)){n.next=21;break}return c=e.messageIds,l=e.source,n.next=18,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(c);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(c,l),n.next=61;break;case 21:if(!(e instanceof ci)){n.next=28;break}return h=e.reqId,d=e.source,n.next=25,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([h]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(h,d),n.next=61;break;case 28:if(!(e instanceof li)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return i.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof hi)){n.next=52;break}return m=e.event,g=e.source,n.next=45,i.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof di)){n.next=61;break}return k=e.event,E=e.source,n.next=56,i.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(k,E);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Od=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},yd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return s(n)}(Ae),Ud=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Vp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Oe),Rd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?pe:fe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Vp(e,a),s}return s(n)}(Oe),Dd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,x=e.metadataValues,C=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:f,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:x,metadata_value_startswith:C,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(Ae),Pd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Vp(e,t)}))),s.ts=null!=u?u:null,s}return s(n)}(Oe),Fd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Ae),Gd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(Oe),qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params={item_keys:o},a}return s(n)}(Ae),Hd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(Oe),jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Ae),zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Vd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Ae),Bd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ee,"/count"),a.params={channel_url:s,status:Wd(i)},o&&(a.params.message_type=o),a}return s(n)}(Ae),Kd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(Oe),Wd=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(gs.PENDING);break;case e.ScheduledStatus.SENT:n.push(gs.IN_QUEUE),n.push(gs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(gs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(gs.FAILED)}})),n}},Yd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,x=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path=fe,a.params=ue({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:x,message_survival_seconds:E}),a}return s(n)}(Ae),Zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s.isCreated=a.is_created,s}return s(n)}(Oe),Jd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Ae),Xd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new _d(s),i}return s(n)}(Ge),$d=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),ef=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new ld(e,t)})):[new ld(e,s.data)],i}return s(n)}(Xd),nf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(Ae),rf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new ld(i._iid,s.data),i}return s(n)}(Xd),af=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Ae),sf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),of=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitees,v=void 0===p?[]:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitees=v.map((function(t){return new ld(e,t)})),i}return s(n)}(Xd),uf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Ae),cf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitee,v=void 0===p?null:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitee=v?new ld(e,v):null,i}return s(n)}(Xd),lf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(ia),hf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new hd(e,s),i}return s(n)}(Ge),df=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}return s(n)}(Ae),ff=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(Ge),pf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:o,allow_auto_unhide:u},a}return s(n)}(Ae),vf=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=s.data.allow_auto_unhide,i.hidePreviousMessages=s.data.hide_previous_messages),i.messageOffsetTimestamp=s.ts_message_offset,i}return s(n)}(Ge),mf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),gf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),yf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),kf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new Ja(i._iid,e)})),i}return s(n)}(Xd),Ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(Ge),wf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(ia),xf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Us(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Cf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Us(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ys(s),i}return s(n)}(Ge),Sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new xi(e,s),i}return s(n)}(Ge),If=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new no(e,s),i.status=Ds(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),Nf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=n.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(C=n.metadataValues)&&void 0!==C?C:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Ka(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Uf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,this,this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Mf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return r.abrupt("break",335);case 81:return q=n.as(ff),H=q.channelUrl,j=q.deliveredStateUpdate,z=void 0===j?{}:j,V=this._groupChannelCache.isCachedInMemory(H),r.next=85,this.getChannel(H,!0);case 85:if(B=r.sent,V)for(Q in z)B._updateUndeliveredMemberState(Q,z[Q]);return Object.keys(z).some((function(e){return e!==cn._sdkState.userId}))&&(this._dispatcher.dispatch(new hu({channels:[B],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUndeliveredMemberStatusUpdated(B)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 89:if(K=n.as(Tf),W=K.channelUrl,Y=K.channelType,Z=K.event,Y!==e.ChannelType.GROUP){r.next=99;break}return r.next=93,this.getChannel(W,!0);case 93:return J=r.sent,r.next=96,this.getMessageFromCache(Z.messageId);case 96:(X=r.sent)&&(X.applyReactionEvent(Z),this._dispatcher.dispatch(new oi({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onReactionUpdated(J,Z)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return r.abrupt("break",335);case 100:if($=n.as(Sf),(ee=$.event).channelType!==e.ChannelType.GROUP){r.next=110;break}return r.next=104,this.getChannel(ee.channelUrl,!0);case 104:return te=r.sent,r.next=107,this.getMessageFromCache(ee.targetMessageId);case 107:(ne=r.sent)&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new oi({messages:[ne],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onThreadInfoUpdated(te,ee)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return r.abrupt("break",335);case 111:re=n.as(Ef),ae=re.groupChannelMemberCounts,se=[],ie=y(ae),r.prev=114,ie.s();case 116:if((oe=ie.n()).done){r.next=125;break}return ue=oe.value,ce=ue.channelUrl,le=ue.memberCount,he=ue.joinedMemberCount,de=ue.updatedAt,r.next=121,this.getChannelFromCache(ce);case 121:(fe=r.sent)&&fe._setLatestMemberCount(le,he,de)&&se.push(fe);case 123:r.next=116;break;case 125:r.next=130;break;case 127:r.prev=127,r.t2=r.catch(114),ie.e(r.t2);case 130:return r.prev=130,ie.f(),r.finish(130);case 133:return se.length>0&&(this._dispatcher.dispatch(new hu({channels:se,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(se)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 135:if(pe=n.as(If),ve=pe.event,_e=pe.status,me=pe.channelUrl,ge=pe.channelType,!me||ge!==e.ChannelType.GROUP){r.next=142;break}return r.next=139,this.getChannel(me,!0);case 139:ye=r.sent,this._dispatcher.dispatch(new hi({event:ve,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(_e===Ls?function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(ye,ve.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(ye,ve)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return r.abrupt("break",335);case 143:if(ke=n.as(Xh),be=ke.event,Ee=ke.channelUrl,we=ke.channelType,!Ee||we!==e.ChannelType.GROUP){r.next=150;break}return r.next=147,this.getChannel(Ee,!0);case 147:xe=r.sent,this._dispatcher.dispatch(new di({event:be,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(xe,be)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return r.abrupt("break",335);case 151:if(Ce=n.as(Xd),!(Te=Ce.event).isGroupChannelEvent){r.next=323;break}r.t3=Te.category,r.next=r.t3===dd.CHANNEL_JOIN?156:r.t3===dd.CHANNEL_LEAVE?165:r.t3===dd.CHANNEL_OPERATOR_UPDATE?181:r.t3===dd.CHANNEL_INVITE?192:r.t3===dd.CHANNEL_DECLINE_INVITE?202:r.t3===dd.TYPING_START||r.t3===dd.TYPING_END?210:r.t3===dd.USER_CHANNEL_MUTE||r.t3===dd.USER_CHANNEL_UNMUTE?219:r.t3===dd.USER_CHANNEL_BAN?246:r.t3===dd.USER_CHANNEL_UNBAN?259:r.t3===dd.CHANNEL_FREEZE||r.t3===dd.CHANNEL_UNFREEZE?265:r.t3===dd.CHANNEL_HIDE?273:r.t3===dd.CHANNEL_UNHIDE?283:r.t3===dd.CHANNEL_DELETED?290:r.t3===dd.CHANNEL_PROP_CHANGED?296:r.t3===dd.CHANNEL_META_DATA_CHANGED?302:r.t3===dd.CHANNEL_META_COUNTERS_CHANGED?311:r.t3===dd.PINNED_MESSAGE_CHANGED?317:323;break;case 156:return r.next=158,this.getChannel(Te.channelUrl,!0);case 158:return Se=r.sent,Ie=n.as(tf),Ne=Ie.memberCount,Me=Ie.joinedMemberCount,Ae=Ie.members,Oe=!1,Ae.forEach((function(t){Se.isExclusive||Se.isSuper||Se.isBroadcast?Oe=Oe||Se._setLatestMemberCount(Ne,Me,Te.ts):(t.state=e.MemberState.JOINED,Se.addMember(t,Te.ts),cn._updateJoinedMemberCount(Se)),t.userId===cn._sdkState.userId&&(Se.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new hu({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ae);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Se,r)}}catch(e){n.e(e)}finally{n.f()}Se.isBroadcast&&Oe&&e.onChannelMemberCountChanged([Se])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 165:if(!(Ue=this._leftChannels.get(Te.channelUrl))){r.next=170;break}r.t4=Ue.channel,r.next=173;break;case 170:return r.next=172,this.getChannel(Te.channelUrl,!0);case 172:r.t4=r.sent;case 173:return Re=r.t4,Le=n.as(rf),De=Le.memberCount,Pe=Le.joinedMemberCount,Fe=Le.member,Ge=!1,qe=ds.of(this._iid),He=qe.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(De,Pe,Te.ts):(He.enabledChannelMemberShipHistory?(Re.members.find((function(e){return e.userId===Fe.userId})).state=e.MemberState.LEFT,Re.memberCount=De):Re.removeMember(Fe),this._updateJoinedMemberCount(Re)),Fe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new du({channelUrls:[Re.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Re,Fe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 181:return r.next=183,this.getChannel(Te.channelUrl,!0);case 183:je=r.sent,ze=n.as(bf),Ve=ze.operators,Be=Ve.map((function(e){return e.userId})),Qe=y(je.members);try{for(Qe.s();!(Ke=Qe.n()).done;)(We=Ke.value).role=Be.includes(We.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Qe.e(e)}finally{Qe.f()}return je.myRole=Be.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new hu({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 192:return r.next=194,this.getChannel(Te.channelUrl,!0);case 194:Ye=r.sent,Ze=n.as(of),Je=Ze.memberCount,Xe=Ze.joinedMemberCount,$e=Ze.inviter,(et=Ze.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),tt=y(et);try{for(tt.s();!(nt=tt.n()).done;)rt=nt.value,Ye.isExclusive||Ye.isSuper||Ye.isBroadcast?Ye._setLatestMemberCount(Je,Xe,Te.ts):Ye.addMember(rt,Te.ts),this._sdkState.userId===rt.userId&&(Ye.hiddenState=e.HiddenState.UNHIDDEN,Ye.myMemberState!==e.MemberState.JOINED&&(Ye.myMemberState=e.MemberState.INVITED),Ye.invitedAt=Te.ts)}catch(e){tt.e(e)}finally{tt.f()}return this._dispatcher.dispatch(new hu({channels:[Ye],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ye,$e,et)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 202:return r.next=204,this.getChannel(Te.channelUrl,!0);case 204:return at=r.sent,st=n.as(cf),it=st.memberCount,ot=st.joinedMemberCount,ut=st.inviter,ct=st.invitee,at.isExclusive||at.isSuper||at.isBroadcast?at._setLatestMemberCount(it,ot,Te.ts):at.removeMember(ct),this._sdkState.userId===ct.userId?(at.invitedAt=0,at.myMemberState=e.MemberState.NONE,at.isPublic?this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new du({channelUrls:[at.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(at,ut,ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 210:return r.next=212,this.getChannel(Te.channelUrl,!0);case 212:return lt=r.sent,ht=Te.category===dd.TYPING_START,dt=n.as(ht?gf:kf),ft=dt.user,lt._updateTypingStatus(ft,ht?Te.ts:0),this._dispatcher.dispatch(new hu({channels:[lt],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 219:return r.next=221,this.getChannel(Te.channelUrl,!0);case 221:pt=r.sent,vt=Te.category===dd.USER_CHANNEL_MUTE,_t=n.as(vt?lh:dh),(mt=_t.user).userId===this._sdkState.userId&&(pt.myMutedState=vt?e.MutedState.MUTED:e.MutedState.UNMUTED,pt._myMutedRemainingTime=mt.restrictionInfo.remainingDuration),gt=y(pt.members),r.prev=226,gt.s();case 228:if((yt=gt.n()).done){r.next=235;break}if((kt=yt.value).userId!==mt.userId){r.next=233;break}return kt.isMuted=vt,r.abrupt("break",235);case 233:r.next=228;break;case 235:r.next=240;break;case 237:r.prev=237,r.t5=r.catch(226),gt.e(r.t5);case 240:return r.prev=240,gt.f(),r.finish(240);case 243:return this._dispatcher.dispatch(new hu({channels:[pt],source:vt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:mt.userId})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vt?e.onUserMuted(pt,mt):e.onUserUnmuted(pt,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 246:if(!(bt=this._leftChannels.get(Te.channelUrl))){r.next=251;break}r.t6=bt.channel,r.next=254;break;case 251:return r.next=253,this.getChannel(Te.channelUrl,!0);case 253:r.t6=r.sent;case 254:return Et=r.t6,this._markAsLeave(Et),wt=n.as(ph),xt=wt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Et,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 259:return r.next=261,this.getChannel(Te.channelUrl,!0);case 261:return Ct=r.sent,Tt=n.as(_h),St=Tt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(Ct,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 265:return r.next=267,this.getChannel(Te.channelUrl,!0);case 267:return It=r.sent,Nt=n.as(gh),Mt=Nt.freeze,It.isFrozen=Mt,this._dispatcher.dispatch(new hu({channels:[It],source:Mt?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Mt?e.onChannelFrozen(It):e.onChannelUnfrozen(It)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 273:return r.next=275,this.getChannel(Te.channelUrl,!0);case 275:return At=r.sent,Ot=n.as(_f),Ut=Ot.allowAutoUnhide,Rt=Ot.hidePreviousMessages,Lt=Ot.messageOffsetTimestamp,null!==Ut&&(At.hiddenState=Ut?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Rt&&Rt&&At._updateUnreadCount(0,0),null!==Lt&&(At.messageOffsetTimestamp=Lt),this._dispatcher.dispatch(new hu({channels:[At],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 283:return r.next=285,this.getChannel(Te.channelUrl,!0);case 285:return(Dt=r.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new hu({channels:[Dt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 290:return r.next=292,this.getChannel(Te.channelUrl,!0);case 292:return Pt=r.sent,this._dispatcher.dispatch(new du({channelUrls:[Te.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 296:return r.next=298,this.getChannelWithoutCache(Te.channelUrl,!0);case 298:return Ft=r.sent,this._dispatcher.dispatch(new hu({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 302:return r.next=304,this.getChannel(Te.channelUrl,!0);case 304:return Gt=r.sent,qt=n.as(Yl),Ht=qt.created,jt=qt.updated,zt=qt.deleted,Ht&&Gt._upsertCachedMetaData(Ht,Te.ts),jt&&Gt._upsertCachedMetaData(jt,Te.ts),zt&&Gt._removeFromCachedMetaData(zt,Te.ts),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ht&&e.onMetaDataCreated(Gt,Ht),jt&&e.onMetaDataUpdated(Gt,jt),zt&&e.onMetaDataDeleted(Gt,zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 311:return r.next=313,this.getChannel(Te.channelUrl,!0);case 313:return Vt=r.sent,Bt=n.as(ih),Qt=Bt.created,Kt=Bt.updated,Wt=Bt.deleted,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Qt&&e.onMetaCounterCreated(Vt,Qt),Kt&&e.onMetaCounterUpdated(Vt,Kt),Wt&&e.onMetaCounterDeleted(Vt,Wt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 317:return r.next=319,this.getChannel(Te.channelUrl,!0);case 319:return Yt=r.sent,Zt=n.as(Af),Jt=Zt.pinnedMessageIds,Xt=Zt.latestPinnedMessage,($t=Zt.ts)>Yt._pinnedMessagesUpdatedAt&&(Yt.pinnedMessageIds=Jt,Yt.lastPinnedMessage=Xt,Yt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new hu({channels:[Yt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(Yt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Yt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",323);case 323:return r.abrupt("break",335);case 324:en=n.as(pu),tn=en.event,r.t7=tn.category,r.next=r.t7===Ho.USER_BLOCK?328:r.t7===Ho.USER_UNBLOCK?331:334;break;case 328:return nn=ou.getDataAsUserBlockEvent(this._iid,tn),rn=nn.blocker,an=nn.blockee,this._groupChannelCache.block(rn.userId,an.userId),r.abrupt("break",334);case 331:return sn=ou.getDataAsUserBlockEvent(this._iid,tn),on=sn.blocker,un=sn.blockee,this._groupChannelCache.unblock(on.userId,un.userId),r.abrupt("break",334);case 334:return r.abrupt("break",335);case 335:r.next=341;break;case 337:if(r.prev=337,r.t8=r.catch(0),!M(r.t8)){r.next=341;break}throw r.t8;case 341:case"end":return r.stop()}}),r,this,[[0,337],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)).throw(A.invalidParameters),s=new Rd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Ld),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Rd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Ld),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new du({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new hu({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new du({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Dd(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Pd),c=u.channels,l=u.token,this._dispatcher.dispatch(new hu({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:go;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:go;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Mf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},yd),r),Ya((L("string",n)||L("number",n))&&kd(s)).throw(A.invalidParameters),i=new Od(ue({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(Ud),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new hu({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new du({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},bd),e),Ya(Ed(r)).throw(A.invalidParameters),a=new Fd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Gd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},xd),e),Ya(Cd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new qd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Hd),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ue({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new jd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(zd),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Td),e),Ya(Sd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Vd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Bd),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Id),e),Ya(Nd(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Qd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Kd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ds.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ds.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ds.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=null),a=new Yd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(Zd),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Ya(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Jd({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Ya(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new Jd({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Of[e]}},{key:"clear",value:function(e){Of[e]&&delete Of[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(wd||(wd={}));var Rf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._worker=null,s._state=wd.IDLE,s._semaphore=null,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===wd.IDLE}},{key:"isRunning",get:function(){return this._state===wd.RUNNING}},{key:"isDone",get:function(){return this._state===wd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Mf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._prevSyncLoopCount<1,i.nextToken=this._metadata.range.top,this._metadata.previousComplete=u.length0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Mf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._nextSyncLoopCount<1,i.nextToken=this._metadata.range.bottom,v.debug("message background next sync progress",i),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",i);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=ds.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=ds.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,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:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Pf[e]||(Pf[e]={}),Pf[e][t.url]||(Pf[e][t.url]=new n({_iid:e,channel:t})),Pf[e][t.url].ref++,Pf[e][t.url]}},{key:"clear",value:function(e,t){Pf[e]&&Pf[e][t]&&(Pf[e][t].close(),delete Pf[e])}}]),n}(),Gf={},qf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=o;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Rf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=Ei.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Gf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Gf[e]||(Gf[e]={}),Gf[e][t.url]||(Gf[e][t.url]=new n({_iid:e,channel:t})),Gf[e][t.url].ref++,Gf[e][t.url]}},{key:"clear",value:function(e,t){Gf[e]&&Gf[e][t]&&(Gf[e][t].close(),delete Gf[e])}}]),n}(),Hf={},jf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=s,this._channel=i;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Rf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=ds.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=to.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof A&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Hf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Hf[t]||(Hf[t]={}),Hf[t][n.url]||(Hf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Hf[t][n.url].ref++,Hf[t][n.url]}}]),e}(),zf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ue({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!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(Ae),Vf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Vs(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Vs(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(Oe),Bf=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},Qf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Kf=function(e,t,n){if(e.length>0){for(var r=Qf(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:Wf(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Wf=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a}},Yf=function(e,t){return t instanceof Ns?e.findIndex((function(e){return e instanceof Ns&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Zf=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Jf=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},Xf=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var $f,ep,tp,np=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;wa((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),rp=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=a,this._key="mc-".concat(re()),this.filter=null!=u?u:new Eo,this._channel=o,this._syncRange=new Mf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+Xf,this._limit=l||go;var h=Uf.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Qf(n,i._channel);if(s>=0){switch(i._channel=n[s],r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;ds.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;ds.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}wa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(r),lu(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),wa((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(ii(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=ds.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=Ff.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=qf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=jf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Rf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof ha)switch(n.stateType){case aa.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Yf(this._messages,l)<0){Yf(this._unsentMessages,l)<0&&o.push(l);var h=Jf(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ns){Yf(this._unsentMessages,l)<0&&Yf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=Yf(this._messages,l);if(d<0){var f=Yf(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=Jf(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Ns){var m=Yf(this._unsentMessages,l);m<0?Yf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}ii(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Df(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=Zf(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=Zf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=Zf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=Yf(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=Yf(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=Jf(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Ns){var f=Yf(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Df(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return ii(n)&&i.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Uf.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Ei.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,x,C,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=Uf.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,Ea((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,x,C,T,S,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=ds.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new zf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Vf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,x=m.nextMessages,C=void 0===x?[]:x,T=m.nextHasmore,S=m.isContinuousNextMessages,g?wa((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,M=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,N].concat(_(C.map((function(e){return e.createdAt}))))),h.dispatch(new oi({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new oi({messages:C,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,A),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(M,A)),IA&&this._nextFill.start(A));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=ds.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,x=0,C=0;C=p&&x++;this._hasPrevious=w>=f,this._hasNext=x>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof A&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+Xf,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){Uf.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=null,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new Lf(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)}},{key:"initialize",value:function(n){var r=this,a=new np;this._messages=[],this._unsentMessages=[],this._syncRange=new Mf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),xa((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(M(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=ds.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(M(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=ds.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,xa((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,xa((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Uf.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=ds.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=Uf.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),ap={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},sp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},ip={hidePreviousMessages:!1,allowAutoUnhide:!0},op=function(e){return L("boolean",e.hidePreviousMessages)&&L("boolean",e.allowAutoUnhide)},up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),cp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new ld(e,t)}))),s}return s(n)}(Oe);e.MutedMemberFilter=void 0,($f=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",$f.MUTED="muted",$f.UNMUTED="unmuted",e.MemberListOrder=void 0,(ep=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",ep.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(tp=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",tp.JOINED="joined_only",tp.INVITED="invited_only",tp.INVITED_BY_FRIEND="invited_by_friend",tp.INVITED_BY_NON_FRIEND="invited_by_non_friend";var lp,hp,dp,fp=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new up(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(cp),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),pp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),vp=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Vp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Oe),_p=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a.params=ue({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(Ae),mp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Vp(e,a),s}return s(n)}(Oe),gp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),yp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Ae),kp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Ae),bp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(Oe),Ep=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Ae),wp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),xp=Object.assign(Object.assign({},wl),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Cp=function(e){return xl(e)&&L("number",e.scheduledAt,!0)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Tp=Object.assign(Object.assign({},Cl),{scheduledAt:null}),Sp=function(e){return Tl(e)&&L("number",e.scheduledAt,!0)},Ip=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Np=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),Mp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),Op=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Ae),Up=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Ae),Rp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Lp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Pp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),Fp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),Gp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Vs(e,a.message),s}return s(n)}(qa),qp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ue({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(Ae),Hp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).hasMore=null,s.token=null;var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new Gp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Oe),jp=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new qp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Hp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.CountPreference=void 0,(lp=e.CountPreference||(e.CountPreference={})).ALL="all",lp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",lp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",lp.OFF="off",e.MutedState=void 0,(hp=e.MutedState||(e.MutedState={})).MUTED="muted",hp.UNMUTED="unmuted",e.HiddenState=void 0,(dp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",dp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",dp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var zp,Vp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,x,C,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new ld(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new Ja(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(x=n.unread_mention_count)&&void 0!==x?x:0),s.pinnedMessageIds=null!==(C=n.pinned_message_ids)&&void 0!==C?C:[],s.lastPinnedMessage=n.latest_pinned_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Ns&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ds.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=ds.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Ka(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rp(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new jp(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof ld?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Ns&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ds.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)>=e.createdAt&&s.push(i))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)0&&void 0!==arguments[0]&&arguments[0],n=ds.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new hd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:ld.payloadify(a),ts:s})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=ds.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Rd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Ld),c=u.channel,this._update(c),s.dispatch(new hu({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ap),n),Ya(sp(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new _p(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(mp),h=l.channel,this._update(h),i.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e.every((function(e){return e instanceof Ja}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new af({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(sf),l=c.channel,this._update(l),s.dispatch(new hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new $d({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(ef),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new nf({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new pp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(vp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new uf({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Uf.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Uf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Fi,a=ds.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(t){var s=Uf.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Uf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Uf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Ns&&(s=ds.of(this._iid),s.dispatcher.dispatch(new ci({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ip),n),Ya(op(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new pf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(vf),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new yp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new gp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new lf({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(hf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Uf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)}))),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new df({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new mf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new yf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Vo),e),Ya(function(e){return Mo(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new wi;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Tp),n),Ya(Sp(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Mp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ph),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Bo),e),Ya(function(e){return To(e)&&L("number",e.scheduledAt)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new wi;return ka(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);wa((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),q(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},xp),n),Ya(Cp(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Ip(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=ds.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Np),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Ap({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Op({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Lp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Dp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Up({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Rp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.CountPreference,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new kp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(bp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Ep({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(wp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Pp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Fp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!q(e.file)){t.next=11;break}return r=ds.of(this._iid),a=r.requestQueue,s=new ps({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(vs),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return ld.payloadify(e)})),last_message:zs(e.lastMessage),inviter:e.inviter?Ja.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:zs(e.lastPinnedMessage)})):null}}]),u}($h),Bp={},Qp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=u;var c,l=ds.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Rf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,s=Uf.of(this._iid),t.next=9,s.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,o=i.channels,u=i.token,r.hasNext=o.length>=this._limit&&!!u,r.nextToken=u,this._metadata.token=u,(a=this._metadata.range).extends.apply(a,_(o.map((function(e){return e.createdAt})))),this._metadata.completed=!r.hasNext,f.debug("channel background sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:r.hasNext=!1,r.nextToken="";case 33:return t.abrupt("return",r);case 34:case"end":return t.stop()}}),n,this,[[5,22]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Mf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=ds.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Bp[this._iid])}}],[{key:"of",value:function(e){return Bp[e]||(Bp[e]=new n({_iid:e})),Bp[e].ref++,Bp[e]}},{key:"clear",value:function(e){Bp[e]&&(Bp[e].close(),delete Bp[e])}}]),n}(),Kp={},Wp=function(){function n(a){var s=this,i=a._iid;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var o,u=ds.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Rf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",this._metadata.token),t.prev=4,a=Uf.of(this._iid),t.next=8,a.getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return s=t.sent,i=s.hasMore,o=s.token,r.hasNext=i,r.nextToken=o,this._metadata.token=o,c.debug("channel changelog sync progress",r),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Kp[this._iid])}}],[{key:"of",value:function(e){return Kp[e]||(Kp[e]=new n({_iid:e})),Kp[e].ref++,Kp[e]}},{key:"clear",value:function(e){Kp[e]&&(Kp[e].close(),delete Kp[e])}}]),n}(),Yp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new fd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=ds.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Qp.of(a),this._backgroundSync.resume()),this._changelogSync=Wp.of(a),this._changelogSync.resume(),Uf.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(lu(t)){var n=e.filter((function(e){return i.filter.match(e,h.userId)})),r=e.filter((function(e){return!i.filter.match(e,h.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)}}),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof ha&&(e.stateType===aa.CONNECTED?i._isGetRemoteChannelsSucceeded||b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===aa.LOGOUT&&i.dispose())}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Kf(this.channels,h,this.order),f=d.place,p=d.oldPosition;if(-1===p)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==p?this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(p,1),this.channels.splice(p0){var v,_=y(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=Qf(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}lu(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new Lf(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return lu(n)&&s.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Lf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),r=this.channels.length>0?Bf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Uf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=ds.of(this._iid),a=r.cacheContext,s=[],!a.localCacheEnabled||!this._backgroundSync.completed){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=s.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:s=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Uf.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),Zp=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=ce.GET,s.path=fe,s.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b}),s}return s(a)}(Ae),Jp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Vp(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe);e.MembershipFilter=void 0,(zp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",zp.JOINED="joined";var Xp,$p=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=ds.of(this._iid),a=r.requestQueue,r.dispatcher,s=new Zp(Object.assign(Object.assign({},this),{token:this._token})),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(Jp),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),ev=s((function e(){r(this,e),this.onUserMuted=qe,this.onUserUnmuted=qe,this.onUserBanned=qe,this.onUserUnbanned=qe,this.onChannelChanged=qe,this.onChannelDeleted=qe,this.onChannelFrozen=qe,this.onChannelUnfrozen=qe,this.onOperatorUpdated=qe,this.onChannelMemberCountChanged=qe,this.onMetaDataCreated=qe,this.onMetaDataUpdated=qe,this.onMetaDataDeleted=qe,this.onMetaCounterCreated=qe,this.onMetaCounterUpdated=qe,this.onMetaCounterDeleted=qe,this.onMessageReceived=qe,this.onMessageUpdated=qe,this.onMessageDeleted=qe,this.onMentionReceived=qe,this.onReactionUpdated=qe,this.onThreadInfoUpdated=qe})),tv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=qe,e.onUserLeft=qe,e.onUserReceivedInvitation=qe,e.onUserDeclinedInvitation=qe,e.onChannelHidden=qe,e.onUnreadMemberStatusUpdated=qe,e.onUndeliveredMemberStatusUpdated=qe,e.onTypingStatusUpdated=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e.onPinnedMessageUpdated=qe,e}return s(n)}(ev),nv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(tv),rv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ee),a.params=ue({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h}),a}return s(n)}(Ae),av=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),sv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new rv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(av),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),iv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Uf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Nf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new $p(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new sv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Ya(L("string",e)&&t instanceof nv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Ya(L("string",e)).throw(A.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},yd),n),Ya(L("string",e)&&kd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},yd),n),Ya(L("number",e)&&kd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},bd),e),Ya(Ed(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},md),e),Ya(gd(r)).throw(A.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},md),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Ya(F("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),ov=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(n=this._channels.get(e))&&void 0!==n?n:null);case 1:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(qa),uv={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},cv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},lv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?_e:ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),hv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Sv(e,a),s}return s(n)}(Oe),dv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=ce.POST,a.path=ve,a.params=ue({channel_url:s,cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h}),a}return s(n)}(Ae),fv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),pv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(Xd),vv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),_v=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(Xd),mv={},gv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),mv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new ov(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof Ge)a._handleEvent(e);else if(e instanceof ha&&e.stateType===aa.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),mv[e]=this),mv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Wa(e);return new Sv(this._iid,Sv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,x,C,T,S,I,N,A,O,U,R,L,D,P,F,G,q,H,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,xe,Ce,Te,Se,Ie,Ne,Me,Ae,Oe,Ue,Re,Le,De=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as(wh):"FILE"===n.code?a=n.as(Ws):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(xf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived(u,i),o&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(Ch):"FEDI"===n.code?c=n.as(Sh):"AEDI"===n.code&&(c=n.as(Cf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated(f,h),d>0&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(Nh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Tf),E=k.channelUrl,w=k.channelType,x=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:C=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(C.url)&&a.onReactionUpdated(C,x)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(Sf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(Ef),A=N.openChannelMemberCounts,O=[],U=y(A),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(H=n.as(If),j=H.event,z=H.status,V=H.channelUrl,B=H.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new hi({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(z===Ls?function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as(Xh),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new di({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as(Xd),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===dd.CHANNEL_ENTER?94:r.t2===dd.CHANNEL_EXIT?101:r.t2===dd.CHANNEL_OPERATOR_UPDATE?108:r.t2===dd.USER_CHANNEL_MUTE||r.t2===dd.USER_CHANNEL_UNMUTE?116:r.t2===dd.USER_CHANNEL_BAN||r.t2===dd.USER_CHANNEL_UNBAN?123:r.t2===dd.CHANNEL_FREEZE||r.t2===dd.CHANNEL_UNFREEZE?130:r.t2===dd.CHANNEL_DELETED?138:r.t2===dd.CHANNEL_PROP_CHANGED?145:r.t2===dd.CHANNEL_META_DATA_CHANGED?150:r.t2===dd.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(pv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return se=r.sent,ie=n.as(_v),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,he=n.as(bf),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(le,de)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===dd.USER_CHANNEL_MUTE,ve=n.as(pe?lh:dh),_e=ve.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted(fe,_e):e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===dd.USER_CHANNEL_BAN,ye=n.as(ge?ph:_h),ke=ye.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned(me,ke):e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return be=r.sent,Ee=n.as(gh),we=Ee.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen(be):e.onChannelUnfrozen(be)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return xe=r.sent,r.next=143,this.removeChannelsFromCache([xe.url]);case 143:return wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return Ce=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Ce)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(Yl),Ie=Se.created,Ne=Se.updated,Me=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Me&&Te._removeFromCachedMetaData(Me,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated(Te,Ne),Me&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Ae=r.sent,Oe=n.as(ih),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted(Ae,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!M(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),a=new lv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(hv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},uv),e),Ya(cv(r)).throw(A.invalidParameters),a=new dv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(hv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return mv[e]}}]),n}(),yv={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},kv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},bv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=ce.GET,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Ae),Ev=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new El(e,t)})),s}return s(n)}(Oe),wv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new bv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ev),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),xv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a.params=ue({cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l}),a}return s(n)}(Ae),Cv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Sv(e,a),s}return s(n)}(Oe),Tv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Sv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new Ja(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Ka(this)}},{key:"isOperator",value:function(e){return e instanceof Ja?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new wv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=gv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new fv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(pv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),gv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new vv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(_v),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),gv.of(this._iid).setExitedToCache(this),Ei.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},yv),e),Ya(kv(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new xv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Cv),c=u.channel,this._update(c),l=gv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},yv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Tv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=gv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},$h.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Ja.payloadify(e)}))})):null}}]),u}($h),Iv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=qe,e.onUserExited=qe,e.onChannelParticipantCountChanged=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e}return s(n)}(ev),Nv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Iv),Mv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=ce.GET,a.path=ve,a.params=ue({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(Ae),Av=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Sv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe),Ov=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Mv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Av),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=gv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),Uv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new gv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ov(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},uv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(fs);Xp=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function Gv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function qv(e){return"string"!=typeof e&&(e=String(e)),e}function Hv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Dv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function jv(e){this.map={},e instanceof jv?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function zv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Vv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Bv(e){var t=new FileReader,n=Vv(t);return t.readAsArrayBuffer(e),n}function Qv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Kv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Dv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Dv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Dv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Dv.arrayBuffer&&Dv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Qv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Dv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Fv(e))?this._bodyArrayBuffer=Qv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Dv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Dv.blob&&(this.blob=function(){var e=zv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=zv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Bv)}),this.text=function(){var e,t,n,r=zv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Vv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Zv(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function Jv(e,t){if(!(this instanceof Jv))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new jv(t.headers),this.url=t.url||"",this._initBody(e)}Yv.prototype.clone=function(){return new Yv(this,{body:this._bodyInit})},Kv.call(Yv.prototype),Kv.call(Jv.prototype),Jv.prototype.clone=function(){return new Jv(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new jv(this.headers),url:this.url})},Jv.error=function(){var e=new Jv(null,{status:0,statusText:""});return e.type="error",e};var Xv=[301,302,303,307,308];Jv.redirect=function(e,t){if(-1===Xv.indexOf(t))throw new RangeError("Invalid status code");return new Jv(null,{status:t,headers:{location:e}})};var $v=Lv.DOMException;try{new $v}catch(an){($v=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),$v.prototype.constructor=$v}function e_(e,t){return new Promise((function(r,a){var s=new Yv(e,t);if(s.signal&&s.signal.aborted)return a(new $v("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new jv,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new Jv(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new $v("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Lv.location.href?Lv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Dv.blob?i.responseType="blob":Dv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof jv?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,qv(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}e_.polyfill=!0,Lv.fetch||(Lv.fetch=e_,Lv.Headers=jv,Lv.Request=Yv,Lv.Response=Jv);var t_=Object.freeze({__proto__:null});return e.AdminMessage=Us,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=mc,e.BannedUserListQuery=Pl,e.BaseChannel=$h,e.BaseMessage=Is,e.BlockedUserListQuery=kc,e.CachedChannelInfo=ee,e.ConnectionHandler=vo,e.Emoji=ac,e.EmojiCategory=sc,e.EmojiContainer=ic,e.FileMessage=Bs,e.FriendListQuery=wc,e.GroupChannel=Vp,e.GroupChannelCollection=Yp,e.GroupChannelEventContext=Lf,e.GroupChannelFilter=fd,e.GroupChannelHandler=nv,e.GroupChannelListQuery=Nf,e.GroupChannelModule=iv,e.LocalCacheConfig=te,e.Member=ld,e.MemberListQuery=fp,e.MemoryStore=cl,e.MessageCollection=rp,e.MessageCollectionInitHandler=np,e.MessageEventContext=Df,e.MessageFilter=Eo,e.MessageMetaArray=bs,e.MessageModule=Gi,e.MessageRequestHandler=wi,e.MessageSearchQuery=Ui,e.MultipleFilesMessage=js,e.MultipleFilesMessageRequestHandler=Fi,e.MutedUserListQuery=Rl,e.OGImage=Es,e.OGMetaData=ws,e.OpenChannel=Sv,e.OpenChannelHandler=Nv,e.OpenChannelListQuery=Ov,e.OpenChannelModule=Uv,e.OperatorListQuery=Al,e.Participant=El,e.ParticipantListQuery=wv,e.PinnedMessage=Gp,e.PinnedMessageListQuery=jp,e.Plugin=Rs,e.PreviousMessageListQuery=Li,e.PublicGroupChannelListQuery=$p,e.Reaction=ks,e.ReactionEvent=ys,e.ReadStatus=hd,e.RestrictedUser=bl,e.RestrictionInfo=kl,e.ScheduledMessageListQuery=sv,e.SendbirdChat=td,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Cs,e.SessionHandler=po,e.ThreadInfo=_s,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=Ms,e.UIKitConfigInfo=Pa,e.UploadedFileInfo=Hs,e.User=Ja,e.UserEventHandler=_o,e.UserMessage=qs,Object.defineProperty(e,"__esModule",{value:!0}),e}({});